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.
287 lines
11 KiB
C#
287 lines
11 KiB
C#
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 DSWeb.Models;
|
|
using DSWeb.EntityDA;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace DSWeb.ParameterSet
|
|
{
|
|
public partial class ATSysDeptSetGridSource : System.Web.UI.Page
|
|
{
|
|
private string strReadXmlType = "";//读取xml串方式 "init"-初始化获取所有账户信息;"add"-添加新的账户信息;"delete"-删除账户信息;"exist"查看是否有与委托相关账户
|
|
private int iShowCount;//每页显示数据量
|
|
|
|
//delete
|
|
private string strSysDeptGid;//账户信息GID
|
|
private string strHandle;//账户操作说明
|
|
private const int iResult = -99;//参数错误
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
private string strRange = String.Empty;//权限可视范围
|
|
RangeDA RangeDA = new RangeDA();
|
|
public string strUserID;//用户GID
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (Session["USERID"] != null)
|
|
{
|
|
strUserID = Session["USERID"].ToString().Trim();
|
|
}
|
|
else
|
|
{
|
|
Server.Transfer("~/Error/FriendError.aspx");
|
|
return;
|
|
//strUserID = "";
|
|
}
|
|
//
|
|
#region 判断参数是否正确
|
|
if (Request.QueryString["read"] != null)
|
|
{
|
|
strReadXmlType = Request.QueryString["read"].ToString().Trim();
|
|
}
|
|
if (Request.QueryString["showcount"] != null)
|
|
{
|
|
iShowCount = int.Parse(Request.QueryString["showcount"].ToString());
|
|
}
|
|
#endregion
|
|
|
|
strRange = "";
|
|
/*
|
|
//权限可视范围
|
|
strRange = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modOrderManagement");
|
|
if (strRange.Trim().Equals("0"))//全部
|
|
{
|
|
strRange = "";
|
|
}
|
|
else if (strRange.Trim().Equals("1"))//分公司
|
|
{
|
|
strRange = " and BSNO in(" + RangeDA.GetOrderManagementCompany(strUserID.Trim()) + ")";
|
|
}
|
|
else if (strRange.Trim().Equals("2"))//部门
|
|
{
|
|
strRange = " and BSNO in(" + RangeDA.GetOrderManagementDEPT(strUserID.Trim()) + ")";
|
|
}
|
|
else if (strRange.Trim().Equals("3"))//个人
|
|
{
|
|
strRange = " and BSNO in(" + RangeDA.GetOrderManagementPerson(strUserID.Trim()) + ")";
|
|
}
|
|
else if (strRange.Trim().Equals("4"))//无
|
|
{
|
|
strRange = " and 1<0";
|
|
}
|
|
else//空
|
|
{
|
|
strRange = " and 1<0";
|
|
}
|
|
*/
|
|
|
|
//
|
|
if (Request.QueryString["codename"] != null)
|
|
{
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
string strCodeName = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["codename"].ToString())));
|
|
strRange += " and (DEPTNAME like '%" + strCodeName + "%')";
|
|
}
|
|
|
|
//
|
|
if (!strReadXmlType.Equals(""))
|
|
{
|
|
if (strReadXmlType.Equals("delete") || strReadXmlType.Equals("recover"))
|
|
{
|
|
strSysDeptGid = (String)Request.QueryString["gid"] as String;
|
|
strHandle = (String)Request.QueryString["read"] as String;
|
|
if (strSysDeptGid == null || strHandle == null)
|
|
{
|
|
Response.Write(iResult);
|
|
}
|
|
else
|
|
{
|
|
string strQuery = DoExcute(strSysDeptGid, strHandle);
|
|
Response.Write(strQuery);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
string strOutputXml = "";
|
|
strOutputXml = GetCells(iShowCount, strReadXmlType);
|
|
//输出XML字符串
|
|
Response.ContentType = "text/xml";
|
|
strOutputXml.Replace("&", "&");
|
|
Response.Write(strOutputXml);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//访问参数不正确
|
|
Response.ContentType = "text/xml";
|
|
Response.Write("-2");
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据用户提交的
|
|
/// </summary>
|
|
/// <param name="tempGid">账户GID</param>
|
|
/// <param name="tempHandle">操作类型 delete删除单条账户</param>
|
|
/// <returns>值1-删除成功;值-1 -删除操作异常 值-2 -回滚失败 值-3 -未获取相关账户信息</returns>
|
|
private string DoExcute(string tempGid, string tempHandle)
|
|
{
|
|
string strVal = "";
|
|
SysDeptDA SysDeptDA = new SysDeptDA();
|
|
if (tempHandle == "recover")
|
|
{
|
|
if (!tempGid.Trim().Equals(""))
|
|
{
|
|
string strInitSql = "SELECT GID,[NAME]=(select [NAME] from [company] where GID=sys_dept.LINKID and ISDELETED=0),DEPTNAME,FINANCESOFTCODE FROM sys_dept WHERE gid='" + tempGid.Trim() + "'";
|
|
DataSet ds = SysDeptDA.GetExcuteSql(strInitSql);
|
|
if (ds != null)
|
|
{
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
StringBuilder SysDeptBuilder = new StringBuilder();
|
|
SysDeptBuilder.Append(ds.Tables[0].Rows[0]["GID"].ToString().Trim() + ",");
|
|
SysDeptBuilder.Append(ds.Tables[0].Rows[0]["NAME"].ToString().Trim() + ",");
|
|
SysDeptBuilder.Append(ds.Tables[0].Rows[0]["DEPTNAME"].ToString().Trim() + ",");
|
|
SysDeptBuilder.Append(ds.Tables[0].Rows[0]["FINANCESOFTCODE"].ToString().Trim());
|
|
strVal = SysDeptBuilder.ToString();
|
|
}
|
|
else
|
|
{
|
|
strVal = "-3";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strVal = "-3";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
strVal = "-3";
|
|
}
|
|
}
|
|
return strVal;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取账户信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private string GetCells(int iShowCount, string readXmlType)
|
|
{
|
|
SysDeptEntity SysDeptEntity = new SysDeptEntity();
|
|
SysDeptDA SysDeptDA = new SysDeptDA();
|
|
|
|
if (!strReadXmlType.Equals("exist"))
|
|
{
|
|
//获取所有账户信息,用做Grid显示
|
|
DataTable SysDeptTable = new DataTable();
|
|
|
|
//初始化
|
|
string strInitSql = " SELECT GID,[NAME]=(select [NAME] from [company] where GID=sys_dept.LINKID and ISDELETED=0),DEPTNAME,FINANCESOFTCODE FROM sys_dept WHERE 1=1 " + strRange + " ORDER BY [NAME],DEPTNAME";
|
|
SysDeptTable = getStatusNameTable(SysDeptDA.GetExcuteSql(strInitSql).Tables[0]);
|
|
|
|
//编排字符串 xml串
|
|
StringBuilder dataBuilder = new StringBuilder();
|
|
|
|
dataBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
|
dataBuilder.Append("<rows>");
|
|
|
|
int iCount = SysDeptTable.Rows.Count;
|
|
|
|
for (int i = 0; i < iCount; i++)
|
|
{
|
|
int jCount = SysDeptTable.Columns.Count;
|
|
dataBuilder.Append("<row id=\"" + SysDeptTable.Rows[i]["GID"].ToString() + "\">");
|
|
for (int j = 1; j < jCount; j++)
|
|
{
|
|
switch (j)
|
|
{
|
|
case 1:
|
|
dataBuilder.Append("<cell>" + SysDeptTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
case 2:
|
|
dataBuilder.Append("<cell>" + SysDeptTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
case 3:
|
|
dataBuilder.Append("<cell>" + SysDeptTable.Rows[i][j].ToString() + "</cell>");
|
|
break;
|
|
}
|
|
|
|
}
|
|
dataBuilder.Append("</row>");
|
|
}
|
|
dataBuilder.Append("</rows>");
|
|
|
|
return dataBuilder.ToString();
|
|
}
|
|
else if (strReadXmlType.Equals("exist"))
|
|
{
|
|
return "1";//存在账户
|
|
}
|
|
else if (strReadXmlType.Equals("add"))
|
|
{
|
|
StringBuilder dataBuilder = new StringBuilder();
|
|
dataBuilder.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
|
|
dataBuilder.Append("<rows>");
|
|
dataBuilder.Append("<row id=\"" + Guid.NewGuid().ToString() + "\">");
|
|
//
|
|
dataBuilder.Append("<cell></cell>");
|
|
dataBuilder.Append("<cell></cell>");
|
|
dataBuilder.Append("<cell></cell>");
|
|
dataBuilder.Append("</row>");
|
|
dataBuilder.Append("</rows>");
|
|
return dataBuilder.ToString();
|
|
}
|
|
else
|
|
{
|
|
return "-3";//没有相关的账户
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 将数据集表中账户状态SysDeptStatus和应收应付类型SysDeptType的数字状态位转换成文字
|
|
/// </summary>
|
|
/// <param name="tempTable">原数据源DataTable</param>
|
|
/// <returns>返回新数据源DataTable</returns>
|
|
private DataTable getStatusNameTable(DataTable tempTable)
|
|
{
|
|
DataTable sourceTable = tempTable;
|
|
DataTable cloneTable = new DataTable();
|
|
int iSwitch = 0;
|
|
for (int i = 0; i < sourceTable.Rows.Count; i++)
|
|
{
|
|
if (iSwitch == 0)
|
|
{
|
|
for (int j = 0; j < sourceTable.Columns.Count; j++)
|
|
{
|
|
DataColumn newColumn = new DataColumn();
|
|
newColumn.ColumnName = sourceTable.Columns[j].ColumnName;
|
|
newColumn.DataType = sourceTable.Columns[j].DataType;
|
|
cloneTable.Columns.Add(newColumn);
|
|
}
|
|
iSwitch = 1;
|
|
}
|
|
DataRow cloneRow = cloneTable.NewRow();
|
|
|
|
for (int k = 0; k < sourceTable.Columns.Count; k++)
|
|
{
|
|
cloneRow[sourceTable.Columns[k].ColumnName] = sourceTable.Rows[i][k];
|
|
}
|
|
cloneTable.Rows.Add(cloneRow);
|
|
}
|
|
return cloneTable;
|
|
}
|
|
}
|
|
}
|