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.

361 lines
19 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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 ATCwAccitemsSet : 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 = "";
}
//
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(""))
{
//应收账户保存
JsonATCwAccitemsSetGroupEntity ATCwAccitemsSetGroupRecvEntity = GetPostEntity(recvJSON);
List<JsonATCwAccitemsSetEntity> ATCwAccitemsSetRecvEntities = new List<JsonATCwAccitemsSetEntity>();
ATCwAccitemsSetRecvEntities = ATCwAccitemsSetGroupRecvEntity.JsonATCwAccitemsSetEntities;
SaveRecvATCwAccitemsSet(ATCwAccitemsSetGroupRecvEntity);
//更新完初始化
recvJSON = "";
}
}
#region 保存应收账户列表更改结果
/// <summary>
/// 保存应收账户列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SaveRecvATCwAccitemsSet(JsonATCwAccitemsSetGroupEntity tempGroupEntity)
{
if (tempGroupEntity != null)
{
List<JsonATCwAccitemsSetEntity> ATCwAccitemsSetEntities = new List<JsonATCwAccitemsSetEntity>();
ATCwAccitemsSetEntities = tempGroupEntity.JsonATCwAccitemsSetEntities;
CwAccitemsSetDA ATCwAccitemsSetDA = new CwAccitemsSetDA();
DataTable ATCwAccitemsSetTable = new DataTable();
string strInitSql = "";
if (tempGroupEntity.JsonATCwAccitemsSetEntities.Count > 0)
{
strInitSql = " SELECT GID,ACCID,ACCNAME,DC,ISFCY,ISDEPTACC,ISEMPLACC,ISCORPACC,ISITEMACC,REMARKS,DETAILED FROM cw_accitems order by ACCID";
}
else
{
return;
}
ATCwAccitemsSetTable = ATCwAccitemsSetDA.GetExcuteSql(strInitSql).Tables[0];
//更新操作SQL语句
ArrayList sqlList = new ArrayList();
//日志操作SQL语句
ArrayList logList = new ArrayList();
//日志记录
Logger log = Logger.Instance;
for (int i = 0; i < ATCwAccitemsSetTable.Rows.Count; i++)
{
foreach (JsonATCwAccitemsSetEntity ATCwAccitemsSet in ATCwAccitemsSetEntities)
{
if (ATCwAccitemsSetTable.Rows[i]["GID"].ToString().Trim().Equals(ATCwAccitemsSet.ATCwAccitemsSet1.Trim()))//惟一编号
{
string strSql = "";
string LogContent = "";
LogEntity logEntity = new LogEntity();
#region 更改前后信息对比
//科目代码
string strACCID = ATCwAccitemsSet.ATCwAccitemsSet2.Trim().ToLower().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet2.Trim();
if (!ATCwAccitemsSetTable.Rows[i]["ACCID"].ToString().Trim().Equals(strACCID))
{
strSql += String.Format(",ACCID = '{0}'", strACCID);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "科目代码", ATCwAccitemsSetTable.Rows[i]["ACCID"].ToString().Trim(), strACCID);
}
//科目名称
string strACCNAME = ATCwAccitemsSet.ATCwAccitemsSet3.Trim().ToLower().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet3.Trim();
if (!ATCwAccitemsSetTable.Rows[i]["ACCNAME"].ToString().Trim().Equals(strACCNAME))
{
strSql += String.Format(",ACCNAME = '{0}'", strACCNAME);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "科目名称", ATCwAccitemsSetTable.Rows[i]["ACCNAME"].ToString().Trim(), strACCNAME);
}
//借贷方向
string strDC = ATCwAccitemsSet.ATCwAccitemsSet4.Trim().ToLower().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet4.Trim();
if (!ATCwAccitemsSetTable.Rows[i]["DC"].ToString().Trim().Equals(strDC))
{
strSql += String.Format(",DC = '{0}'", strDC);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "借贷方向", ATCwAccitemsSetTable.Rows[i]["DC"].ToString().Trim(), strDC);
}
//是否核算外币
string strISFCY = ATCwAccitemsSet.ATCwAccitemsSet5.ToString().Trim().ToLower().Equals("null") ? "False" : ATCwAccitemsSet.ATCwAccitemsSet5.ToString().Trim();
if (!ATCwAccitemsSetTable.Rows[i]["ISFCY"].ToString().Trim().Equals(strISFCY))
{
strSql += String.Format(",ISFCY = '{0}'", strISFCY);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "是否核算外币", ATCwAccitemsSetTable.Rows[i]["ISFCY"].ToString().Trim(), strISFCY);
}
//是否核算部门
string strISDEPTACC = ATCwAccitemsSet.ATCwAccitemsSet6.ToString().Trim().Equals("null") ? "False" : ATCwAccitemsSet.ATCwAccitemsSet6.ToString().Trim();
if (!ATCwAccitemsSetTable.Rows[i]["ISDEPTACC"].ToString().Trim().Equals(strISDEPTACC))
{
strSql += String.Format(",ISDEPTACC = '{0}'", Decimal.Parse(strISDEPTACC));
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "是否核算部门", ATCwAccitemsSetTable.Rows[i]["ISDEPTACC"].ToString().Trim(), strISDEPTACC);
}
//是否核算人员
string strISEMPLACC = ATCwAccitemsSet.ATCwAccitemsSet7.ToString().Trim().ToLower().Equals("null") ? "False" : ATCwAccitemsSet.ATCwAccitemsSet7.ToString().Trim();
if (!ATCwAccitemsSetTable.Rows[i]["ISEMPLACC"].ToString().Trim().Equals(strISEMPLACC))
{
strSql += String.Format(",ISEMPLACC = '{0}'", strISEMPLACC);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "是否核算人员", ATCwAccitemsSetTable.Rows[i]["ISEMPLACC"].ToString().Trim(), strISEMPLACC);
}
//是否算客户门
string strISCORPACC = ATCwAccitemsSet.ATCwAccitemsSet8.ToString().Trim().ToLower().Equals("null") ? "False" : ATCwAccitemsSet.ATCwAccitemsSet8.ToString().Trim();
if (!ATCwAccitemsSetTable.Rows[i]["ISCORPACC"].ToString().Trim().Equals(strISCORPACC))
{
strSql += String.Format(",ISCORPACC = '{0}'", strISCORPACC);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "是否算客户门", ATCwAccitemsSetTable.Rows[i]["ISCORPACC"].ToString().Trim(), strISCORPACC);
}
//是否核算项目
string strISITEMACC = ATCwAccitemsSet.ATCwAccitemsSet9.ToString().Trim().ToLower().Equals("null") ? "False" : ATCwAccitemsSet.ATCwAccitemsSet9.ToString().Trim();
if (!ATCwAccitemsSetTable.Rows[i]["ISITEMACC"].ToString().Trim().Equals(strISITEMACC))
{
strSql += String.Format(",ISITEMACC = '{0}'", strISITEMACC);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "是否核算项目", ATCwAccitemsSetTable.Rows[i]["ISITEMACC"].ToString().Trim(), strISITEMACC);
}
//备注
string strREMARKS = ATCwAccitemsSet.ATCwAccitemsSet10.Trim().ToLower().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet10.Trim();
if (!ATCwAccitemsSetTable.Rows[i]["REMARKS"].ToString().Trim().Equals(strREMARKS))
{
strSql += String.Format(",REMARKS = '{0}'", strREMARKS);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "备注", ATCwAccitemsSetTable.Rows[i]["REMARKS"].ToString().Trim(), strREMARKS);
}
#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}'", "cw_accitems", strSql, ATCwAccitemsSet.ATCwAccitemsSet1.Trim());
sqlList.Add(strUpdateSql);
logList.Add(String.Format("更新账户标识 {0} {1}", ATCwAccitemsSet.ATCwAccitemsSet1.Trim(), LogContent));
}
ATCwAccitemsSetEntities.Remove(ATCwAccitemsSet);
break;
}
}
}
if (sqlList.Count > 0)
{
int iResult = ATCwAccitemsSetDA.UpdateATCwAccitemsSetFromGrid(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
}
}
//如果遍历完所有财务其他常用科目表数据,没有相对应的财务其他常用科目信息,则将剩余的财务其他常用科目信息插入到财务其他常用科目表中
if (ATCwAccitemsSetEntities.Count > 0)
{
//插入新的应收财务其他常用科目信息
InsertATCwAccitemsSet(ATCwAccitemsSetEntities, 1);
}
recvJSON = "";
this.recvContainer.Value = "";
}
else
{
recvJSON = "";
this.recvContainer.Value = "";
return;
}
}
#endregion
#region 插入账户信息记录
/// <summary>
/// 插入账户信息记录
/// </summary>
/// <param name="ATCwAccitemsSetEntities">需要插入账户表的账户实体类</param>
/// <param name="iType">如果iType值为1则记录账户类型为收/否则记录为付</param>
public void InsertATCwAccitemsSet(List<JsonATCwAccitemsSetEntity> ATCwAccitemsSetEntities, int iType)
{
ArrayList sqlInsertList = new ArrayList();
CwAccitemsSetDA ATCwAccitemsSetDA = new CwAccitemsSetDA();
ATCwAccitemsSetEntity ATCwAccitemsSetEntity = new ATCwAccitemsSetEntity();
ATCwAccitemsSetEntity ATCwAccitemsSetEntityGID = new ATCwAccitemsSetEntity();
string alt = "";
foreach (JsonATCwAccitemsSetEntity ATCwAccitemsSet in ATCwAccitemsSetEntities)
{
ATCwAccitemsSetEntity.GID = ATCwAccitemsSet.ATCwAccitemsSet1.Trim().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet1.Trim();
ATCwAccitemsSetEntity.ACCID = ATCwAccitemsSet.ATCwAccitemsSet2.Trim().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet2.Trim();
ATCwAccitemsSetEntity.ACCNAME = ATCwAccitemsSet.ATCwAccitemsSet3.Trim().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet3.Trim();
ATCwAccitemsSetEntity.DC = ATCwAccitemsSet.ATCwAccitemsSet4.Trim().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet4.Trim();
ATCwAccitemsSetEntity.ISFCY = ATCwAccitemsSet.ATCwAccitemsSet5.ToString().Trim().Equals("null") ? false : ATCwAccitemsSet.ATCwAccitemsSet5;
ATCwAccitemsSetEntity.ISDEPTACC = ATCwAccitemsSet.ATCwAccitemsSet6.ToString().Trim().Equals("null") ? false : ATCwAccitemsSet.ATCwAccitemsSet6;
ATCwAccitemsSetEntity.ISEMPLACC = ATCwAccitemsSet.ATCwAccitemsSet7.ToString().Trim().Equals("null") ? false : ATCwAccitemsSet.ATCwAccitemsSet7;
ATCwAccitemsSetEntity.ISCORPACC = ATCwAccitemsSet.ATCwAccitemsSet8.ToString().Trim().Equals("null") ? false : ATCwAccitemsSet.ATCwAccitemsSet8;
ATCwAccitemsSetEntity.ISITEMACC = ATCwAccitemsSet.ATCwAccitemsSet9.ToString().Trim().Equals("null") ? false : ATCwAccitemsSet.ATCwAccitemsSet9;
ATCwAccitemsSetEntity.REMARKS = ATCwAccitemsSet.ATCwAccitemsSet10.Trim().Equals("null") ? "" : ATCwAccitemsSet.ATCwAccitemsSet10.Trim();
ATCwAccitemsSetEntity.DETAILED=true;
//
ATCwAccitemsSetEntityGID = ATCwAccitemsSetDA.GetModel(ATCwAccitemsSetEntity.GID);
if (ATCwAccitemsSetEntityGID == null || ATCwAccitemsSetEntityGID.GID == null)
{
int iResult = ATCwAccitemsSetDA.Add(ATCwAccitemsSetEntity);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
if (iResult == 1)
{
}
}
else
{
alt += ATCwAccitemsSetEntity.GID + ",";
}
}
//
//if (alt != "")
//{
// alt=alt.Trim().Substring(0,alt.Trim().Length-1);
// Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('"+alt+"')数据重复,不允许插入!);</script>");
//}
}
#endregion
#region 获取账户客户保存的账户信息
/// <summary>
/// 获取账户客户保存的账户信息
/// </summary>
/// <param name="tempValue"></param>
/// <returns></returns>
public JsonATCwAccitemsSetGroupEntity GetPostEntity(string tempValue)
{
JsonATCwAccitemsSetGroupEntity ATCwAccitemsSetGroupEntity = (JsonATCwAccitemsSetGroupEntity)JSON.Instance.ToObject(tempValue);
return ATCwAccitemsSetGroupEntity;
}
#endregion
}
}