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.

429 lines
21 KiB
C#

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 WmsZXFee : 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;
}
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();
}
//
if (this.hdEnabled.Value.Trim() == "false")
{
getEnabled();
}
//
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 (!IsPostBack)
{
getddlDataSet();
}
//
recvJSON = "";
recvJSON = this.recvContainer.Value.Trim();
if (!recvJSON.Trim().Equals(""))
{
//应收账户保存
JsonWmsZXFeeGroupEntity WmsZXFeeTableGroupRecvEntity = GetPostEntity(recvJSON);
List<JsonWmsZXFeeEntity> WmsZXFeeTableRecvEntities = new List<JsonWmsZXFeeEntity>();
WmsZXFeeTableRecvEntities = WmsZXFeeTableGroupRecvEntity.JsonWmsZXFeeEntities;
SaveRecvWmsZXFeeTable(WmsZXFeeTableGroupRecvEntity);
//更新完初始化
recvJSON = "";
}
//
}
protected void getddlDataSet()
{
int iYear = int.Parse(DateTime.Parse(strdate).Year.ToString());
ddlFEEYEAR.Items.Clear();
for (int i = iYear; i > iYear - 11; i--)
{
ddlFEEYEAR.Items.Add(new ListItem(i.ToString(), i.ToString()));
ddlFEEYEAR1.Items.Add(new ListItem(i.ToString(), i.ToString()));
ddlFEEYEAR2.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
ddlFEEYEAR.Text = iYear.ToString();
ddlFEEYEAR1.Text = iYear.ToString();
ddlFEEYEAR2.Text = iYear.ToString();
//
string sMonth = DateTime.Parse(strdate).Month.ToString();
if (sMonth.Length == 1)
{
sMonth = "0" + sMonth;
}
ddlFEEMONTH.Text = sMonth;
ddlFEEMONTH1.Text = sMonth;
ddlFEEMONTH2.Text = sMonth;
}
protected void getEnabled()
{
divadd.Disabled = true;
divsave.Disabled = true;
divdel.Disabled = true;
divrefresh.Disabled = true;
mygrid_recv.Disabled = true;
}
#region 保存应收账户列表更改结果
/// <summary>
/// 保存应收账户列表更改结果
/// </summary>
/// <param name="tempGroupEntity"></param>
private void SaveRecvWmsZXFeeTable(JsonWmsZXFeeGroupEntity tempGroupEntity)
{
if (tempGroupEntity != null)
{
List<WmsFeeEntity> WMSZXEntities = new List<WmsFeeEntity>();
List<JsonWmsZXFeeEntity> WmsFeeEntities = new List<JsonWmsZXFeeEntity>();
WmsFeeEntities = tempGroupEntity.JsonWmsZXFeeEntities;
DataTable WmsZXFeeTableTable = new DataTable();
//
ArrayList sqlInsertList = new ArrayList();
WmsFeeDA WmsFeeDA = new WmsFeeDA();
WmsFeeEntity WmsFeeEntityGID = new WmsFeeEntity();
//
string strInitSql = "";
if (tempGroupEntity.JsonWmsZXFeeEntities.Count > 0)
{
strInitSql = " SELECT GID,FEEYEAR,FEEMONTH,CLIENTNAME,STORAGENAME,AREANAME,UNITPRICE,ACREAGE,ARFEE,APFEE,UNIT,REMARK,ISLOCK,LOCKTIME,LOCKUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME FROM wms_fee WHERE 1=1 and FEEYEAR='" + ddlFEEYEAR.Text.Trim() + "' and FEEMONTH='" + ddlFEEMONTH.Text.Trim() + "' ORDER BY MODIFIEDTIME desc";
}
else
{
return;
}
WmsZXFeeTableTable = WmsFeeDA.GetExcuteSql(strInitSql).Tables[0];
//更新操作SQL语句
ArrayList sqlList = new ArrayList();
//日志操作SQL语句
ArrayList logList = new ArrayList();
//日志记录
Logger log = Logger.Instance;
for (int i = 0; i < WmsZXFeeTableTable.Rows.Count; i++)
{
if (WmsZXFeeTableTable.Rows[i]["ISLOCK"].ToString().Trim() == "True")
{
continue;
}
//
foreach (JsonWmsZXFeeEntity WmsZXFee in WmsFeeEntities)
{
if (WmsZXFeeTableTable.Rows[i]["GID"].ToString().Trim().Equals(WmsZXFee.WmsZXFee1.Trim()))//惟一编号
{
WmsFeeEntity model = new WmsFeeEntity();
string strSql = "";
string LogContent = "";
LogEntity logEntity = new LogEntity();
//GID
string strGID = WmsZXFee.WmsZXFee1.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee1.ToString().Trim();
model.GID = strGID;
//
#region 更改前后信息对比
//客户名称
string strCLIENTNAME = WmsZXFee.WmsZXFee2.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee2.ToString().Trim();
model.CLIENTNAME = strCLIENTNAME;
if (!WmsZXFeeTableTable.Rows[i]["CLIENTNAME"].ToString().Trim().Equals(strCLIENTNAME))
{
//strSql += String.Format(" itemno = '{0}'", strCLIENTNAME);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "客户名称", WmsZXFeeTableTable.Rows[i]["CLIENTNAME"].ToString().Trim(), strCLIENTNAME);
}
//仓库名称
string strSTORAGENAME = WmsZXFee.WmsZXFee3.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee3.ToString().Trim();
model.STORAGENAME = strSTORAGENAME;
if (!WmsZXFeeTableTable.Rows[i]["STORAGENAME"].ToString().Trim().Equals(strSTORAGENAME))
{
//strSql += String.Format(" itemno = '{0}'", strSTORAGENAME);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "仓库名称", WmsZXFeeTableTable.Rows[i]["STORAGENAME"].ToString().Trim(), strSTORAGENAME);
}
//库位名称
string strAREANAME = WmsZXFee.WmsZXFee4.Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee4.Trim();
model.AREANAME = strAREANAME;
if (!WmsZXFeeTableTable.Rows[i]["AREANAME"].ToString().Trim().Equals(strAREANAME))
{
//strSql += String.Format(",explan = '{0}'", strAREANAME);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "库位名称", WmsZXFeeTableTable.Rows[i]["AREANAME"].ToString().Trim(), strAREANAME);
}
//计费单价
string strUNITPRICE = WmsZXFee.WmsZXFee5.ToString().Trim().Equals("null") ? "" : WmsZXFee.WmsZXFee5.ToString().Trim();
model.UNITPRICE = Decimal.Parse(strUNITPRICE);
if (!WmsZXFeeTableTable.Rows[i]["UNITPRICE"].ToString().Trim().Equals(strUNITPRICE))
{
//strSql += String.Format(",accname = '{0}'", strARFEE);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "计费单价", WmsZXFeeTableTable.Rows[i]["UNITPRICE"].ToString().Trim(), strUNITPRICE);
}
//计费数量
string strACREAGE = WmsZXFee.WmsZXFee6.ToString().Trim().Equals("null") ? "" : WmsZXFee.WmsZXFee6.ToString().Trim();
model.ACREAGE = Decimal.Parse(strACREAGE);
if (!WmsZXFeeTableTable.Rows[i]["ACREAGE"].ToString().Trim().Equals(strACREAGE))
{
//strSql += String.Format(",accname = '{0}'", strARFEE);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "计费数量", WmsZXFeeTableTable.Rows[i]["ACREAGE"].ToString().Trim(), strACREAGE);
}
//仓储费
string strARFEE = WmsZXFee.WmsZXFee7.ToString().Trim().Equals("null") ? "" : WmsZXFee.WmsZXFee7.ToString().Trim();
model.ARFEE = Decimal.Parse(strARFEE);
if (!WmsZXFeeTableTable.Rows[i]["ARFEE"].ToString().Trim().Equals(strARFEE))
{
//strSql += String.Format(",accname = '{0}'", strARFEE);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "仓储费", WmsZXFeeTableTable.Rows[i]["ARFEE"].ToString().Trim(), strARFEE);
}
//数量单位
string strUNIT = WmsZXFee.WmsZXFee8.Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee8.Trim();
model.UNIT = strUNIT;
if (!WmsZXFeeTableTable.Rows[i]["UNIT"].ToString().Trim().Equals(strUNIT))
{
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "数量单位", WmsZXFeeTableTable.Rows[i]["UNIT"].ToString().Trim(), strUNIT);
}
//备注
string strREMARK = WmsZXFee.WmsZXFee9.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee9.ToString().Trim();
model.REMARK = strREMARK;
if (!WmsZXFeeTableTable.Rows[i]["REMARK"].ToString().Trim().Equals(strREMARK))
{
//strSql += String.Format(",blno = '{0}'", strREMARK);
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "备注", WmsZXFeeTableTable.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), "最后一次更改操作人", WmsZXFeeTableTable.Rows[i]["MODIFIEDUSER"].ToString().Trim(), strUserID);
//最后一次更改操作时间
//strSql += ",MODIFIEDTIME = getdate()";
LogContent += String.Format(log.GetLogContentTemplate(Logger.LogTypes.UPDATE), "最后一次更改操作时间", WmsZXFeeTableTable.Rows[i]["MODIFIEDTIME"].ToString().Trim(), DateTime.Now.ToString().Trim());
}
#endregion
//如果有字段内容更新则执行更新操作
if (LogContent.Trim().Length > 1)
{
WMSZXEntities.Add(model);
logList.Add(String.Format("更新账户标识 {0} {1}", WmsZXFee.WmsZXFee1.Trim(), LogContent));
}
WmsFeeEntities.Remove(WmsZXFee);
break;
}
}
}
if (WMSZXEntities.Count > 0)
{
int iResult = WmsFeeDA.UpdateFromGrid(WMSZXEntities);
//为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 (WmsFeeEntities.Count > 0)
{
//插入新的应收币别信息
InsertWmsZXFeeTable(WmsFeeEntities);
}
//
recvJSON = "";
this.recvContainer.Value = "";
}
else
{
recvJSON = "";
this.recvContainer.Value = "";
return;
}
}
#endregion
#region 插入账户信息记录
/// <summary>
/// 插入账户信息记录
/// </summary>
/// <param name="WmsFeeEntities">需要插入账户表的账户实体类</param>
public void InsertWmsZXFeeTable(List<JsonWmsZXFeeEntity> WmsFeeEntities)
{
ArrayList sqlInsertList = new ArrayList();
WmsFeeDA WmsFeeDA = new WmsFeeDA();
WmsFeeEntity WmsFeeEntityGID = new WmsFeeEntity();
string alt = "";
foreach (JsonWmsZXFeeEntity WmsZXFee in WmsFeeEntities)
{
WmsFeeEntity model = new WmsFeeEntity();
model.GID = WmsZXFee.WmsZXFee1.Trim().Equals("null") ? "" : WmsZXFee.WmsZXFee1.Trim();
//
#region 更改前后信息对比
//客户名称
string strCLIENTNAME = WmsZXFee.WmsZXFee2.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee2.ToString().Trim();
model.CLIENTNAME = strCLIENTNAME;
//仓库名称
string strSTORAGENAME = WmsZXFee.WmsZXFee3.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee3.ToString().Trim();
model.STORAGENAME = strSTORAGENAME;
//库位名称
string strAREANAME = WmsZXFee.WmsZXFee4.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee4.ToString().Trim();
model.AREANAME = strAREANAME;
//单价
string strUNITPRICE = WmsZXFee.WmsZXFee5.ToString().Trim().Equals("null") ? "" : WmsZXFee.WmsZXFee5.ToString().Trim();
if (strUNITPRICE.Trim() == "" || strUNITPRICE.Trim() == "0" || strUNITPRICE.Trim() == "0.00")
{
model.UNITPRICE = 0;
}
else
{
model.UNITPRICE = Decimal.Parse(strUNITPRICE);
}
//数量
string strACREAGE = WmsZXFee.WmsZXFee6.ToString().Trim().Equals("null") ? "" : WmsZXFee.WmsZXFee6.ToString().Trim();
if (strACREAGE.Trim() == "" || strACREAGE.Trim() == "0" || strACREAGE.Trim() == "0.00")
{
model.ACREAGE = 0;
}
else
{
model.ACREAGE = Decimal.Parse(strACREAGE);
}
//仓储费
string strARFEE = WmsZXFee.WmsZXFee7.ToString().Trim().Equals("null") ? "" : WmsZXFee.WmsZXFee7.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 strUNIT = WmsZXFee.WmsZXFee8.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee8.ToString().Trim();
model.UNIT = strUNIT;
//
//备注
string strREMARK = WmsZXFee.WmsZXFee9.ToString().Trim().ToLower().Equals("null") ? "" : WmsZXFee.WmsZXFee9.ToString().Trim();
model.REMARK = strREMARK;
//
model.CREATEUSER = strUserID;
model.MODIFIEDUSER = strUserID;
model.CREATETIME = DateTime.Parse(ddlFEEYEAR.Text + "-" + ddlFEEMONTH.Text + "-" + "01");
//
model.FEEYEAR = int.Parse(ddlFEEYEAR.Text.Trim());
model.FEEMONTH = int.Parse(ddlFEEMONTH.Text.Trim());
#endregion
//
WmsFeeEntityGID = WmsFeeDA.GetModel(model.GID);
if (WmsFeeEntityGID == null)
{
int iResult = WmsFeeDA.Add(model);
//为1表示更新成功
//为-1有异常,更新失败
//为-2更新异常,事务已回滚成功
//更新完成后,记录日志
if (iResult == 1)
{
}
}
else
{
alt += model.GID + ",";
}
}
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParent('" + this.hdGID.Value.Trim() + "','" + this.hdHandle.Value.Trim() + "');</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>refreshRecv();</script>");
}
#endregion
#region 获取账户客户保存的账户信息
/// <summary>
/// 获取账户客户保存的账户信息
/// </summary>
/// <param name="tempValue"></param>
/// <returns></returns>
public JsonWmsZXFeeGroupEntity GetPostEntity(string tempValue)
{
JsonWmsZXFeeGroupEntity WmsZXFeeTableGroupEntity = (JsonWmsZXFeeGroupEntity)JSON.Instance.ToObject(tempValue);
return WmsZXFeeTableGroupEntity;
}
#endregion
protected String getWMSNO()
{
string strWMSNO = Guid.NewGuid().ToString();
strWMSNO = strWMSNO.Replace("-", "");
strWMSNO = "WmsZXFee" + strWMSNO;
return strWMSNO;
}
//
}
}