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/WMS_ZX/WmsZXInfo.aspx.cs

1136 lines
60 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.WMS_ZX
{
public partial class WmsZXInfo : System.Web.UI.Page
{
private string recvJSON;
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 (!IsPostBack)
{
if (Request.QueryString["handle"] != null)
{
WmsDA WmsDA = new WmsDA();
WmsEntity WmsEntity = new WmsEntity();
switch (this.hdHandle.Value.Trim())
{
case "add"://新增
//ViewState["GID"] = getBSNO();
//this.hdGid.Value = ViewState["GID"].ToString().Trim();
this.hdGID.Value = "";
tbWMSNO.Text = "";
tbCLIENTBSNO.Text = "";
tbWMSDATE.Text = strdate;
this.hd_comboWMSOP.Value = strShowName.Trim();
if (this.hdGID.Value.Trim() != "")
{
WmsEntity = WmsDA.GetModel(this.hdGID.Value.Trim());
if (WmsEntity.GID != null)
{
this.hd_comboCUSTOMERNAME.Value = WmsEntity.CUSTOMERNAME.ToString().Trim();
this.hd_comboTRUCK.Value = WmsEntity.TRUCKNAME.ToString().Trim();
this.hd_comboWMSOP.Value = WmsEntity.WMSOP.ToString().Trim();
this.hd_comboSTOREMAN.Value = WmsEntity.STOREMAN.ToString().Trim();
}
}
break;
case "addfull"://新增
this.hdGID.Value = "";
tbWMSNO.Text = "";
tbCLIENTBSNO.Text = "";
tbWMSDATE.Text = strdate;
this.hd_comboWMSOP.Value = strShowName.Trim();
if (this.hdGID.Value.Trim() != "")
{
WmsEntity = WmsDA.GetModel(this.hdGID.Value.Trim());
if (WmsEntity.GID != null)
{
this.hd_comboCUSTOMERNAME.Value = WmsEntity.CUSTOMERNAME.ToString().Trim();
this.hd_comboTRUCK.Value = WmsEntity.TRUCKNAME.ToString().Trim();
this.hd_comboWMSOP.Value = WmsEntity.WMSOP.ToString().Trim();
this.hd_comboSTOREMAN.Value = WmsEntity.STOREMAN.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();
tbCLIENTBSNO.Text = WmsEntity.CLIENTBSNO.ToString().Trim();
this.hd_comboCUSTOMERNAME.Value = WmsEntity.CUSTOMERNAME.ToString().Trim();
this.hd_comboTRUCK.Value = WmsEntity.TRUCKNAME.ToString().Trim();
this.hd_comboWMSOP.Value = WmsEntity.WMSOP.ToString().Trim();
this.hd_comboSTOREMAN.Value = WmsEntity.STOREMAN.ToString().Trim();
tbWMSDATE.Text = WmsEntity.WMSDATE.ToString("yyyy-MM-dd").Trim();
DataSet ds = T_ALL_DA.GetAllSQL("select top 1 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.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 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.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();
}
//
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(), 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(""))
{
//应收账户保存
JsonWmsInGroupEntity WmsZXInfoGroupRecvEntity = GetPostEntity(recvJSON);
List<JsonWmsInEntity> WmsZXInfoRecvEntities = new List<JsonWmsInEntity>();
WmsZXInfoRecvEntities = WmsZXInfoGroupRecvEntity.JsonWmsInEntities;
SaveRecvWmsZXInfo(WmsZXInfoGroupRecvEntity);
//更新完初始化
recvJSON = "";
}
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initComboCUSTOMERNAME();initComboWMSOP();initComboSTOREMAN();initComboTRUCK();</script>");
}
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;
tbCLIENTBSNO.Enabled = false;
}
#region 保存应收账户列表更改结果
/// <summary>
/// 保存应收账户列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SaveRecvWmsZXInfo(JsonWmsInGroupEntity 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");//调用编码规则
}
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", "<script>alert(入库单'" + strWMSNO + "'已经生成,不允许重复生成!);</script>");
return;
}
//
WmsEntity.WMSDATE = DateTime.Parse(tbWMSDATE.Text.Trim());
WmsEntity.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();
WmsEntity.TRUCKNAME = this.hd_comboTRUCK.Value.ToString().Trim();
WmsEntity.WMSOP = this.hd_comboWMSOP.Value.Trim();
WmsEntity.STOREMAN = this.hd_comboSTOREMAN.Value.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;
WmsEntity.ASSOCIATEDNO = "";
WmsEntity.FREESTORAGEPERIOD = 0;
WmsEntity.BLNO = "";
WmsEntity.CONTRACTNO = "";
WmsEntity.GOODSNAME = "";
WmsEntity.GOODSMODEL = "";
WmsEntity.CLIENTCODEOLD = "";
WmsEntity.CLIENTNAMEOLD = "";
WmsEntity.STORAGENAME = "";
WmsEntity.CHARGEUNIT = "";
WmsEntity.CUSTNO = "";
WmsEntity.CUSTOMNO = "";//备案清单号
WmsEntity.FREESTORAGEPERIODAP = 0;
WmsEntity.STARTBILLINGDATEAP = WmsEntity.WMSDATE;
WmsEntity.STARTBILLINGDATE = WmsEntity.WMSDATE;
WmsEntity.CORPID = strCompanyID;
WmsEntity.CLIENTBSNO = tbCLIENTBSNO.Text.Trim();
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");//调用编码规则
}
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", "<script>alert(入库单'" + strWMSNO + "'已经生成,不允许重复生成!);</script>");
return;
}
//
WmsEntity.WMSDATE = DateTime.Parse(tbWMSDATE.Text.Trim());
WmsEntity.CUSTOMERNAME = this.hd_comboCUSTOMERNAME.Value.Trim();
WmsEntity.TRUCKNAME = this.hd_comboTRUCK.Value.Trim();
WmsEntity.WMSOP = this.hd_comboWMSOP.Value.Trim();
WmsEntity.STOREMAN = this.hd_comboSTOREMAN.Value.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;
WmsEntity.ASSOCIATEDNO = "";
WmsEntity.FREESTORAGEPERIOD = 0;
WmsEntity.BLNO = "";
WmsEntity.CONTRACTNO = "";
WmsEntity.GOODSNAME = "";
WmsEntity.GOODSMODEL = "";
WmsEntity.CLIENTCODEOLD = "";
WmsEntity.CLIENTNAMEOLD = "";
WmsEntity.STORAGENAME = "";
WmsEntity.CHARGEUNIT = "";
WmsEntity.CUSTNO = "";
WmsEntity.CUSTOMNO = "";//备案清单号
WmsEntity.ARCLIENT = "";
WmsEntity.FREESTORAGEPERIODAP = 0;
WmsEntity.STARTBILLINGDATEAP = WmsEntity.WMSDATE;
WmsEntity.STARTBILLINGDATE = WmsEntity.WMSDATE;
WmsEntity.ISCHANGE = false;//
WmsEntity.CORPID = strCompanyID;
WmsEntity.CLIENTBSNO = tbCLIENTBSNO.Text.Trim();
int iR = WmsDA.Add(WmsEntity);
}
//
List<WmsInEntity> WMSZXEntities = new List<WmsInEntity>();
List<JsonWmsInEntity> WmsInEntities = new List<JsonWmsInEntity>();
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,STORAGENAME,AREANAME,GOODSNAME,GOODSMODEL,CHARGEUNIT,GOODSPACK,GOODSRKSL,ARFEE,APFEE,REMARK,ASSOCIATEDNO,MODIFIEDTIME,GOODSPACKSTOCK FROM wms_in WHERE 1<0";
}
else
{
strInitSql = " SELECT GID,STORAGENAME,AREANAME,GOODSNAME,GOODSMODEL,CHARGEUNIT,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 (JsonWmsInEntity 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 strSTORAGENAME = WmsIn.WmsIn2.ToString().Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn2.ToString().Trim();
model.STORAGENAME = strSTORAGENAME;
if (!WmsZXInfoTable.Rows[i]["STORAGENAME"].ToString().Trim().Equals(strSTORAGENAME))
{
//strSql += String.Format(" itemno = '{0}'", strSTORAGENAME);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "仓库名称", WmsZXInfoTable.Rows[i]["STORAGENAME"].ToString().Trim(), strSTORAGENAME);
}
//库位名称
string strAREANAME = WmsIn.WmsIn3.Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn3.Trim();
model.AREANAME = strAREANAME;
if (!WmsZXInfoTable.Rows[i]["AREANAME"].ToString().Trim().Equals(strAREANAME))
{
//strSql += String.Format(",explan = '{0}'", strAREANAME);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "库位名称", WmsZXInfoTable.Rows[i]["AREANAME"].ToString().Trim(), strAREANAME);
}
//货物名称
string strGOODSNAME = WmsIn.WmsIn4.Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn4.Trim();
model.GOODSNAME = strGOODSNAME;
if (!WmsZXInfoTable.Rows[i]["GOODSNAME"].ToString().Trim().Equals(strGOODSNAME))
{
//strSql += String.Format(",accid = '{0}'", strGOODSNAME);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "货物名称", WmsZXInfoTable.Rows[i]["GOODSNAME"].ToString().Trim(), strGOODSNAME);
}
//型号
string strGOODSMODEL = WmsIn.WmsIn5.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn5.ToString().Trim();
model.GOODSMODEL = strGOODSMODEL;
if (!WmsZXInfoTable.Rows[i]["GOODSMODEL"].ToString().Trim().Equals(strGOODSMODEL))
{
//strSql += String.Format(",accname = '{0}'", strGOODSMODEL);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "型号", WmsZXInfoTable.Rows[i]["GOODSMODEL"].ToString().Trim(), strGOODSMODEL);
}
//计费单位
string strCHARGEUNIT = WmsIn.WmsIn6.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn6.ToString().Trim();
model.CHARGEUNIT = strCHARGEUNIT;
if (!WmsZXInfoTable.Rows[i]["GOODSMODEL"].ToString().Trim().Equals(strCHARGEUNIT))
{
//strSql += String.Format(",accname = '{0}'", strCHARGEUNIT);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "计费单位", WmsZXInfoTable.Rows[i]["GOODSMODEL"].ToString().Trim(), strCHARGEUNIT);
}
//件数
string strGOODSPACK = WmsIn.WmsIn7.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn7.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.WmsIn8.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn8.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.WmsIn9.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn9.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.WmsIn10.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn10.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.WmsIn11.ToString().Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn11.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 isnull(CODENAME,'') as 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();// 原客户名称
// 仓库编码
string strSTORAGECODE = T_ALL_DA.GetStrSQL("CODENAME", "select top 1 isnull(CODENAME,'') as CODENAME from info_client where SHORTNAME='" + strSTORAGENAME.Trim() + "'");
model.STORAGECODE = strSTORAGECODE;
// 库位编码
string strAREACODE = T_ALL_DA.GetStrSQL("AREACODE", "select top 1 isnull(AREACODE,'') as AREACODE from wms_storage_area where STORAGENAME='" + strSTORAGENAME.Trim() + "' and AREANAME='" + strAREANAME.Trim() + "'");
model.AREACODE = strAREACODE;
// 货物编号
string strGOODSCODE = T_ALL_DA.GetStrSQL("GOODCODE", "select top 1 isnull(GOODCODE,'') as GOODCODE from code_goods where GOODNAME='" + strSTORAGENAME.Trim() + "'");
model.GOODSCODE = strGOODSCODE;
//
model.BLNO = "";// 提单号
model.CONTRACTNO = "";// 合同号
model.CNTRNO = "";// 箱号
model.SEALNO = "";// 封号
model.BSNO = "";// 仓单明细号
model.GOODSTYPE = "";// 货物类型
model.GOODSSTANDARD = "";// 规格
model.FREESTORAGEPERIOD = 0;//
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<FeeEntity> feeEntities = new List<FeeEntity>();
//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);
}
//
recvJSON = "";
this.recvContainer.Value = "";
}
else
{
recvJSON = "";
this.recvContainer.Value = "";
return;
}
}
#endregion
#region 插入账户信息记录
/// <summary>
/// 插入账户信息记录
/// </summary>
/// <param name="WmsInEntities">需要插入账户表的账户实体类</param>
public void InsertWmsZXInfo(List<JsonWmsInEntity> WmsInEntities)
{
ArrayList sqlInsertList = new ArrayList();
WmsInDA WmsInDA = new WmsInDA();
WmsInEntity WmsInEntityGID = new WmsInEntity();
string alt = "";
foreach (JsonWmsInEntity WmsIn in WmsInEntities)
{
WmsInEntity model = new WmsInEntity();
model.GID = WmsIn.WmsIn1.Trim().Equals("null") ? "" : WmsIn.WmsIn1.Trim();
//
#region 更改前后信息对比
//仓库名称
string strSTORAGENAME = WmsIn.WmsIn2.ToString().Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn2.ToString().Trim();
model.STORAGENAME = strSTORAGENAME;
//库位名称
string strAREANAME = WmsIn.WmsIn3.Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn3.Trim();
model.AREANAME = strAREANAME;
//货物名称
string strGOODSNAME = WmsIn.WmsIn4.Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn4.Trim();
model.GOODSNAME = strGOODSNAME;
//型号
string strGOODSMODEL = WmsIn.WmsIn5.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn5.ToString().Trim();
model.GOODSMODEL = strGOODSMODEL;
//计费单位
string strCHARGEUNIT = WmsIn.WmsIn6.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn6.ToString().Trim();
model.CHARGEUNIT = strCHARGEUNIT;
//件数
string strGOODSPACK = WmsIn.WmsIn7.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn7.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.WmsIn8.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn8.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.WmsIn9.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn9.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.WmsIn10.ToString().Trim().Equals("null") ? "" : WmsIn.WmsIn10.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.WmsIn11.ToString().Trim().ToLower().Equals("null") ? "" : WmsIn.WmsIn11.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 isnull(CODENAME,'') as 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();// 原客户名称
// 仓库编码
string strSTORAGECODE = T_ALL_DA.GetStrSQL("CODENAME", "select top 1 isnull(CODENAME,'') as CODENAME from info_client where SHORTNAME='" + strSTORAGENAME.Trim() + "'");
model.STORAGECODE = strSTORAGECODE;
// 库位编码
string strAREACODE = T_ALL_DA.GetStrSQL("AREACODE", "select top 1 isnull(AREACODE,'') as AREACODE from wms_storage_area where STORAGENAME='" + strSTORAGENAME.Trim() + "' and AREANAME='" + strAREANAME.Trim() + "'");
model.AREACODE = strAREACODE;
// 货物编号
string strGOODSCODE = T_ALL_DA.GetStrSQL("GOODCODE", "select top 1 isnull(GOODCODE,'') as GOODCODE from code_goods where GOODNAME='" + strSTORAGENAME.Trim() + "'");
model.GOODSCODE = strGOODSCODE;
//
model.BLNO = "";// 提单号
model.CONTRACTNO = "";// 合同号
model.CNTRNO = "";// 箱号
model.SEALNO = "";// 封号
model.BSNO = tbWMSNO.Text.Trim();// 仓单明细号
model.GOODSTYPE = "";// 货物类型
model.GOODSSTANDARD = "";// 规格
model.FREESTORAGEPERIOD = 0;//
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<FeeEntity> feeEntities = new List<FeeEntity>();
//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", "<script>reloadParent('" + this.hdGID.Value.Trim() + "','" + this.hdHandle.Value.Trim() + "');</script>");
//
//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 JsonWmsInGroupEntity GetPostEntity(string tempValue)
{
JsonWmsInGroupEntity WmsZXInfoGroupEntity = (JsonWmsInGroupEntity)JSON.Instance.ToObject(tempValue);
return WmsZXInfoGroupEntity;
}
#endregion
protected String getWMSNO()
{
string strWMSNO = Guid.NewGuid().ToString();
strWMSNO = strWMSNO.Replace("-", "");
strWMSNO = "WmsZ" + strWMSNO;
return strWMSNO;
}
/// <summary>
/// 提取规则编号
/// </summary>
/// <param name="strRULENAME">规则项目名称</param>
/// <param name="strfield">需要加规则的字段</param>
/// <returns></returns>
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;
}
}
}
}
}
}
/// <summary>
/// 提取规则编号
/// </summary>
/// <param name="strRULENAME">规则项目名称</param>
/// <param name="strfield">需要加规则的字段</param>
/// <returns></returns>
protected String getCodeRule(string strRULENAME, string strfield)
{
//调用编码规则
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 [wms] 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 "";
}
//
}
}