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.

397 lines
20 KiB
C#

11 months 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 CodeCtnSet : 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)
{
this.hd_comboCTN1.Value = "";
this.hd_comboCTN2.Value = "";
this.hd_comboCTN3.Value = "";
this.hd_comboCTN4.Value = "";
this.hd_comboCTN5.Value = "";
this.hd_comboCTN6.Value = "";
this.hd_comboCTN7.Value = "";
this.hd_comboCTN8.Value = "";
this.hd_comboCTN9.Value = "";
this.hd_comboCTN10.Value = "";
DataSet ds = T_ALL_DA.GetAllSQL("SELECT * FROM code_ctn_disp");
if (ds != null)
{
if(ds.Tables[0].Rows.Count>0)
{
this.hd_comboCTN1.Value = ds.Tables[0].Rows[0]["CNT1"].ToString().Trim();
this.hd_comboCTN2.Value = ds.Tables[0].Rows[0]["CNT2"].ToString().Trim();
this.hd_comboCTN3.Value = ds.Tables[0].Rows[0]["CNT3"].ToString().Trim();
this.hd_comboCTN4.Value = ds.Tables[0].Rows[0]["CNT4"].ToString().Trim();
this.hd_comboCTN5.Value = ds.Tables[0].Rows[0]["CNT5"].ToString().Trim();
this.hd_comboCTN6.Value = ds.Tables[0].Rows[0]["CNT6"].ToString().Trim();
this.hd_comboCTN7.Value = ds.Tables[0].Rows[0]["CNT7"].ToString().Trim();
this.hd_comboCTN8.Value = ds.Tables[0].Rows[0]["CNT8"].ToString().Trim();
this.hd_comboCTN9.Value = ds.Tables[0].Rows[0]["CNT9"].ToString().Trim();
this.hd_comboCTN10.Value = ds.Tables[0].Rows[0]["CNT10"].ToString().Trim();
}
}
}
if (this.hdCTN.Value == "1")
{
bool bl = T_ALL_DA.GetExecuteSqlCommand("update code_ctn_disp set CNT1='" + this.hd_comboCTN1.Value + "',CNT2='" + this.hd_comboCTN2.Value + "',CNT3='" + this.hd_comboCTN3.Value + "',CNT4='" + this.hd_comboCTN4.Value + "',CNT5='" + this.hd_comboCTN5.Value + "',CNT6='" + this.hd_comboCTN6.Value + "',CNT7='" + this.hd_comboCTN7.Value + "',CNT8='" + this.hd_comboCTN8.Value + "',CNT9='" + this.hd_comboCTN9.Value + "',CNT10='" + this.hd_comboCTN10.Value + "'");
if (bl)
{
this.hdCTN.Value = "0";
//Response.Write("<script>alert('删除成功!');history.back();</script>");
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>freshCTN1();</script>");
return;
}
else
{
this.hdCTN.Value = "0";
Response.Write("<script>alert('删除失败!');history.back();</script>");
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>freshCTN1();</script>");
return;
}
}
//
if (!recvJSON.Trim().Equals(""))
{
//应收账户保存
JsonCodeCtnSetGroupEntity CodeCtnSetGroupRecvEntity = GetPostEntity(recvJSON);
List<JsonCodeCtnSetEntity> CodeCtnSetRecvEntities = new List<JsonCodeCtnSetEntity>();
CodeCtnSetRecvEntities = CodeCtnSetGroupRecvEntity.JsonCodeCtnSetEntities;
SaveRecvCodeCtnSet(CodeCtnSetGroupRecvEntity);
//更新完初始化
recvJSON = "";
}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>freshCTN1();</script>");
}
#region 保存应收账户列表更改结果
/// <summary>
/// 保存应收账户列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SaveRecvCodeCtnSet(JsonCodeCtnSetGroupEntity tempGroupEntity)
{
if (tempGroupEntity != null)
{
List<JsonCodeCtnSetEntity> CodeCtnSetEntities = new List<JsonCodeCtnSetEntity>();
CodeCtnSetEntities = tempGroupEntity.JsonCodeCtnSetEntities;
CodeCtnSetDA CodeCtnSetDA = new CodeCtnSetDA();
DataTable CodeCtnSetTable = new DataTable();
string strInitSql = "";
if (tempGroupEntity.JsonCodeCtnSetEntities.Count > 0)
{
strInitSql = " SELECT CTNID,CTNSIZE,CTNTYPE,CTN,EDICODE,CTNWEIGHT,EEXPLAIN,CEXPLAIN FROM code_ctn order by CTNTYPE";
}
else
{
return;
}
CodeCtnSetTable = CodeCtnSetDA.GetExcuteSql(strInitSql).Tables[0];
//更新操作SQL语句
ArrayList sqlList = new ArrayList();
//日志操作SQL语句
ArrayList logList = new ArrayList();
//日志记录
Logger log = Logger.Instance;
for (int i = 0; i < CodeCtnSetTable.Rows.Count; i++)
{
foreach (JsonCodeCtnSetEntity CodeCtnSet in CodeCtnSetEntities)
{
if (CodeCtnSetTable.Rows[i]["CTNID"].ToString().Trim().Equals(CodeCtnSet.CodeCtnSet1.Trim()))//惟一编号
{
string strSql = "";
string LogContent = "";
LogEntity logEntity = new LogEntity();
#region 更改前后信息对比
//集装箱尺寸
string strCTNSIZE = CodeCtnSet.CodeCtnSet2.Trim().ToLower().Equals("null") ? "" : CodeCtnSet.CodeCtnSet2.Trim();
if (!CodeCtnSetTable.Rows[i]["CTNSIZE"].ToString().Trim().Equals(strCTNSIZE))
{
strSql += String.Format(" CTNSIZE = '{0}'", strCTNSIZE);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "集装箱尺寸", CodeCtnSetTable.Rows[i]["CTNSIZE"].ToString().Trim(), strCTNSIZE);
}
//集装箱类型
string strCTNTYPE = CodeCtnSet.CodeCtnSet3.Trim().ToLower().Equals("null") ? "" : CodeCtnSet.CodeCtnSet3.Trim();
if (!CodeCtnSetTable.Rows[i]["CTNTYPE"].ToString().Trim().Equals(strCTNTYPE))
{
strSql += String.Format(" CTNTYPE = '{0}'", strCTNTYPE);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "集装箱类型", CodeCtnSetTable.Rows[i]["CTNTYPE"].ToString().Trim(), strCTNTYPE);
}
//表现形式
string strCTN = CodeCtnSet.CodeCtnSet4.Trim().ToLower().Equals("null") ? "" : CodeCtnSet.CodeCtnSet4.Trim();
if (!CodeCtnSetTable.Rows[i]["CTN"].ToString().Trim().Equals(strCTN))
{
strSql += String.Format(",CTN = '{0}'", strCTN);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "表现形式", CodeCtnSetTable.Rows[i]["CTN"].ToString().Trim(), strCTN);
}
//EDI代码
string strEDICODE = CodeCtnSet.CodeCtnSet5.Trim().ToLower().Equals("null") ? "" : CodeCtnSet.CodeCtnSet5.Trim();
if (!CodeCtnSetTable.Rows[i]["EDICODE"].ToString().Trim().Equals(strEDICODE))
{
strSql += String.Format(",EDICODE = '{0}'", strEDICODE);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "EDI代码", CodeCtnSetTable.Rows[i]["EDICODE"].ToString().Trim(), strEDICODE);
}
//箱皮重
string strCTNWEIGHT = CodeCtnSet.CodeCtnSet6.ToString().Trim().Equals("null") ? "" : CodeCtnSet.CodeCtnSet6.ToString().Trim();
if (!CodeCtnSetTable.Rows[i]["CTNWEIGHT"].ToString().Trim().Equals(strCTNWEIGHT))
{
strSql += String.Format(",CTNWEIGHT = '{0}'", Decimal.Parse(strCTNWEIGHT));
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "箱皮重", CodeCtnSetTable.Rows[i]["CTNWEIGHT"].ToString().Trim(), strCTNWEIGHT);
}
//英文说明
string strEEXPLAIN = CodeCtnSet.CodeCtnSet7.Trim().ToLower().Equals("null") ? "" : CodeCtnSet.CodeCtnSet7.Trim();
if (!CodeCtnSetTable.Rows[i]["EEXPLAIN"].ToString().Trim().Equals(strEEXPLAIN))
{
strSql += String.Format(",EEXPLAIN = '{0}'", strEEXPLAIN);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "英文说明", CodeCtnSetTable.Rows[i]["EEXPLAIN"].ToString().Trim(), strEEXPLAIN);
}
//中文说明
string strCEXPLAIN = CodeCtnSet.CodeCtnSet8.Trim().ToLower().Equals("null") ? "" : CodeCtnSet.CodeCtnSet8.Trim();
if (!CodeCtnSetTable.Rows[i]["CEXPLAIN"].ToString().Trim().Equals(strCEXPLAIN))
{
strSql += String.Format(",CEXPLAIN = '{0}'", strCEXPLAIN);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "中文说明", CodeCtnSetTable.Rows[i]["CEXPLAIN"].ToString().Trim(), strCEXPLAIN);
}
#endregion
//如果有字段内容更新则执行更新操作
if (LogContent.Trim().Length > 1)
{
if (strSql.Trim().StartsWith(","))
{
strSql = strSql.Trim().Substring(1);
}
string strUpdateSql = String.Format("UPDATE {0} SET {1} WHERE CTNID = '{2}'", "code_ctn", strSql, CodeCtnSet.CodeCtnSet1.Trim());
sqlList.Add(strUpdateSql);
logList.Add(String.Format("更新账户标识 {0} {1}", CodeCtnSet.CodeCtnSet1.Trim(), LogContent));
}
CodeCtnSetEntities.Remove(CodeCtnSet);
break;
}
}
}
if (sqlList.Count > 0)
{
int iResult = CodeCtnSetDA.UpdateCodeCtnSetFromGrid(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 (CodeCtnSetEntities.Count > 0)
{
//插入新的应收集装箱信息
InsertCodeCtnSet(CodeCtnSetEntities, 1);
}
recvJSON = "";
this.recvContainer.Value = "";
}
else
{
recvJSON = "";
this.recvContainer.Value = "";
return;
}
}
#endregion
#region 插入账户信息记录
/// <summary>
/// 插入账户信息记录
/// </summary>
/// <param name="CodeCtnSetEntities">需要插入账户表的账户实体类</param>
/// <param name="iType">如果iType值为1则记录账户类型为收/否则记录为付</param>
public void InsertCodeCtnSet(List<JsonCodeCtnSetEntity> CodeCtnSetEntities, int iType)
{
ArrayList sqlInsertList = new ArrayList();
CodeCtnSetDA CodeCtnSetDA = new CodeCtnSetDA();
CodeCtnSetEntity CodeCtnSetEntity = new CodeCtnSetEntity();
CodeCtnSetEntity CodeCtnSetEntityCTN = new CodeCtnSetEntity();
string alt = "";
foreach (JsonCodeCtnSetEntity CodeCtnSet in CodeCtnSetEntities)
{
CodeCtnSetEntity.CTNID = CodeCtnSet.CodeCtnSet1.Trim().Equals("null") ? "" : CodeCtnSet.CodeCtnSet1.Trim();
CodeCtnSetEntity.CTNSIZE = CodeCtnSet.CodeCtnSet2.Trim().Equals("null") ? "" : CodeCtnSet.CodeCtnSet2.Trim();
CodeCtnSetEntity.CTNTYPE = CodeCtnSet.CodeCtnSet3.Trim().Equals("null") ? "" : CodeCtnSet.CodeCtnSet3.Trim();
CodeCtnSetEntity.CTN = CodeCtnSet.CodeCtnSet4.Trim().Equals("null") ? "" : CodeCtnSet.CodeCtnSet4.Trim();
CodeCtnSetEntity.EDICODE = CodeCtnSet.CodeCtnSet5.Trim().Equals("null") ? "" : CodeCtnSet.CodeCtnSet5.Trim();
CodeCtnSetEntity.CTNWEIGHT = Decimal.Parse(CodeCtnSet.CodeCtnSet6.ToString().Trim().Equals("null") ? "0" : CodeCtnSet.CodeCtnSet6.ToString().Trim());
CodeCtnSetEntity.EEXPLAIN = CodeCtnSet.CodeCtnSet7.Trim().Equals("null") ? "" : CodeCtnSet.CodeCtnSet7.Trim();
CodeCtnSetEntity.CEXPLAIN = CodeCtnSet.CodeCtnSet8.Trim().Equals("null") ? "" : CodeCtnSet.CodeCtnSet8.Trim();
//
CodeCtnSetEntityCTN = CodeCtnSetDA.GetCodeCtnSetCTN(CodeCtnSetEntity.CTN);
if (CodeCtnSetEntityCTN == null)
{
int iResult = CodeCtnSetDA.InserInfo(CodeCtnSetEntity);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
if (iResult == 1)
{
}
}
else
{
alt += CodeCtnSetEntity.CTN + ",";
}
}
//
//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 JsonCodeCtnSetGroupEntity GetPostEntity(string tempValue)
{
JsonCodeCtnSetGroupEntity CodeCtnSetGroupEntity = (JsonCodeCtnSetGroupEntity)JSON.Instance.ToObject(tempValue);
return CodeCtnSetGroupEntity;
}
#endregion
}
}