You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Shipping/ExchangesUnitShareGridSourc...

259 lines
9.0 KiB
C#

3 years ago
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Text;
namespace DSWeb.Shipping
{
public partial class ExchangesUnitShareGridSource : System.Web.UI.Page
{
public string strHandle;//用户GID
public string strUserID;//登录用户GID
public string strCompanyID;//公司GID
public string strShowName;//用户显示名
public string strDeptName;//部门名称
public string strGid;//部门名称
public string strClientid;
public string strCompanyid;
protected void Page_Load(object sender, EventArgs e)
{
//Session["USERID"] = "1BEC90E1-9780-472F-90C2-0C6390C044A4";
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
else
{
Server.Transfer("~/Error/FriendError.aspx");
return;
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
//
if (Request.QueryString["id"] != null)//if (Request.QueryString["id"] != null)
{
strGid = Request.QueryString["id"].ToString();//"topseaeusername129481962859531250";
}
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString();
}
if (Request.QueryString["clientid"] != null)
{
strClientid = Request.QueryString["clientid"].ToString();
}
if (Request.QueryString["companyid"] != null)
{
strCompanyid = Request.QueryString["companyid"].ToString();
}
if (strHandle != null)
{
if (strHandle == "comptree")
{
Response.Write(GetDepartmentTree());
}
if (strHandle == "userlist")
{
Response.Write(GetUserListByCondition());
}
if (strHandle == "save")
{
Response.Write(GetSave());
}
if (strHandle == "iscompanyid")
{
Response.Write(GetISCompanyid());
}
}
}
#region 保存客户的共享信息
/// <summary>
/// 保存客户的共享信息
/// </summary>
/// <returns></returns>
private string GetISCompanyid()
{
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string alt = T_ALL_DA.GetISCompanyid(strClientid);
return alt.ToString().Trim();
}
#endregion
#region 保存客户的共享信息
/// <summary>
/// 保存客户的共享信息
/// </summary>
/// <returns></returns>
private string GetSave()
{
int iResult = 0;
string alt = "";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
iResult = T_ALL_DA.GetInfoClientShareSave(strClientid, strCompanyid, strUserID);
if (iResult<1)
{
alt = "操作失误!";
}
return alt.ToString().Trim();
}
#endregion
#region 获取客户的共享信息
/// <summary>
/// 获取客户的共享信息
/// </summary>
/// <returns></returns>
private string GetUserListByCondition()
{
UserDA userDA = new UserDA();
DataTable sourceTable;
string condition = "";
if (strGid != null)
{
if (strGid != "")
{
condition += String.Format(" AND S.CLIENTID = '{0}' ", strGid);
}
else
{
condition = " and 1<0";
}
}
else
{
condition = " and 1<0";
}
string strSql = String.Format("SELECT S.GID, I.SHORTNAME, C.NAME,(case S.ISMASTER when 'True' then '是' else '否' end) as ISMASTER,(case S.ISSHARE when 'True' then '是' else '否' end) as ISSHARE,CREATEUSER=(select SHOWNAME from [user] where gid=S.CREATEUSER and ISDELETED=0),S.CREATETIME, MODIFIEDUSER=(select SHOWNAME from [user] where gid=S.MODIFIEDUSER and ISDELETED=0), S.MODIFIEDTIME FROM info_client_share AS S INNER JOIN company AS C ON S.COMPANYID = C.GID INNER JOIN info_client AS I ON S.CLIENTID = I.GID WHERE (C.ISDELETED = 0) AND (C.ISDISABLE = 0) AND (I.ISSTOP = 0) {0} ORDER BY S.ISMASTER,C.NAME", condition);//, S.CLIENTID, S.COMPANYID
sourceTable = userDA.GetExcuteSql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 获取分公司和部门信息
/// <summary>
/// 获取分公司和部门信息
/// </summary>
/// <returns>返回JSON Tree数据</returns>
private string GetDepartmentTree()
{
StringBuilder userBuilder = new StringBuilder();
IList<CompanyEntity> companyEntities = new List<CompanyEntity>();
CompanyDA companyDA = new CompanyDA();
companyEntities = companyDA.GetAllCompany();
userBuilder.Append("{id:0");
if (companyEntities.Count > 0)
{
userBuilder.Append(",item:[");
for (int k = 0; k < companyEntities.Count; k++)
{
if (k == 0)
{
userBuilder.Append("{id:\"" + companyEntities[k].GID + "#comp\",");
}
else
{
userBuilder.Append(",{id:\"" + companyEntities[k].GID + "#comp\",");
}
userBuilder.Append("text:\"" + companyEntities[k].NAME + "\"");
//获取部门信息
//IList<SysDeptEntity> sysDeptEntities = new List<SysDeptEntity>();
//sysDeptEntities = new SysDeptDA().GetDepartmentByCompanyID(companyEntities[k].GID);
//if (sysDeptEntities.Count > 0)
//{
// userBuilder.Append(",item:[");
// for (int j = 0; j < sysDeptEntities.Count; j++)
// {
// userBuilder.Append("{id:\"" + sysDeptEntities[j].GID + "#dept\",");
// userBuilder.Append("text:\"" + sysDeptEntities[j].DEPTNAME + "\"");
// if (j == sysDeptEntities.Count - 1)
// {
// userBuilder.Append("}");
// }
// else
// {
// userBuilder.Append("},");
// }
// }
// userBuilder.Append("]");
//}
userBuilder.Append("}");
}
userBuilder.Append("]");
}
userBuilder.Append("}");
return userBuilder.ToString();
}
#endregion
}
}