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/ParameterSet/ATClientSet.aspx.cs

259 lines
11 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 DSWeb.Models;
using System.Collections.Generic;
using JsonHelper;
using DSWeb.EntityDA;
using DSWeb.Log;
namespace DSWeb.ParameterSet
{
public partial class CRMClient : System.Web.UI.Page
{
private string recvJSON;
RangeDA RangeDA = new RangeDA();
T_ALL_DA T_ALL_DA = new T_ALL_DA();
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 = "";
}
if (Request.QueryString["ISFINANCESOFTCODE"] != null)
{
this.ISFINANCESOFTCODE.Value = Request.QueryString["ISFINANCESOFTCODE"].ToString().Trim();
}
else
{
this.ISFINANCESOFTCODE.Value = "";
}
//
recvJSON = "";
recvJSON = this.recvContainer.Value.Trim();
/*
//权限可视范围
this.hdRangeV.Value = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modOrderManagement");
this.hdRangeO.Value = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modOrderManagement");
string alt = "";
if (this.hdRangeV.Value.Trim() != this.hdRangeO.Value.Trim())
{
if (this.hdRangeO.Value.Trim().Equals("0"))//全部
{
}
else if (this.hdRangeO.Value.Trim().Equals("1"))//分公司
{
alt = RangeDA.GetOrderManagementCompany(strUserID.Trim(), strSeaBSNO);
if (alt == "")
{
divadd.Disabled = true;
divsave.Disabled = true;
divdel.Disabled = true;
divrollback.Disabled = true;
mygrid_container_recv.Disabled = true;
}
}
else if (this.hdRangeO.Value.Trim().Equals("2"))//部门
{
alt = RangeDA.GetOrderManagementDEPT(strUserID.Trim(), strSeaBSNO);
if (alt == "")
{
divadd.Disabled = true;
divsave.Disabled = true;
divdel.Disabled = true;
divrollback.Disabled = true;
mygrid_container_recv.Disabled = true;
}
}
else if (this.hdRangeO.Value.Trim().Equals("3"))//个人
{
alt = RangeDA.GetOrderManagementPerson(strUserID.Trim(), strSeaBSNO);
if (alt == "")
{
divadd.Disabled = true;
divsave.Disabled = true;
divdel.Disabled = true;
divrollback.Disabled = true;
mygrid_container_recv.Disabled = true;
}
}
else if (this.hdRangeO.Value.Trim().Equals("4"))//无
{
divadd.Disabled = true;
divsave.Disabled = true;
divdel.Disabled = true;
divrollback.Disabled = true;
mygrid_container_recv.Disabled = true;
}
}
*/
//
if (!IsPostBack)
{
}
//
if (!recvJSON.Trim().Equals(""))
{
//应收账户保存
JsonCRMClientGroupEntity CRMClientGroupRecvEntity = GetPostEntity(recvJSON);
List<JsonCRMClientEntity> CRMClientRecvEntities = new List<JsonCRMClientEntity>();
CRMClientRecvEntities = CRMClientGroupRecvEntity.JsonCRMClientEntities;
SaveRecvCRMClient(CRMClientGroupRecvEntity);
//更新完初始化
recvJSON = "";
}
}
#region 保存应收账户列表更改结果
/// <summary>
/// 保存应收账户列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SaveRecvCRMClient(JsonCRMClientGroupEntity tempGroupEntity)
{
if (tempGroupEntity != null)
{
List<JsonCRMClientEntity> CRMClientEntities = new List<JsonCRMClientEntity>();
CRMClientEntities = tempGroupEntity.JsonCRMClientEntities;
CRMClientDA CRMClientDA = new CRMClientDA();
DataTable CRMClientTable = new DataTable();
string strInitSql = "";
if (tempGroupEntity.JsonCRMClientEntities.Count > 0)
{
strInitSql = " SELECT GID,CODENAME,SHORTNAME,DESCRIPTION,FARCODE,FAPCODE FROM info_client order by SHORTNAME";
}
else
{
return;
}
CRMClientTable = CRMClientDA.GetExcuteSql(strInitSql).Tables[0];
//更新操作SQL语句
ArrayList sqlList = new ArrayList();
//日志操作SQL语句
ArrayList logList = new ArrayList();
//日志记录
Logger log = Logger.Instance;
for (int i = 0; i < CRMClientTable.Rows.Count; i++)
{
foreach (JsonCRMClientEntity CRMClient in CRMClientEntities)
{
if (CRMClientTable.Rows[i]["GID"].ToString().Trim().Equals(CRMClient.CRMClient1.Trim()))//惟一编号
{
string strSql = "";
string LogContent = "";
LogEntity logEntity = new LogEntity();
#region 更改前后信息对比
//财务应收帐款代码
string strFARCODE = CRMClient.CRMClient5.Trim().ToLower().Equals("null") ? "" : CRMClient.CRMClient5.Trim();
if (!CRMClientTable.Rows[i]["FARCODE"].ToString().Trim().Equals(strFARCODE))
{
strSql += String.Format(",FARCODE = '{0}'", strFARCODE);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "财务应收帐款代码", CRMClientTable.Rows[i]["FARCODE"].ToString().Trim(), strFARCODE);
}
//财务应付帐款代码
string strFAPCODE = CRMClient.CRMClient6.Trim().ToLower().Equals("null") ? "" : CRMClient.CRMClient6.Trim();
if (!CRMClientTable.Rows[i]["FAPCODE"].ToString().Trim().Equals(strFAPCODE))
{
strSql += String.Format(",FAPCODE = '{0}'", strFAPCODE);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "财务应付帐款代码", CRMClientTable.Rows[i]["FAPCODE"].ToString().Trim(), strFAPCODE);
}
#endregion
//如果有字段内容更新则执行更新操作
if (LogContent.Trim().Length > 1)
{
if (strSql.Trim().StartsWith(","))
{
strSql = strSql.Trim().Substring(1);
}
string strUpdateSql = String.Format("UPDATE {0} SET {1} WHERE GID = '{2}'", "info_client", strSql, CRMClient.CRMClient1.Trim());
sqlList.Add(strUpdateSql);
logList.Add(String.Format("更新账户标识 {0} {1}", CRMClient.CRMClient1.Trim(), LogContent));
}
CRMClientEntities.Remove(CRMClient);
break;
}
}
}
if (sqlList.Count > 0)
{
int iResult = CRMClientDA.UpdateCRMClientFromGrid(sqlList);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
if (iResult == 1)
{
#region 日志记录操作
// INSERT-"INSERT INTO {0} ({1}) VALUES ({2})" @{0}-所要插入记录的表;{1}记录字段值;{2}-记录新值@
//if (logList.Count > 0)
//{
// for (int i = 0; i < logList.Count; i++)
// {
// LogEntity logEntity = new LogEntity();
// logEntity.GID = Guid.NewGuid().ToString();
// logEntity.Name = "更新账户信息列表";
// logEntity.LogType = "UPDATE 更新操作";
// logEntity.CreateUserID = strUserID.Trim();//测试使用数据,正式发布请删除
// logEntity.LogContent = logList[i].ToString();
// log.WriteLog(logEntity);
// }
//}
#endregion
}
}
recvJSON = "";
this.recvContainer.Value = "";
}
else
{
recvJSON = "";
this.recvContainer.Value = "";
return;
}
}
#endregion
#region 获取账户客户保存的账户信息
/// <summary>
/// 获取账户客户保存的账户信息
/// </summary>
/// <param name="tempValue"></param>
/// <returns></returns>
public JsonCRMClientGroupEntity GetPostEntity(string tempValue)
{
JsonCRMClientGroupEntity CRMClientGroupEntity = (JsonCRMClientGroupEntity)JSON.Instance.ToObject(tempValue);
return CRMClientGroupEntity;
}
#endregion
}
}