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; using System.Text; using DSWeb.DataAccess; using System.Data.SqlClient; using System.Web.Script.Serialization; using System.Text.RegularExpressions; using System.ComponentModel; using System.Drawing; using System.Web.SessionState; using System.Web.Mail; using System.IO; using System.Data.OleDb; using DSWeb.Attributes; namespace DSWeb.SeaiInfoLCL { public partial class WmsLCLInfo : System.Web.UI.Page { private string recvJSON; private string recvJSON_2; RangeDA RangeDA = new RangeDA(); T_ALL_DA T_ALL_DA = new T_ALL_DA(); public string strdate;// public string strUserID;//登录用户GID public string strCompanyID;//公司GID public string strShowName;//用户显示名 public string strDeptName;//部门名称 protected void Page_Load(object sender, EventArgs e) { if (Session["USERID"] != null) { strUserID = Session["USERID"].ToString().Trim(); this.hdUserID.Value = strUserID; } else { Server.Transfer("~/Error/FriendError.aspx"); return; //strUserID = "1BEC90E1-9780-472F-90C2-0C6390C044A4"; //this.hdUserID.Value = strUserID; } if (Session["SHOWNAME"] != null) { strShowName = Session["SHOWNAME"].ToString(); } if (Session["COMPANYID"] != null) { strCompanyID = Session["COMPANYID"].ToString(); this.hdCompanyID.Value = strCompanyID; } if (Session["DEPTNAME"] != null) { strDeptName = Session["DEPTNAME"].ToString(); } if (Request.QueryString["isenabled"] != null) { this.hdEnabled.Value = Request.QueryString["isenabled"].ToString(); } // T_ALL_DA T_ALL_DA = new T_ALL_DA(); strdate = T_ALL_DA.GetStrSQL("rq", "select convert(char(10),getdate(),20) as rq"); // if (Request.QueryString["handle"] != null) { this.hdHandle.Value = Request.QueryString["handle"].ToString(); } // if (Request.QueryString["id"] != null) { this.hdGID.Value = Request.QueryString["id"].ToString(); } // if (Request.QueryString["associatedno"] != null) { this.hid_associatedno.Value = Request.QueryString["associatedno"].ToString(); } // if (!IsPostBack) { if (Request.QueryString["handle"] != null) { WmsDA WmsDA = new WmsDA(); WmsEntity WmsEntity = new WmsEntity(); SeaImportInfoDA SeaImportInfoDA = new SeaImportInfoDA(); TopSeaiEntity TopSeaiEntity = new TopSeaiEntity(); switch (this.hdHandle.Value.Trim()) { case "add"://新增 //ViewState["GID"] = getBSNO(); //this.hdGid.Value = ViewState["GID"].ToString().Trim(); this.hdGID.Value = ""; tbWMSNO.Text = ""; tbWMSDATE.Text = strdate; if (this.hid_associatedno.Value.Trim() != "") { TopSeaiEntity = SeaImportInfoDA.GetID(this.hid_associatedno.Value.Trim()); if (TopSeaiEntity.BSNO != null) { this.hd_comboCUSTOMERNAME.Value = TopSeaiEntity.CUSTOMERNAME.ToString().Trim(); tbFREESTORAGEPERIOD.Text = TopSeaiEntity.FBP.ToString().Trim() == "" ? "0" : TopSeaiEntity.FBP.ToString().Trim(); tbBLNO.Text = TopSeaiEntity.MBLNO.ToString().Trim(); tbCONTRACTNO.Text = TopSeaiEntity.CONTRACTNO.ToString().Trim(); this.hd_comboGOODSNAME.Value = TopSeaiEntity.GOODSNAME.ToString().Trim(); tbGOODSMODEL.Text = TopSeaiEntity.GOODSTYPENAME.ToString().Trim(); ddlCHARGEUNIT.Text = TopSeaiEntity.UNITOFWEIGHT.ToString().Trim(); this.hd_comboSTORAGENAME.Value = TopSeaiEntity.STORAGENAME.ToString().Trim(); this.hd_comboTRUCKNAME.Value = TopSeaiEntity.STORAGENAME.ToString().Trim(); } } break; case "addfull"://新增 this.hdGID.Value = ""; tbWMSNO.Text = ""; tbWMSDATE.Text = strdate; if (this.hid_associatedno.Value.Trim() != "") { TopSeaiEntity = SeaImportInfoDA.GetID(this.hid_associatedno.Value.Trim()); if (TopSeaiEntity.BSNO != null) { this.hd_comboCUSTOMERNAME.Value = TopSeaiEntity.CUSTOMERNAME.ToString().Trim(); tbFREESTORAGEPERIOD.Text = TopSeaiEntity.FBP.ToString().Trim() == "" ? "0" : TopSeaiEntity.FBP.ToString().Trim(); tbBLNO.Text = TopSeaiEntity.MBLNO.ToString().Trim(); tbCONTRACTNO.Text = TopSeaiEntity.CONTRACTNO.ToString().Trim(); this.hd_comboGOODSNAME.Value = TopSeaiEntity.GOODSNAME.ToString().Trim(); tbGOODSMODEL.Text = TopSeaiEntity.GOODSTYPENAME.ToString().Trim(); ddlCHARGEUNIT.Text = TopSeaiEntity.UNITOFWEIGHT.ToString().Trim(); this.hd_comboSTORAGENAME.Value = TopSeaiEntity.STORAGENAME.ToString().Trim(); this.hd_comboTRUCKNAME.Value = TopSeaiEntity.STORAGENAME.ToString().Trim(); } } // //ViewState["GID"] = getBSNO(); //this.hdGid.Value = ViewState["GID"].ToString().Trim(); // break; case "edit"://录入 if (this.hdGID.Value.Trim() != "") { WmsEntity = WmsDA.GetModel(this.hdGID.Value.Trim()); if (WmsEntity.GID != null) { tbWMSNO.Text = WmsEntity.WMSNO.ToString().Trim(); this.hd_comboCUSTOMERNAME.Value = WmsEntity.CUSTOMERNAME.ToString().Trim(); tbFREESTORAGEPERIOD.Text = WmsEntity.FREESTORAGEPERIOD.ToString().Trim() == "" ? "0" : WmsEntity.FREESTORAGEPERIOD.ToString().Trim(); tbBLNO.Text = WmsEntity.BLNO.ToString().Trim(); tbCONTRACTNO.Text = WmsEntity.CONTRACTNO.ToString().Trim(); tbWMSDATE.Text = WmsEntity.WMSDATE.ToString("yyyy-MM-dd").Trim(); this.hd_comboGOODSNAME.Value = WmsEntity.GOODSNAME.ToString().Trim(); tbGOODSMODEL.Text = WmsEntity.GOODSMODEL.ToString().Trim(); ddlCHARGEUNIT.Text = WmsEntity.CHARGEUNIT.ToString().Trim(); this.hd_comboSTORAGENAME.Value = WmsEntity.STORAGENAME.ToString().Trim(); this.hd_comboTRUCKNAME.Value = WmsEntity.TRUCKNAME.ToString().Trim(); DataSet ds = T_ALL_DA.GetAllSQL("select top 1 GOODSPACK=(select sum(GOODSPACK) from wms_in where ASSOCIATEDNO=wms.gid),GOODSRKSL=(select sum(GOODSRKSL) from wms_in where ASSOCIATEDNO=wms.gid),ARFEE=(select sum(ARFEE) from wms_in where ASSOCIATEDNO=wms.gid),APFEE=(select sum(APFEE) from wms_in where ASSOCIATEDNO=wms.gid) from wms where gid='" + this.hdGID.Value.Trim() + "'"); if (ds != null) { //件数 this.dvGOODSPACKVal.InnerText = ds.Tables[0].Rows[0]["GOODSPACK"].ToString().Trim(); //计费数量 this.dvProfitTotalVal.InnerText = ds.Tables[0].Rows[0]["GOODSRKSL"].ToString().Trim(); //出库应收 this.dvRecvTotalVal.InnerText = ds.Tables[0].Rows[0]["ARFEE"].ToString().Trim(); //出库应付 this.dvPaySumVal.InnerText = ds.Tables[0].Rows[0]["APFEE"].ToString().Trim(); } } } break; } } } // if (this.hdHandle.Value.Trim() == "edit") { DataSet ds1 = T_ALL_DA.GetAllSQL("select top 1 GOODSPACK=(select sum(GOODSPACK) from wms_in where ASSOCIATEDNO=wms.gid),GOODSRKSL=(select sum(GOODSRKSL) from wms_in where ASSOCIATEDNO=wms.gid),ARFEE=(select sum(ARFEE) from wms_in where ASSOCIATEDNO=wms.gid),APFEE=(select sum(APFEE) from wms_in where ASSOCIATEDNO=wms.gid) from wms where gid='" + this.hdGID.Value.Trim() + "'"); if (ds1 != null) { //件数 this.dvGOODSPACKVal.InnerText = ds1.Tables[0].Rows[0]["GOODSPACK"].ToString().Trim(); //计费数量 this.dvProfitTotalVal.InnerText = ds1.Tables[0].Rows[0]["GOODSRKSL"].ToString().Trim(); //出库应收 this.dvRecvTotalVal.InnerText = ds1.Tables[0].Rows[0]["ARFEE"].ToString().Trim(); //出库应付 this.dvPaySumVal.InnerText = ds1.Tables[0].Rows[0]["APFEE"].ToString().Trim(); } tbWMSNO.Enabled = false; } else { tbWMSNO.Enabled = true; } if (this.hdEnabled.Value.Trim() == "false") { getEnabled(); } if (this.hdEnabled.Value.Trim() == "falses") { getEnabled(); btislock.Disabled = true; btnotislock.Disabled = true; this.hdHandle.Value = "false"; } // recvJSON = ""; recvJSON = this.recvContainer.Value.Trim(); recvJSON_2 = ""; recvJSON_2 = this.recvContainer_2.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(), strSeaWMSNO); 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(), strSeaWMSNO); 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(), strSeaWMSNO); 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 (!recvJSON.Trim().Equals("")) { //应收账户保存 JsonWmsInGroupEntity3 WmsZXInfoGroupRecvEntity = GetPostEntity(recvJSON); List WmsZXInfoRecvEntities = new List(); WmsZXInfoRecvEntities = WmsZXInfoGroupRecvEntity.JsonWmsInEntities; SaveRecvWmsZXInfo(WmsZXInfoGroupRecvEntity); //更新完初始化 recvJSON = ""; } //仓储费率 if (!recvJSON_2.Trim().Equals("")) { SaveRateAction(); recvJSON_2 = ""; this.recvContainer_2.Value = ""; } //加载下拉框 Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", ""); } protected void getEnabled() { divadd.Disabled = true; divsave.Disabled = true; divdel.Disabled = true; divrollback.Disabled = true; divrefresh.Disabled = true; //ibPrint.Disabled = true; mygrid_recv.Disabled = true; // tbWMSNO.Enabled=false; //ddlCUSTOMERNAME tbBLNO.Enabled=false; tbCONTRACTNO.Enabled=false; //ddlSTORAGENAME tbFREESTORAGEPERIOD.Enabled=false; //ddlGOODSNAME tbGOODSMODEL.Enabled=false; ddlCHARGEUNIT.Enabled=false; tbWMSDATE.Enabled = false; //仓储费率 divadd_2.Disabled = true; divsave_2.Disabled = true; divdel_2.Disabled = true; divrollback_2.Disabled = true; divrefresh_2.Disabled = true; mygrid_container_recv_2.Disabled = true; } #region 将页面post获取的仓储费率信息保存或更新“仓储费率信息表”wms_rate,并返回操作结果 /// /// 将页面post获取的仓储费率信息保存或更新“仓储费率信息表”wms_rate,并返回操作结果 /// private void SaveRateAction() { IList rateEntities = new List(); if (!recvJSON_2.Trim().Equals("")) { rateEntities = ResolverecvJSON_2(recvJSON_2.Trim(), rateEntities); this.recvContainer_2.Value = ""; } WmsRateDA rateDA = new WmsRateDA(); foreach (WmsRateEntity rateentity in rateEntities) { string strwhere = String.Format(" GID='{0}' ", rateentity.GID); int strExists = rateDA.GetRecordCount(strwhere); if (strExists == 1) { bool iRecvState = rateDA.Update(rateentity); } else if (strExists == 0) { bool iRecvState = rateDA.Add(rateentity); } } } #endregion #region 将页面post获取的仓储费率信息读入到仓储费率实体类wms_rate中 /// /// 将页面post获取的仓储费率信息读入到仓储费率实体类wms_rate中 /// /// /// /// 将页面post获取的仓储费率信息读入到仓储费率实体类wms_rate中 private IList ResolverecvJSON_2(string tempJSON, IList tempRateEntities) { string strFilter = ""; if (tempJSON.IndexOf("[") >= 0 && tempJSON.IndexOf("]") > 0) { strFilter = tempJSON.Substring(tempJSON.IndexOf("[") + 1, tempJSON.IndexOf("]") - tempJSON.IndexOf("[") - 1); string[] strFees = strFilter.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries); if (strFees.Length > 0) { for (int i = 0; i < strFees.Length; i++) { strFees[i] = strFees[i].ToString().Replace("{", ""); strFees[i] = strFees[i].ToString().Replace("}", ""); string[] strCell = strFees[i].Split(new char[] { ',' }); if (strCell.Length > 0) { WmsRateEntity RateEntity = new WmsRateEntity(); for (int j = 0; j < strCell.Length; j++) { string[] strArg = strCell[j].Split(new char[] { ':' }); switch (strArg[0].Replace("\"", "")) { case "id": RateEntity.GID = strArg[1].ToString().Replace("\"", ""); break; //case "cusid": // RateEntity.CLIENTGID = strArg[1].ToString().Replace("\"", ""); // break; case "cus": RateEntity.CUSTOMERNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "")); break; //case "no": // RateEntity.CONTRACTNO =strArg[1].ToString().Replace("\"", "") ; // break; //case "bt": // RateEntity.STARTTIME = DateTime.Parse(strArg[1].ToString().Replace("\"", "")); // break; //case "et": // RateEntity.ENDTIME = DateTime.Parse(strArg[1].ToString().Replace("\"", "")); // break; //case "goods": // RateEntity.GOODSNAME = strArg[1].ToString().Replace("\"", ""); // break; case "fgrade": RateEntity.FEEGRADE = int.Parse(strArg[1].ToString().Replace("\"", "")); break; case "fscale": RateEntity.FEESCALE = int.Parse(strArg[1].ToString().Replace("\"", "")); break; case "fprice": RateEntity.FEEPRICE = decimal.Parse(strArg[1].ToString().Replace("\"", "")); break; case "funit": RateEntity.FEEUNIT = "吨天"; break; case "remark": RateEntity.REMARK = strArg[1].ToString().Replace("\"", ""); break; default: break; } } RateEntity.BSNO = this.hdGID.Value.Trim(); RateEntity.CREATEUSER = this.strShowName; RateEntity.MODIFIEDUSER = this.strShowName; tempRateEntities.Add(RateEntity); } } } } return tempRateEntities; } #endregion #region 保存应收账户列表更改结果 /// /// 保存应收账户列表更改结果 /// /// private void SaveRecvWmsZXInfo(JsonWmsInGroupEntity3 tempGroupEntity) { if (tempGroupEntity != null) { // if (this.hdGID.Value.Trim() != "" & this.hdHandle.Value.Trim()=="edit") { WmsDA WmsDA = new WmsDA(); WmsEntity WmsEntity = new WmsEntity(); //this.hdGID.Value = getWMSNO(); WmsEntity.GID = this.hdGID.Value.Trim(); if (tbWMSNO.Text.Trim() == "") { WmsEntity.WMSNO = getCodeRule("入库单号", "WMSNO", "WMS");//调用编码规则 } else { WmsEntity.WMSNO = tbWMSNO.Text.Trim(); } // string strWMSNO = T_ALL_DA.GetStrSQL("WMSNO", "select WMSNO from wms where wmsno='" + WmsEntity.WMSNO.ToString().Trim() + "' and gid<>'" + this.hdGID.Value.Trim() + "'"); if (strWMSNO.Trim() != "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", ""); return; } // WmsEntity.WMSDATE = DateTime.Parse(tbWMSDATE.Text.Trim()); WmsEntity.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim(); WmsEntity.FREESTORAGEPERIOD = tbFREESTORAGEPERIOD.Text.Trim() == "" ? 0 : int.Parse(tbFREESTORAGEPERIOD.Text.Trim()); WmsEntity.BLNO = tbBLNO.Text.Trim(); WmsEntity.CONTRACTNO = tbCONTRACTNO.Text.Trim(); WmsEntity.WMSOP = strShowName.Trim(); WmsEntity.STOREMAN = strShowName.Trim(); WmsEntity.MODIFIEDUSER = strUserID; // WmsEntity.GOODSPACK = 0; WmsEntity.GOODSPACKSTOCK = 0; WmsEntity.GOODSRKSL = 0; WmsEntity.GOODSSTOCK = 0; WmsEntity.ARFEE = 0; WmsEntity.APFEE = 0; WmsEntity.GOODSPACKACTUAL = 0; WmsEntity.GOODSRKSLACTUAL = 0; // if (this.hid_associatedno.Value.Trim() == "" && tbBLNO.Text.Trim() != "") { this.hid_associatedno.Value = T_ALL_DA.GetStrSQL("bsno", "select top 1 bsno from op_seai where MBLNO='" + tbBLNO.Text.Trim() + "'"); } WmsEntity.ASSOCIATEDNO = this.hid_associatedno.Value.Trim(); // WmsEntity.GOODSNAME = this.hd_comboGOODSNAME.Value.Trim(); WmsEntity.GOODSMODEL = tbGOODSMODEL.Text.Trim(); WmsEntity.CHARGEUNIT = ddlCHARGEUNIT.Text.Trim(); //原客户编码 string strCLIENTCODE = T_ALL_DA.GetStrSQL("CODENAME", "select top 1 CODENAME from info_client where SHORTNAME='" + this.hd_comboCUSTOMERNAME.Value.Trim() + "'"); WmsEntity.CLIENTCODEOLD = strCLIENTCODE;// 原客户编码 WmsEntity.CLIENTNAMEOLD = this.hd_comboCUSTOMERNAME.Value.Trim();// 原客户名称 WmsEntity.STORAGENAME = this.hd_comboSTORAGENAME.Value.Trim(); WmsEntity.TRUCKNAME = this.hd_comboTRUCKNAME.Value.Trim(); WmsEntity.CUSTNO = ""; WmsEntity.CUSTOMNO = "";//备案清单号 WmsEntity.FREESTORAGEPERIODAP = 0; WmsEntity.STARTBILLINGDATEAP = WmsEntity.WMSDATE; WmsEntity.CORPID = strCompanyID; WmsEntity.CLIENTBSNO = ""; int iR = WmsDA.Update(WmsEntity); } else { WmsDA WmsDA = new WmsDA(); WmsEntity WmsEntity = new WmsEntity(); this.hdGID.Value=getWMSNO(); WmsEntity.GID = this.hdGID.Value.Trim(); if (tbWMSNO.Text.Trim() == "") { WmsEntity.WMSNO = getCodeRule("入库单号", "WMSNO", "WMS");//调用编码规则 } else { WmsEntity.WMSNO = tbWMSNO.Text.Trim(); } // string strWMSNO = T_ALL_DA.GetStrSQL("WMSNO", "select WMSNO from wms where wmsno='" + WmsEntity.WMSNO.ToString().Trim() + "'"); if (strWMSNO.Trim() != "") { Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", ""); return; } // WmsEntity.WMSDATE = DateTime.Parse(tbWMSDATE.Text.Trim()); WmsEntity.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim(); WmsEntity.FREESTORAGEPERIOD = tbFREESTORAGEPERIOD.Text.Trim() == "" ? 0 : int.Parse(tbFREESTORAGEPERIOD.Text.Trim()); WmsEntity.BLNO = tbBLNO.Text.Trim().Trim(); WmsEntity.CONTRACTNO = tbCONTRACTNO.Text.Trim(); WmsEntity.WMSOP = strShowName.Trim(); WmsEntity.STOREMAN = strShowName.Trim(); WmsEntity.MODIFIEDUSER = strUserID; // WmsEntity.GOODSPACK = 0; WmsEntity.GOODSPACKSTOCK = 0; WmsEntity.GOODSRKSL = 0; WmsEntity.GOODSSTOCK = 0; WmsEntity.ARFEE = 0; WmsEntity.APFEE = 0; WmsEntity.GOODSPACKACTUAL = 0; WmsEntity.GOODSRKSLACTUAL = 0; // if (this.hid_associatedno.Value.Trim() == "" && tbBLNO.Text.Trim() != "") { this.hid_associatedno.Value = T_ALL_DA.GetStrSQL("bsno", "select top 1 bsno from op_seai where MBLNO='" + tbBLNO.Text.Trim() + "'"); } WmsEntity.ASSOCIATEDNO = this.hid_associatedno.Value.Trim(); // WmsEntity.GOODSNAME = this.hd_comboGOODSNAME.Value.Trim(); WmsEntity.GOODSMODEL = tbGOODSMODEL.Text.Trim(); WmsEntity.CHARGEUNIT = ddlCHARGEUNIT.Text.Trim(); //原客户编码 string strCLIENTCODE = T_ALL_DA.GetStrSQL("CODENAME", "select top 1 CODENAME from info_client where SHORTNAME='" + this.hd_comboCUSTOMERNAME.Value.Trim() + "'"); WmsEntity.CLIENTCODEOLD = strCLIENTCODE;// 原客户编码 WmsEntity.CLIENTNAMEOLD = this.hd_comboCUSTOMERNAME.Value.Trim();// 原客户名称 WmsEntity.STORAGENAME = this.hd_comboSTORAGENAME.Value.Trim(); WmsEntity.TRUCKNAME = this.hd_comboTRUCKNAME.Value.Trim(); WmsEntity.ARCLIENT = ""; WmsEntity.CUSTNO = ""; WmsEntity.CUSTOMNO = "";//备案清单号 WmsEntity.FREESTORAGEPERIODAP=0; WmsEntity.STARTBILLINGDATEAP = WmsEntity.WMSDATE; WmsEntity.ISCHANGE = false;// WmsEntity.CORPID = strCompanyID; WmsEntity.CLIENTBSNO = ""; int iR = WmsDA.Add(WmsEntity); } // List WMSZXEntities = new List(); List WmsInEntities = new List(); WmsInEntities = tempGroupEntity.JsonWmsInEntities; DataTable WmsZXInfoTable = new DataTable(); // ArrayList sqlInsertList = new ArrayList(); WmsInDA WmsInDA = new WmsInDA(); WmsInEntity WmsInEntityGID = new WmsInEntity(); string strInitSql = ""; if (tempGroupEntity.JsonWmsInEntities.Count > 0) { if (this.hdGID.Value.Trim() == "") { strInitSql = " SELECT GID,GOODSPACK,GOODSRKSL,ARFEE,APFEE,REMARK,ASSOCIATEDNO,MODIFIEDTIME,GOODSPACKSTOCK FROM wms_in WHERE 1<0"; } else { strInitSql = " SELECT GID,GOODSPACK,GOODSRKSL,ARFEE,APFEE,REMARK,ASSOCIATEDNO,MODIFIEDTIME,GOODSPACKSTOCK FROM wms_in WHERE 1=1 and ASSOCIATEDNO='" + this.hdGID.Value.Trim() + "' ORDER BY MODIFIEDTIME desc"; } } else { return; } WmsZXInfoTable = WmsInDA.GetExcuteSql(strInitSql).Tables[0]; //更新操作SQL语句 ArrayList sqlList = new ArrayList(); //日志操作SQL语句 ArrayList logList = new ArrayList(); //日志记录 Logger log = Logger.Instance; for (int i = 0; i < WmsZXInfoTable.Rows.Count; i++) { foreach (JsonWmsInEntity3 WmsIn in WmsInEntities) { if (WmsZXInfoTable.Rows[i]["GID"].ToString().Trim().Equals(WmsIn.WmsIn1.Trim()))//惟一编号 { WmsInEntity model = new WmsInEntity(); string strSql = ""; string LogContent = ""; LogEntity logEntity = new LogEntity(); //GID string strGID = WmsIn.WmsIn1.ToString().Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn1.ToString().Trim(); model.GID = strGID; // #region 更改前后信息对比 //件数 string strGOODSPACK = WmsIn.WmsIn2.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn2.ToString().Trim(); model.GOODSPACK = Decimal.Parse(strGOODSPACK); model.GOODSPACKSTOCK = Decimal.Parse(strGOODSPACK); //剩余件数 //model.GOODSPACKSTOCK = Decimal.Parse(WmsZXInfoTable.Rows[i]["GOODSPACKSTOCK"].ToString().Trim().Equals("null") ? "0" : WmsZXInfoTable.Rows[i]["GOODSPACKSTOCK"].ToString().Trim()); //剩余件数 if (!WmsZXInfoTable.Rows[i]["GOODSPACK"].ToString().Trim().Equals(strGOODSPACK)) { //strSql += String.Format(",accname = '{0}'", strGOODSPACK); LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "件数", WmsZXInfoTable.Rows[i]["GOODSPACK"].ToString().Trim(), strGOODSPACK); } //计费数量 string strGOODSRKSL = WmsIn.WmsIn3.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn3.ToString().Trim(); model.GOODSRKSL = Decimal.Parse(strGOODSRKSL); model.GOODSSTOCK = Decimal.Parse(strGOODSRKSL); if (!WmsZXInfoTable.Rows[i]["GOODSRKSL"].ToString().Trim().Equals(strGOODSRKSL)) { //strSql += String.Format(",accname = '{0}'", strARFEE); LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "计费数量", WmsZXInfoTable.Rows[i]["GOODSRKSL"].ToString().Trim(), strGOODSRKSL); } //应收账款 string strARFEE = WmsIn.WmsIn4.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn4.ToString().Trim(); model.ARFEE = Decimal.Parse(strARFEE); if (!WmsZXInfoTable.Rows[i]["ARFEE"].ToString().Trim().Equals(strARFEE)) { //strSql += String.Format(",accname = '{0}'", strARFEE); LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应收账款", WmsZXInfoTable.Rows[i]["ARFEE"].ToString().Trim(), strARFEE); } //应付账款 string strAPFEE = WmsIn.WmsIn5.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn5.ToString().Trim(); model.APFEE = Decimal.Parse(strAPFEE); if (!WmsZXInfoTable.Rows[i]["APFEE"].ToString().Trim().Equals(strAPFEE)) { //strSql += String.Format(",accname = '{0}'", strAPFEE); LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "应付账款", WmsZXInfoTable.Rows[i]["APFEE"].ToString().Trim(), strAPFEE); } //备注 string strREMARK = WmsIn.WmsIn6.ToString().Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn6.ToString().Trim(); model.REMARK = strREMARK; if (!WmsZXInfoTable.Rows[i]["REMARK"].ToString().Trim().Equals(strREMARK)) { //strSql += String.Format(",blno = '{0}'", strREMARK); LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "备注", WmsZXInfoTable.Rows[i]["REMARK"].ToString().Trim(), strREMARK); } // model.MODIFIEDUSER = strUserID; if (strSql.Trim() != "") { //最后一次更改操作人 //strSql += String.Format(",MODIFIEDUSER = '{0}'", strUserID); LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "最后一次更改操作人", WmsZXInfoTable.Rows[i]["MODIFIEDUSER"].ToString().Trim(), strUserID); //最后一次更改操作时间 //strSql += ",MODIFIEDTIME = getdate()"; LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "最后一次更改操作时间", WmsZXInfoTable.Rows[i]["MODIFIEDTIME"].ToString().Trim(), DateTime.Now.ToString().Trim()); } #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}'", "wms_in", strSql, WmsIn.WmsIn1.Trim()); //sqlList.Add(strUpdateSql); // model.ASSOCIATEDNO = this.hdGID.Value.Trim();// 关联号 // 客户编码 string strCLIENTCODE = T_ALL_DA.GetStrSQL("CODENAME", "select top 1 CODENAME from info_client where SHORTNAME='" + this.hd_comboCUSTOMERNAME.Value.Trim() + "'"); model.CLIENTCODE = strCLIENTCODE; model.CLIENTNAME = this.hd_comboCUSTOMERNAME.Value.Trim(); model.CLIENTCODEOLD = strCLIENTCODE;// 原客户编码 model.CLIENTNAMEOLD = this.hd_comboCUSTOMERNAME.Value.Trim();// 原客户名称 model.STORAGECODE = "";// 仓库编码 model.AREACODE = "";// 库位编码 model.AREANAME = ""; model.GOODSCODE = "";// 货物编号 model.GOODSNAME = this.hd_comboGOODSNAME.Value.Trim();//货物名称 model.GOODSMODEL = tbGOODSMODEL.Text.Trim();//型号 model.CHARGEUNIT = ddlCHARGEUNIT.Text.Trim();//计费单位 model.STORAGENAME = this.hd_comboSTORAGENAME.Value.Trim(); // model.BLNO = tbBLNO.Text.Trim();// 提单号 model.CONTRACTNO = tbCONTRACTNO.Text.Trim();// 合同号 model.BSNO = tbWMSNO.Text.Trim();// 仓单明细号 model.FREESTORAGEPERIOD = tbFREESTORAGEPERIOD.Text.Trim() == "" ? 0 : int.Parse(tbFREESTORAGEPERIOD.Text.Trim());// model.CNTRNO = "";// 箱号 model.SEALNO = "";// 封号 model.GOODSTYPE = "";// 货物类型 model.GOODSSTANDARD = "";// 规格 model.GOODSKGS = 0;// 重量 model.KINDPKGS = "";// // model.ISLOCK = false;// 是否锁定 model.LOCKUSER = "";// 锁定操作人 model.ISDELETE = false;// 是否废除 model.DELETEUSER = "";// 废除操作人 model.CTNALL = ""; // model.GOODSTHICKNESS = 0; model.GOODSWIDTH = 0; model.GOODSLENGTH = 0; model.GOODSSLICE = 0; model.GOODSGRADE = ""; model.STACKLOCATION = ""; model.CORPID = strCompanyID; // WMSZXEntities.Add(model); logList.Add(String.Format("更新账户标识 {0} {1}", WmsIn.WmsIn1.Trim(), LogContent)); } WmsInEntities.Remove(WmsIn); break; } } } if (WMSZXEntities.Count > 0) { int iResult = WmsInDA.UpdateFromGrid(WMSZXEntities); //为1表示更新成功 //为-1有异常,更新失败 //为-2更新异常,事务已回滚成功 //更新完成后,记录日志 if (iResult == 1) { #region 费用合计入ch_fee表 //FeeDA feeDA = new FeeDA(); //IList feeEntities = new List(); //FeeEntity feeEntityBSNO = new FeeEntity(); //// ////应收 //string feehj = T_ALL_DA.GetStrSQL("hj", "SELECT isnull(sum(ARFEE),0) as hj FROM wms_in WHERE ASSOCIATEDNO = '" + this.hdGID.Value.Trim() + "'"); //string feebsno = T_ALL_DA.GetStrSQL("GID", "SELECT top 1 GID FROM ch_fee WHERE BSNO = '" + this.hdGID.Value.Trim() + "' and FEETYPE=1"); //FeeEntity feeEntity = new FeeEntity(); //if (feebsno.Trim() == "") //{ // feeEntity.GID = Guid.NewGuid().ToString(); //} //else //{ // feeEntity.GID = feebsno; //} //feeEntity.FeeType = 1; //feeEntity.BSNO = this.hdGID.Value.Trim();// 关联号 //feeEntity.FeeName = "装卸费"; //feeEntity.CustomerName = this.hd_comboCUSTOMERNAME.Value.Trim(); //feeEntity.Unit = "重量"; //feeEntity.UnitPrice = decimal.Parse(feehj); //feeEntity.Quantity = 1; //feeEntity.CommissionRate = 1; //feeEntity.Amount = decimal.Parse(feehj); ; //feeEntity.Currency = "RMB"; //feeEntity.ExchangeRate = 1; //feeEntity.FeeFrt = ""; //feeEntity.Remark = ""; //feeEntity.IsAdvancePay = false; //feeEntity.EnterOperator = strUserID; //feeEntity.FeeStatus = 1; //feeEntity.WMSOUTBSNO = ""; //feeEntities.Add(feeEntity); ////应付 //feehj = T_ALL_DA.GetStrSQL("hj", "SELECT isnull(sum(APFEE),0) as hj FROM wms_in WHERE ASSOCIATEDNO = '" + this.hdGID.Value.Trim() + "'"); //feebsno = T_ALL_DA.GetStrSQL("GID", "SELECT top 1 GID FROM ch_fee WHERE BSNO = '" + this.hdGID.Value.Trim() + "' and FEETYPE=2"); //FeeEntity feeEntity1 = new FeeEntity(); //if (feebsno.Trim() == "") //{ // feeEntity1.GID = Guid.NewGuid().ToString(); //} //else //{ // feeEntity1.GID = feebsno; //} //feeEntity1.FeeType = 2; //feeEntity1.BSNO = this.hdGID.Value.Trim();// 关联号 //feeEntity1.FeeName = "装卸费"; //feeEntity1.CustomerName = this.hd_comboCUSTOMERNAME.Value.Trim(); //feeEntity1.Unit = "重量"; //feeEntity1.UnitPrice = decimal.Parse(feehj); //feeEntity1.Quantity = 1; //feeEntity1.CommissionRate = 1; //feeEntity1.Amount = decimal.Parse(feehj); ; //feeEntity1.Currency = "RMB"; //feeEntity1.ExchangeRate = 1; //feeEntity1.FeeFrt = ""; //feeEntity1.Remark = ""; //feeEntity1.IsAdvancePay = false; //feeEntity1.EnterOperator = strUserID; //feeEntity1.FeeStatus = 1; //feeEntity1.WMSOUTBSNO = ""; //feeEntities.Add(feeEntity1); //int iState = feeDA.DoFee(feeEntities, this.hdGID.Value.Trim(), strUserID); #endregion #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 (WmsInEntities.Count > 0) { //插入新的应收币别信息 InsertWmsZXInfo(WmsInEntities); } // updateWMS();//更新wms的库存、费用数据 // recvJSON = ""; this.recvContainer.Value = ""; } else { recvJSON = ""; this.recvContainer.Value = ""; return; } } #endregion #region 更新wms的库存、费用数据 /// /// 更新wms的库存、费用数据 /// public void updateWMS() { T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA(); string lsSQL = "update wms set " + "GOODSPACK=(select isnull(sum(GOODSPACK),0) from wms_in where ASSOCIATEDNO=wms.gid)" + ",GOODSPACKSTOCK=(select isnull(sum(GOODSPACKSTOCK),0) from wms_in where ASSOCIATEDNO=wms.gid)" + ",GOODSRKSL=(select isnull(sum(GOODSRKSL),0) from wms_in where ASSOCIATEDNO=wms.gid)" + ",GOODSSTOCK=(select isnull(sum(GOODSSTOCK),0) from wms_in where ASSOCIATEDNO=wms.gid)" + ",ARFEE=(select isnull(sum(ARFEE),0) from wms_in where ASSOCIATEDNO=wms.gid)" + ",APFEE=(select isnull(sum(APFEE),0) from wms_in where ASSOCIATEDNO=wms.gid)" + " where ISLOCK=0 and GID='" + this.hdGID.Value.Trim() + "'"; bool bl = T_ALL_DA.GetExecuteSqlCommand(lsSQL); } #endregion #region 插入账户信息记录 /// /// 插入账户信息记录 /// /// 需要插入账户表的账户实体类 public void InsertWmsZXInfo(List WmsInEntities) { ArrayList sqlInsertList = new ArrayList(); WmsInDA WmsInDA = new WmsInDA(); WmsInEntity WmsInEntityGID = new WmsInEntity(); string alt = ""; foreach (JsonWmsInEntity3 WmsIn in WmsInEntities) { WmsInEntity model = new WmsInEntity(); model.GID = WmsIn.WmsIn1.Trim().Equals("null") ? "" : WmsIn.WmsIn1.Trim(); // #region 插入信息 //件数 string strGOODSPACK = WmsIn.WmsIn2.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn2.ToString().Trim(); if (strGOODSPACK.Trim() == "" || strGOODSPACK.Trim() == "0" || strGOODSPACK.Trim() == "0.0000") { model.GOODSPACK = 0; model.GOODSPACKSTOCK = 0; //剩余件数 } else { model.GOODSPACK = Decimal.Parse(strGOODSPACK); model.GOODSPACKSTOCK = Decimal.Parse(strGOODSPACK); //剩余件数 } //计费数量 string strGOODSRKSL = WmsIn.WmsIn3.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn3.ToString().Trim(); if (strGOODSRKSL.Trim() == "" || strGOODSRKSL.Trim() == "0" || strGOODSRKSL.Trim() == "0.0000") { model.GOODSRKSL = 0; model.GOODSSTOCK = 0; //剩余件数 } else { model.GOODSRKSL = Decimal.Parse(strGOODSRKSL); model.GOODSSTOCK = Decimal.Parse(strGOODSRKSL); //计费数量 } //应收账款 string strARFEE = WmsIn.WmsIn4.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn4.ToString().Trim(); if (strARFEE.Trim() == "" || strARFEE.Trim() == "0" || strARFEE.Trim() == "0.00") { model.ARFEE = 0; } else { model.ARFEE = Decimal.Parse(Decimal.Parse(strARFEE.Trim()).ToString("F2")); } //应付账款 string strAPFEE = WmsIn.WmsIn5.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn5.ToString().Trim(); if (strAPFEE.Trim() == "" || strAPFEE.Trim() == "0" || strAPFEE.Trim() == "0.00") { model.APFEE = 0; } else { model.APFEE = Decimal.Parse(Decimal.Parse(strAPFEE.Trim()).ToString("F2")); } //备注 string strREMARK = WmsIn.WmsIn6.ToString().Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn6.ToString().Trim(); model.REMARK = strREMARK; // model.CREATEUSER = strUserID; model.MODIFIEDUSER = strUserID; // model.ASSOCIATEDNO = this.hdGID.Value.Trim();// 关联号 // 客户编码 string strCLIENTCODE = T_ALL_DA.GetStrSQL("CODENAME", "select top 1 CODENAME from info_client where SHORTNAME='" + this.hd_comboCUSTOMERNAME.Value.Trim() + "'"); model.CLIENTCODE = strCLIENTCODE; model.CLIENTNAME = this.hd_comboCUSTOMERNAME.Value.Trim(); model.CLIENTCODEOLD = strCLIENTCODE;// 原客户编码 model.CLIENTNAMEOLD = this.hd_comboCUSTOMERNAME.Value.Trim();// 原客户名称 model.STORAGECODE = ""; model.AREACODE = "";// 库位编码 model.AREANAME = ""; model.GOODSCODE = "";// 货物编号 model.GOODSNAME = this.hd_comboGOODSNAME.Value.Trim();//货物名称 model.GOODSMODEL = tbGOODSMODEL.Text.Trim();//型号 model.CHARGEUNIT = ddlCHARGEUNIT.Text.Trim();//计费单位 model.STORAGENAME = this.hd_comboSTORAGENAME.Value.Trim(); // model.BLNO = tbBLNO.Text.Trim();// 提单号 model.CONTRACTNO = tbCONTRACTNO.Text.Trim();// 合同号 model.BSNO = getCodeRule("入库明细单号", "WMSNO", "wms_in");//调用编码规则 model.FREESTORAGEPERIOD = tbFREESTORAGEPERIOD.Text.Trim() == "" ? 0 : int.Parse(tbFREESTORAGEPERIOD.Text.Trim());// // model.CNTRNO = "";// 箱号 model.SEALNO = "";// 封号 model.GOODSTYPE = "";// 货物类型 model.GOODSSTANDARD = "";// 规格 model.GOODSKGS = 0;// 重量 model.KINDPKGS = "";// // model.ISLOCK = false;// 是否锁定 model.LOCKUSER = "";// 锁定操作人 model.ISDELETE = false;// 是否废除 model.DELETEUSER = "";// 废除操作人 model.CTNALL = "";// // model.GOODSTHICKNESS = 0; model.GOODSWIDTH = 0; model.GOODSLENGTH = 0; model.GOODSSLICE = 0; model.GOODSGRADE = ""; model.STACKLOCATION = ""; model.ISCHANGE = false;// model.CORPID = strCompanyID; #endregion // WmsInEntityGID = WmsInDA.GetID(model.GID); if (WmsInEntityGID.GID == null) { int iResult = WmsInDA.InserInfo(model); //为1表示更新成功 //为-1有异常,更新失败 //为-2更新异常,事务已回滚成功 //更新完成后,记录日志 if (iResult == 1) { #region 费用合计入ch_fee表 //FeeDA feeDA = new FeeDA(); //IList feeEntities = new List(); //FeeEntity feeEntityBSNO = new FeeEntity(); //// ////应收 //string feehj = T_ALL_DA.GetStrSQL("hj", "SELECT isnull(sum(ARFEE),0) as hj FROM wms_in WHERE ASSOCIATEDNO = '" + this.hdGID.Value.Trim() + "'"); //string feebsno = T_ALL_DA.GetStrSQL("GID", "SELECT top 1 GID FROM ch_fee WHERE BSNO = '" + this.hdGID.Value.Trim() + "' and FEETYPE=1"); //FeeEntity feeEntity = new FeeEntity(); //if (feebsno.Trim() == "") //{ // feeEntity.GID = Guid.NewGuid().ToString(); //} //else //{ // feeEntity.GID = feebsno; //} //feeEntity.FeeType = 1; //feeEntity.BSNO = this.hdGID.Value.Trim();// 关联号 //feeEntity.FeeName = "装卸费"; //feeEntity.CustomerName = this.hd_comboCUSTOMERNAME.Value.Trim(); //feeEntity.Unit = "重量"; //feeEntity.UnitPrice = decimal.Parse(feehj); //feeEntity.Quantity = 1; //feeEntity.CommissionRate = 1; //feeEntity.Amount = decimal.Parse(feehj); ; //feeEntity.Currency = "RMB"; //feeEntity.ExchangeRate = 1; //feeEntity.FeeFrt = ""; //feeEntity.Remark = ""; //feeEntity.IsAdvancePay = false; //feeEntity.EnterOperator = strUserID; //feeEntity.FeeStatus = 1; //feeEntity.WMSOUTBSNO = ""; //feeEntities.Add(feeEntity); ////应付 //feehj = T_ALL_DA.GetStrSQL("hj", "SELECT isnull(sum(APFEE),0) as hj FROM wms_in WHERE ASSOCIATEDNO = '" + this.hdGID.Value.Trim() + "'"); //feebsno = T_ALL_DA.GetStrSQL("GID", "SELECT top 1 GID FROM ch_fee WHERE BSNO = '" + this.hdGID.Value.Trim() + "' and FEETYPE=2"); //FeeEntity feeEntity1 = new FeeEntity(); //if (feebsno.Trim() == "") //{ // feeEntity1.GID = Guid.NewGuid().ToString(); //} //else //{ // feeEntity1.GID = feebsno; //} //feeEntity1.FeeType = 2; //feeEntity1.BSNO = this.hdGID.Value.Trim();// 关联号 //feeEntity1.FeeName = "装卸费"; //feeEntity1.CustomerName = this.hd_comboCUSTOMERNAME.Value.Trim(); //feeEntity1.Unit = "重量"; //feeEntity1.UnitPrice = decimal.Parse(feehj); //feeEntity1.Quantity = 1; //feeEntity1.CommissionRate = 1; //feeEntity1.Amount = decimal.Parse(feehj); ; //feeEntity1.Currency = "RMB"; //feeEntity1.ExchangeRate = 1; //feeEntity1.FeeFrt = ""; //feeEntity1.Remark = ""; //feeEntity1.IsAdvancePay = false; //feeEntity1.EnterOperator = strUserID; //feeEntity1.FeeStatus = 1; //feeEntity1.WMSOUTBSNO = ""; //feeEntities.Add(feeEntity1); //int iState = feeDA.DoFee(feeEntities, this.hdGID.Value.Trim(), strUserID); //if (iState != 1) //{ //} #endregion } } else { alt += model.GID + ","; } } Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", ""); // //if (alt != "") //{ // alt=alt.Trim().Substring(0,alt.Trim().Length-1); // Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", ""); //} } #endregion #region 获取账户客户保存的账户信息 /// /// 获取账户客户保存的账户信息 /// /// /// public JsonWmsInGroupEntity3 GetPostEntity(string tempValue) { JsonWmsInGroupEntity3 WmsZXInfoGroupEntity = (JsonWmsInGroupEntity3)JSON.Instance.ToObject(tempValue); return WmsZXInfoGroupEntity; } #endregion protected String getWMSNO() { string strWMSNO = Guid.NewGuid().ToString(); strWMSNO = strWMSNO.Replace("-", ""); strWMSNO = "Wms" + strWMSNO; return strWMSNO; } /// /// 提取规则编号 /// /// 规则项目名称 /// 需要加规则的字段 /// protected void getCodeRuleEnabled(string strRULENAME, string strfield) { //是否生成之后允许编辑 DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3"); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True")) { if (strfield == "WMSNO") { if (ds.Tables[0].Rows[0]["ISALLOWEDITS"].ToString().Trim().Equals("True")) { tbWMSNO.Enabled = true; } else { tbWMSNO.Enabled = false; } } } } } } /// /// 提取规则编号 /// /// 规则项目名称 /// 需要加规则的字段 /// protected String getCodeRule(string strRULENAME, string strfield,string tablename) { //调用编码规则 string strRULEYEAR = ""; string strRULECONTENT = ""; string strCODENAME = ""; string strDEPTNO = ""; string strRULENOLENGTH = ""; int iRULENOLENGTH = 0; int inum = 0; string strCONTENT = ""; DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3"); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True")) { getCodeRuleEnabled(strRULENAME, strfield); // if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期")) { if (tbWMSDATE.Text.Trim() == "") { return ""; } DateTime dETD = System.Convert.ToDateTime(tbWMSDATE.Text.Trim()); if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True")) { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM"); } } else { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = dETD.ToString("yyyy"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = dETD.ToString("yy"); } } } else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份")) { DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()")); if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True")) { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM"); } } else { if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4") { strRULEYEAR = fwqdate.ToString("yyyy"); } else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2") { strRULEYEAR = fwqdate.ToString("yy"); } } } // if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True")) { strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + this.hdUserID.Value.Trim() + "')"); } if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True")) { strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + this.hdUserID.Value.Trim() + "')"); } strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim(); strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME); strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO); // if (ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "") { iRULENOLENGTH = 0; } else { iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim()); } strCONTENT = strRULECONTENT + strRULEYEAR; //获取分公司的票号头字符 string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'"); strCONTENT = tempBANKSHEAD + strCONTENT; // strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [" + tablename + "] where " + strfield + " like '" + strCONTENT.Trim() + "%' and ISDELETE=0 order by " + strfield + " DESC"); if (strRULENOLENGTH == "") { strRULENOLENGTH = "1"; } else { strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), ""); inum = int.Parse(strRULENOLENGTH.Trim()); inum = inum + 1; strRULENOLENGTH = inum.ToString(); } int j = iRULENOLENGTH - strRULENOLENGTH.Length; for (int i = 1; i <= j; i++) { strRULENOLENGTH = "0" + strRULENOLENGTH; } // strCONTENT = strCONTENT + strRULENOLENGTH; return strCONTENT; } } } return ""; } #region Unicode-GB Code转换 /// /// Unicode-GB Code转换 /// /// 将Unicode编码字符转换成GB编码字符 /// GB Code字符串 public string UnicodeToGB(string text) { UnicodeEncoding unicode = new UnicodeEncoding(); text = unicode.GetString(unicode.GetBytes(Regex.Unescape(text.Trim()))); return text; } /// /// Unicode-GB Code转换 /// /// 将Unicode编码字符转换成GB编码字符 /// GB Code字符串 public string UnicodeToGB_Old(string text) { MatchCollection mc = Regex.Matches(text, "([\\w]+)|(\\\\u([\\w]{4}))"); if (mc != null && mc.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (Match m2 in mc) { string v = m2.Value; if (v.IndexOf("\\") >= 0) { string word = v.Substring(2); byte[] codes = new byte[2]; int code = Convert.ToInt32(word.Substring(0, 2), 16); int code2 = Convert.ToInt32(word.Substring(2), 16); codes[0] = (byte)code2; codes[1] = (byte)code; sb.Append(Encoding.Unicode.GetString(codes)); } else { sb.Append(v); } } return sb.ToString(); } else { return text; } } #endregion // } }