|
|
|
|
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.Shipping
|
|
|
|
|
{
|
|
|
|
|
public partial class CompanysSysDept : System.Web.UI.Page
|
|
|
|
|
{
|
|
|
|
|
private string recvJSON;
|
|
|
|
|
private string strSeaBSNO;
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
if (Request.QueryString["id"] != null)
|
|
|
|
|
{
|
|
|
|
|
strSeaBSNO = Request.QueryString["id"].ToString().Trim();
|
|
|
|
|
this.dvOrderNumVal.Value = Request.QueryString["id"].ToString().Trim();
|
|
|
|
|
|
|
|
|
|
if (!recvJSON.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
//应收部门保存
|
|
|
|
|
JsonSysDeptGroupEntity SysDeptGroupRecvEntity = GetPostEntity(recvJSON);
|
|
|
|
|
List<JsonSysDeptEntity> SysDeptRecvEntities = new List<JsonSysDeptEntity>();
|
|
|
|
|
|
|
|
|
|
SysDeptRecvEntities = SysDeptGroupRecvEntity.JsonSysDeptEntities;
|
|
|
|
|
|
|
|
|
|
SaveRecvSysDept(SysDeptGroupRecvEntity);
|
|
|
|
|
//更新完初始化
|
|
|
|
|
recvJSON = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Response.Write("-1");
|
|
|
|
|
Response.End();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 保存应收部门列表更改结果
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存应收部门列表更改结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempGroupEntity"></param>
|
|
|
|
|
private void SaveRecvSysDept(JsonSysDeptGroupEntity tempGroupEntity)
|
|
|
|
|
{
|
|
|
|
|
if (tempGroupEntity != null)
|
|
|
|
|
{
|
|
|
|
|
List<JsonSysDeptEntity> SysDeptEntities = new List<JsonSysDeptEntity>();
|
|
|
|
|
SysDeptEntities = tempGroupEntity.JsonSysDeptEntities;
|
|
|
|
|
SysDeptDA SysDeptDA = new SysDeptDA();
|
|
|
|
|
|
|
|
|
|
DataTable SysDeptTable = new DataTable();
|
|
|
|
|
|
|
|
|
|
string strInitSql = "";
|
|
|
|
|
if (tempGroupEntity.JsonSysDeptEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
string LINKID = tempGroupEntity.JsonSysDeptEntities[0].SysDept8.Trim();
|
|
|
|
|
strInitSql = " SELECT GID,LINKID,DEPTNO,DEPTNAME,MANAGE1,MANAGE2,FINANCESOFTCODE,REMARK,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME FROM sys_dept WHERE 1=1 AND LINKID = '" + LINKID + "'";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SysDeptTable = SysDeptDA.GetExcuteSql(strInitSql).Tables[0];
|
|
|
|
|
|
|
|
|
|
//更新操作SQL语句
|
|
|
|
|
ArrayList sqlList = new ArrayList();
|
|
|
|
|
//日志操作SQL语句
|
|
|
|
|
ArrayList logList = new ArrayList();
|
|
|
|
|
|
|
|
|
|
//日志记录
|
|
|
|
|
Logger log = Logger.Instance;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < SysDeptTable.Rows.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
foreach (JsonSysDeptEntity SysDept in SysDeptEntities)
|
|
|
|
|
{
|
|
|
|
|
if (SysDeptTable.Rows[i]["GID"].ToString().Trim().Equals(SysDept.SysDept1.Trim()))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string strSql = "";
|
|
|
|
|
string LogContent = "";
|
|
|
|
|
LogEntity logEntity = new LogEntity();
|
|
|
|
|
|
|
|
|
|
#region 更改前后信息对比
|
|
|
|
|
//部门代码
|
|
|
|
|
string strSysDeptDEPTNO = SysDept.SysDept2.Trim().ToLower().Equals("null") ? "" : SysDept.SysDept2.Trim();
|
|
|
|
|
if (!SysDeptTable.Rows[i]["DEPTNO"].ToString().Trim().Equals(strSysDeptDEPTNO))
|
|
|
|
|
{
|
|
|
|
|
strSql += String.Format(" DEPTNO = '{0}'", strSysDeptDEPTNO);
|
|
|
|
|
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "部门代码", SysDeptTable.Rows[i]["DEPTNO"].ToString().Trim(), strSysDeptDEPTNO);
|
|
|
|
|
}
|
|
|
|
|
//部门名称
|
|
|
|
|
string strSysDeptDEPTNAME = SysDept.SysDept3.Trim().ToLower().Equals("null") ? "" : SysDept.SysDept3.Trim();
|
|
|
|
|
if (!SysDeptTable.Rows[i]["DEPTNAME"].ToString().Trim().Equals(strSysDeptDEPTNAME))
|
|
|
|
|
{
|
|
|
|
|
strSql += String.Format(",DEPTNAME = '{0}'", strSysDeptDEPTNAME);
|
|
|
|
|
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "部门名称", SysDeptTable.Rows[i]["DEPTNAME"].ToString().Trim(), strSysDeptDEPTNAME);
|
|
|
|
|
}
|
|
|
|
|
//部门经理
|
|
|
|
|
string strSysDeptMANAGE1 = SysDept.SysDept4.Trim().ToLower().Equals("null") ? "" : SysDept.SysDept4.Trim();
|
|
|
|
|
if (!SysDeptTable.Rows[i]["MANAGE1"].ToString().Trim().Equals(strSysDeptMANAGE1))
|
|
|
|
|
{
|
|
|
|
|
strSql += String.Format(",MANAGE1 = '{0}'", strSysDeptMANAGE1);
|
|
|
|
|
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "部门经理", SysDeptTable.Rows[i]["MANAGE1"].ToString().Trim(), strSysDeptMANAGE1);
|
|
|
|
|
}
|
|
|
|
|
//部门副经理
|
|
|
|
|
string strSysDeptMANAGE2 = SysDept.SysDept5.Trim().ToLower().Equals("null") ? "" : SysDept.SysDept5.Trim();
|
|
|
|
|
if (!SysDeptTable.Rows[i]["MANAGE2"].ToString().Trim().Equals(strSysDeptMANAGE2))
|
|
|
|
|
{
|
|
|
|
|
strSql += String.Format(",MANAGE2 = '{0}'", strSysDeptMANAGE2);
|
|
|
|
|
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "部门副经理", SysDeptTable.Rows[i]["MANAGE2"].ToString().Trim(), strSysDeptMANAGE2);
|
|
|
|
|
}
|
|
|
|
|
//财务软件代码
|
|
|
|
|
string strSysDeptFINANCESOFTCODE = SysDept.SysDept6.Trim().ToLower().Equals("null") ? "" : SysDept.SysDept6.Trim();
|
|
|
|
|
if (!SysDeptTable.Rows[i]["FINANCESOFTCODE"].ToString().Trim().Equals(strSysDeptFINANCESOFTCODE))
|
|
|
|
|
{
|
|
|
|
|
strSql += String.Format(",FINANCESOFTCODE = '{0}'", strSysDeptFINANCESOFTCODE);
|
|
|
|
|
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "财务软件代码", SysDeptTable.Rows[i]["FINANCESOFTCODE"].ToString().Trim(), strSysDeptFINANCESOFTCODE);
|
|
|
|
|
}
|
|
|
|
|
//备注
|
|
|
|
|
string strSysDeptREMARK = SysDept.SysDept7.Trim().ToLower().Equals("null") ? "" : SysDept.SysDept7.Trim();
|
|
|
|
|
if (!SysDeptTable.Rows[i]["REMARK"].ToString().Trim().Equals(strSysDeptREMARK))
|
|
|
|
|
{
|
|
|
|
|
strSql += String.Format(",REMARK = '{0}'", strSysDeptREMARK);
|
|
|
|
|
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "备注", SysDeptTable.Rows[i]["REMARK"].ToString().Trim(), strSysDeptREMARK);
|
|
|
|
|
}
|
|
|
|
|
//最后一次更新操作人GID
|
|
|
|
|
string strSysDeptMODIFIEDUSER = strUserID.Trim().Equals("") ? "" : strUserID.Trim();
|
|
|
|
|
if (!SysDeptTable.Rows[i]["MODIFIEDUSER"].ToString().Trim().Equals(strSysDeptMODIFIEDUSER))
|
|
|
|
|
{
|
|
|
|
|
strSql += String.Format(",MODIFIEDUSER = '{0}'", strSysDeptMODIFIEDUSER);
|
|
|
|
|
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "最后一次更新操作人GID", SysDeptTable.Rows[i]["MODIFIEDUSER"].ToString().Trim(), strSysDeptMODIFIEDUSER);
|
|
|
|
|
}
|
|
|
|
|
//最后一次更新操作时间
|
|
|
|
|
string strSysDeptMODIFIEDTIME = "GETDATE()";
|
|
|
|
|
if (!SysDeptTable.Rows[i]["MODIFIEDTIME"].ToString().Trim().Equals(strSysDeptMODIFIEDTIME))
|
|
|
|
|
{
|
|
|
|
|
strSql += String.Format(",MODIFIEDTIME = {0}", strSysDeptMODIFIEDTIME);
|
|
|
|
|
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "最后一次更新操作时间", SysDeptTable.Rows[i]["MODIFIEDTIME"].ToString().Trim(), strSysDeptMODIFIEDTIME);
|
|
|
|
|
}
|
|
|
|
|
#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}'", "sys_dept", strSql, SysDept.SysDept1.Trim());
|
|
|
|
|
sqlList.Add(strUpdateSql);
|
|
|
|
|
logList.Add(String.Format("更新部门标识 {0} {1}", SysDept.SysDept1.Trim(), LogContent));
|
|
|
|
|
}
|
|
|
|
|
SysDeptEntities.Remove(SysDept);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (sqlList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int iResult = SysDeptDA.UpdateSysDeptFromGrid(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 (SysDeptEntities.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//插入新的应收费用信息
|
|
|
|
|
InsertSysDept(SysDeptEntities, 1);
|
|
|
|
|
}
|
|
|
|
|
recvJSON = "";
|
|
|
|
|
this.recvContainer.Value = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
recvJSON = "";
|
|
|
|
|
this.recvContainer.Value = "";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 插入部门信息记录
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 插入部门信息记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="SysDeptEntities">需要插入部门表的部门实体类</param>
|
|
|
|
|
/// <param name="iType">如果iType值为1则记录部门类型为收/否则记录为付</param>
|
|
|
|
|
public void InsertSysDept(List<JsonSysDeptEntity> SysDeptEntities, int iType)
|
|
|
|
|
{
|
|
|
|
|
ArrayList sqlInsertList = new ArrayList();
|
|
|
|
|
SysDeptDA SysDeptDA = new SysDeptDA();
|
|
|
|
|
|
|
|
|
|
foreach (JsonSysDeptEntity SysDept in SysDeptEntities)
|
|
|
|
|
{
|
|
|
|
|
string strItemSql = "";
|
|
|
|
|
string strValueSql = "";
|
|
|
|
|
string strInsertSql = "";
|
|
|
|
|
|
|
|
|
|
//GID
|
|
|
|
|
strItemSql += "GID";
|
|
|
|
|
strValueSql += String.Format("'{0}'", SysDept.SysDept1.Trim().Equals("null") ? "" : SysDept.SysDept1.Trim());
|
|
|
|
|
//部门代码
|
|
|
|
|
strItemSql += ",DEPTNO";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", SysDept.SysDept2.Trim().Equals("null") ? "" : SysDept.SysDept2.Trim());
|
|
|
|
|
//部门名称
|
|
|
|
|
strItemSql += ",DEPTNAME";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", SysDept.SysDept3.Trim().Equals("null") ? "" : SysDept.SysDept3.Trim());
|
|
|
|
|
//部门经理
|
|
|
|
|
strItemSql += ",MANAGE1";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", SysDept.SysDept4.Trim().Equals("null") ? "" : SysDept.SysDept4.Trim());
|
|
|
|
|
//部门副经理
|
|
|
|
|
strItemSql += ",MANAGE2";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", SysDept.SysDept5.Trim().Equals("null") ? "" : SysDept.SysDept5.Trim());
|
|
|
|
|
//财务软件代码
|
|
|
|
|
strItemSql += ",FINANCESOFTCODE";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", SysDept.SysDept6.Trim().Equals("null") ? "" : SysDept.SysDept6.Trim());
|
|
|
|
|
//备注
|
|
|
|
|
strItemSql += ",REMARK";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", SysDept.SysDept7.Trim().Equals("null") ? "" : SysDept.SysDept7.Trim());
|
|
|
|
|
//公司关联id
|
|
|
|
|
strItemSql += ",LINKID";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", SysDept.SysDept8);
|
|
|
|
|
//创建人GID
|
|
|
|
|
strItemSql += ",CREATEUSER";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", strUserID.Trim());
|
|
|
|
|
//最后一次更新操作人GID
|
|
|
|
|
strItemSql += ",MODIFIEDUSER";
|
|
|
|
|
strValueSql += String.Format(",'{0}'", strUserID.Trim());
|
|
|
|
|
//
|
|
|
|
|
if (!strItemSql.Trim().Equals("") && !strValueSql.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
if (strItemSql.Trim().StartsWith(","))
|
|
|
|
|
{
|
|
|
|
|
strItemSql = strItemSql.Trim().Substring(1);
|
|
|
|
|
}
|
|
|
|
|
if (strValueSql.Trim().StartsWith(","))
|
|
|
|
|
{
|
|
|
|
|
strValueSql = strValueSql.Trim().Substring(1);
|
|
|
|
|
}
|
|
|
|
|
strInsertSql = String.Format("INSERT INTO {0} ({1}) VALUES({2})", "sys_dept", strItemSql, strValueSql);
|
|
|
|
|
sqlInsertList.Add(strInsertSql);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (sqlInsertList.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int iResult = SysDeptDA.InsertSysDeptFromGrid(sqlInsertList);
|
|
|
|
|
//为1表示更新成功
|
|
|
|
|
//为-1有异常,更新失败
|
|
|
|
|
//为-2更新异常,事务已回滚成功
|
|
|
|
|
//更新完成后,记录日志
|
|
|
|
|
//if (iResult == 1)
|
|
|
|
|
//{
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取部门客户保存的部门信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取部门客户保存的部门信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempValue"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public JsonSysDeptGroupEntity GetPostEntity(string tempValue)
|
|
|
|
|
{
|
|
|
|
|
JsonSysDeptGroupEntity SysDeptGroupEntity = (JsonSysDeptGroupEntity)JSON.Instance.ToObject(tempValue);
|
|
|
|
|
return SysDeptGroupEntity;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|