|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Configuration;
|
|
|
using System.Data;
|
|
|
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 System.Collections.Generic;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Data.SqlClient;
|
|
|
using System.Text;
|
|
|
using System.Globalization;
|
|
|
using JsonHelper;
|
|
|
using DSWeb.Models;
|
|
|
using DSWeb.EntityDA;
|
|
|
using DSWeb.Log;
|
|
|
using DSWeb.Authority;
|
|
|
using DSWeb.DataAccess;
|
|
|
using System.IO;
|
|
|
using System.Xml;
|
|
|
|
|
|
namespace DSWeb.SeaiFee
|
|
|
{
|
|
|
public partial class WmsOutEditCBM : System.Web.UI.Page
|
|
|
{
|
|
|
private string strUserID;
|
|
|
private string strCompanyID;//公司GID
|
|
|
private string strShowName;//用户显示名
|
|
|
private string strDeptName;//部门名称
|
|
|
|
|
|
private string strSearch;//仓储费率的客户、合同号、货物名称
|
|
|
private string WoJSON;//出库明细信息
|
|
|
private string WoDetailJSON;//出库明细信息
|
|
|
private string recvJSON;
|
|
|
private string payJSON;
|
|
|
private string strSeaBSNO;
|
|
|
private int iImportTemplateDetailType;
|
|
|
private string strCacheName;
|
|
|
private string strImportHistoryCacheName;
|
|
|
private int iHistoryType;//1-应收 2-应付
|
|
|
//private string strHandle;
|
|
|
//private bool isJsFee = false;
|
|
|
private int ischangecust = 0;
|
|
|
private IList<string> CustParent=new List<string>();
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
private string recvJSON_2;
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
this.h_oplb.Value = "op_Seai";
|
|
|
this.h_wmsoutbsno.Value = "";
|
|
|
this.h_IsFeeGain.Value = "0";
|
|
|
h_Mode.Value = "0";
|
|
|
this.txt_outdate.Value = DateTime.Today.ToString("yyyy-MM-dd");
|
|
|
this.txt_oldcustFeeDate.Value = this.txt_outdate.Value;
|
|
|
|
|
|
//addwmsout
|
|
|
if (Session["USERID"] != null)
|
|
|
{
|
|
|
strUserID = Session["USERID"].ToString();
|
|
|
}
|
|
|
if (Session["SHOWNAME"] != null)
|
|
|
{
|
|
|
strShowName = Session["SHOWNAME"].ToString();
|
|
|
}
|
|
|
if (Session["COMPANYID"] != null)
|
|
|
{
|
|
|
strCompanyID = Session["COMPANYID"].ToString();
|
|
|
}
|
|
|
if (Session["DEPTNAME"] != null)
|
|
|
{
|
|
|
strDeptName = Session["DEPTNAME"].ToString();
|
|
|
}
|
|
|
//
|
|
|
if (Request.QueryString["handle"] != null)
|
|
|
{
|
|
|
this.h_Handle.Value = Request.QueryString["handle"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["outgid"] != null)
|
|
|
{
|
|
|
this.h_outgid.Value = Request.QueryString["outgid"].ToString();
|
|
|
}
|
|
|
if (Request.QueryString["search"] != null)
|
|
|
{
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
|
|
|
this.h_EditJson.Value = strSearch;
|
|
|
}
|
|
|
if (Request.QueryString["bsno"] != null)
|
|
|
{
|
|
|
this.h_opseaibsno.Value = Request.QueryString["bsno"].ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.h_opseaibsno.Value = T_ALL_DA.GetStrSQL("ASSOCIATEDNO", "select top 1 ASSOCIATEDNO from wms_out where GID='" + this.h_outgid.Value.Trim() + "'");
|
|
|
}
|
|
|
if (Request.QueryString["ischangecust"] != null)
|
|
|
{
|
|
|
ischangecust = int.Parse(Request.QueryString["ischangecust"].ToString());
|
|
|
if (ischangecust == 1)
|
|
|
{
|
|
|
this.h_Ischange.Value = "1";
|
|
|
this.btn_Out.InnerHtml = "货权转移";
|
|
|
this.Title = "货权转移";
|
|
|
this.h_IsSetRate.Value = "1";
|
|
|
//this.txt_oldcustFeeDate.Disabled = false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.h_Ischange.Value = "0";
|
|
|
this.h_IsSetRate.Value = "0";
|
|
|
this.btn_Out.InnerHtml = "生成出库单";
|
|
|
this.Title = "生成出库单";
|
|
|
//this.txt_oldcustFeeDate.Disabled = true;
|
|
|
}
|
|
|
}
|
|
|
if (Request.QueryString["isdisabled"] != null)
|
|
|
{
|
|
|
this.h_isdisabled.Value = Request.QueryString["isdisabled"].ToString().Trim();
|
|
|
bool isdisabled = bool.Parse(this.h_isdisabled.Value.Trim());
|
|
|
setIsDisabled(isdisabled);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//货主名称
|
|
|
sel_customer.Visible = true;
|
|
|
txt_customer.Visible = false;
|
|
|
//仓库名称
|
|
|
sel_storage.Visible = true;
|
|
|
txt_storage.Visible = false;
|
|
|
//品名
|
|
|
sel_goods.Visible = true;
|
|
|
txt_goods.Visible = false;
|
|
|
}
|
|
|
//
|
|
|
WoJSON = "";
|
|
|
WoDetailJSON = "";
|
|
|
WoJSON=this.WoContainer.Value;
|
|
|
WoDetailJSON = this.WoDetailContainer.Value;
|
|
|
|
|
|
recvJSON = "";
|
|
|
recvJSON = this.recvContainer.Value.Trim();
|
|
|
payJSON = "";
|
|
|
payJSON = this.payContainer.Value.Trim();
|
|
|
|
|
|
recvJSON_2 = "";
|
|
|
recvJSON_2 = this.recvContainer_2.Value.Trim();
|
|
|
|
|
|
#region 获取引入费用模板缓存信息
|
|
|
if (recvJSON.Trim().Equals("") && payJSON.Trim().Equals("") && strCacheName != null && iImportTemplateDetailType > 0)
|
|
|
{
|
|
|
DataTable templateTable = (DataTable)Session[strCacheName];
|
|
|
StringBuilder templateBuilder = new StringBuilder();
|
|
|
|
|
|
if (templateTable != null)
|
|
|
{
|
|
|
if (templateTable.Rows.Count > 0)
|
|
|
{
|
|
|
templateBuilder.Append("{\"templates\":[");
|
|
|
for (int i = 0; i < templateTable.Rows.Count; i++)
|
|
|
{
|
|
|
templateTable.Rows[i]["GID"] = Guid.NewGuid().ToString();
|
|
|
if (i == templateTable.Rows.Count - 1)
|
|
|
{
|
|
|
templateBuilder.Append("{");
|
|
|
templateBuilder.Append("\"tid\":\"" + templateTable.Rows[i]["GID"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"fname\":\"" + templateTable.Rows[i]["FEENAME"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"client\":" + templateTable.Rows[i]["CLIENT"].ToString() + ",");
|
|
|
templateBuilder.Append("\"cust\":\"" + templateTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"unit\":\"" + templateTable.Rows[i]["UNIT"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"uprice\":" + templateTable.Rows[i]["UNITPRICE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"cur\":\"" + templateTable.Rows[i]["CURRENCY"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"exrate\":" + templateTable.Rows[i]["EXCHANGERATE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"remark\":\"" + templateTable.Rows[i]["REMARK"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"type\":" + templateTable.Rows[i]["FEETYPE"].ToString().ToString());
|
|
|
templateBuilder.Append("}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
templateBuilder.Append("{");
|
|
|
templateBuilder.Append("\"tid\":\"" + templateTable.Rows[i]["GID"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"fname\":\"" + templateTable.Rows[i]["FEENAME"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"client\":" + templateTable.Rows[i]["CLIENT"].ToString() + ",");
|
|
|
templateBuilder.Append("\"cust\":\"" + templateTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"unit\":\"" + templateTable.Rows[i]["UNIT"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"uprice\":" + templateTable.Rows[i]["UNITPRICE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"cur\":\"" + templateTable.Rows[i]["CURRENCY"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"exrate\":" + templateTable.Rows[i]["EXCHANGERATE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"remark\":\"" + templateTable.Rows[i]["REMARK"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"type\":" + templateTable.Rows[i]["FEETYPE"].ToString().ToString());
|
|
|
templateBuilder.Append("},");
|
|
|
}
|
|
|
}
|
|
|
templateBuilder.Append("]}");
|
|
|
|
|
|
this.h_importtype.Value = iImportTemplateDetailType.ToString();
|
|
|
this.h_cachename.Value = strCacheName;
|
|
|
this.h_cachetemplate.Value = templateBuilder.ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.h_importtype.Value = iImportTemplateDetailType.ToString();
|
|
|
this.h_cachename.Value = "";
|
|
|
this.h_cachetemplate.Value = "";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取引入历史费用缓存信息
|
|
|
if (recvJSON.Trim().Equals("") && payJSON.Trim().Equals("") && strImportHistoryCacheName != null && iHistoryType > 0)
|
|
|
{
|
|
|
DataTable templateTable = (DataTable)Session[strImportHistoryCacheName];
|
|
|
StringBuilder templateBuilder = new StringBuilder();
|
|
|
|
|
|
if (templateTable != null)
|
|
|
{
|
|
|
if (templateTable.Rows.Count > 0)
|
|
|
{
|
|
|
templateBuilder.Append("{\"history\":[");
|
|
|
for (int i = 0; i < templateTable.Rows.Count; i++)
|
|
|
{
|
|
|
templateTable.Rows[i]["GID"] = Guid.NewGuid().ToString();
|
|
|
if (i == templateTable.Rows.Count - 1)
|
|
|
{
|
|
|
templateBuilder.Append("{");
|
|
|
templateBuilder.Append("\"tid\":\"" + templateTable.Rows[i]["GID"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"fname\":\"" + templateTable.Rows[i]["FEENAME"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"cust\":\"" + templateTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"unit\":\"" + templateTable.Rows[i]["UNIT"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"uprice\":" + templateTable.Rows[i]["UNITPRICE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"quantity\":" + templateTable.Rows[i]["QUANTITY"].ToString() + ",");
|
|
|
templateBuilder.Append("\"comm\":" + templateTable.Rows[i]["COMMISSIONRATE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"amount\":" + templateTable.Rows[i]["AMOUNT"].ToString() + ",");
|
|
|
templateBuilder.Append("\"cur\":\"" + templateTable.Rows[i]["CURRENCY"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"exrate\":" + templateTable.Rows[i]["EXCHANGERATE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"frt\":\"" + templateTable.Rows[i]["FEEFRT"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"remark\":\"" + templateTable.Rows[i]["REMARK"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"isadv\":" + (templateTable.Rows[i]["ISADVANCEDPAY"].ToString().ToLower().Equals("true") ? 1 : 0) + ",");
|
|
|
templateBuilder.Append("\"type\":" + templateTable.Rows[i]["FEETYPE"].ToString().ToString());
|
|
|
templateBuilder.Append("}");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
templateBuilder.Append("{");
|
|
|
templateBuilder.Append("\"tid\":\"" + templateTable.Rows[i]["GID"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"fname\":\"" + templateTable.Rows[i]["FEENAME"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"cust\":\"" + templateTable.Rows[i]["CUSTOMERNAME"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"unit\":\"" + templateTable.Rows[i]["UNIT"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"uprice\":" + templateTable.Rows[i]["UNITPRICE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"quantity\":" + templateTable.Rows[i]["QUANTITY"].ToString() + ",");
|
|
|
templateBuilder.Append("\"comm\":" + templateTable.Rows[i]["COMMISSIONRATE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"amount\":" + templateTable.Rows[i]["AMOUNT"].ToString() + ",");
|
|
|
templateBuilder.Append("\"cur\":\"" + templateTable.Rows[i]["CURRENCY"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"exrate\":" + templateTable.Rows[i]["EXCHANGERATE"].ToString() + ",");
|
|
|
templateBuilder.Append("\"frt\":\"" + templateTable.Rows[i]["FEEFRT"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"remark\":\"" + templateTable.Rows[i]["REMARK"].ToString() + "\",");
|
|
|
templateBuilder.Append("\"isadv\":" + (templateTable.Rows[i]["ISADVANCEDPAY"].ToString().ToLower().Equals("true") ? 1 : 0) + ",");
|
|
|
templateBuilder.Append("\"type\":" + templateTable.Rows[i]["FEETYPE"].ToString().ToString());
|
|
|
templateBuilder.Append("},");
|
|
|
}
|
|
|
}
|
|
|
templateBuilder.Append("]}");
|
|
|
|
|
|
this.h_historytype.Value = iHistoryType.ToString();
|
|
|
this.h_historycachename.Value = strImportHistoryCacheName;
|
|
|
this.h_cachehistory.Value = templateBuilder.ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.h_historytype.Value = iHistoryType.ToString();
|
|
|
this.h_historycachename.Value = "";
|
|
|
this.h_cachehistory.Value = "";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 保存操作
|
|
|
if (this.h_post.Value.Trim() != "")
|
|
|
{
|
|
|
//保存操作
|
|
|
if (this.h_post.Value.Trim() == "1")
|
|
|
{
|
|
|
if (!recvJSON.Trim().Equals("") || !payJSON.Trim().Equals(""))
|
|
|
{ // 将页面post获取的费用信息保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain,并返回操作结果
|
|
|
SaveFeeAction();
|
|
|
}
|
|
|
}
|
|
|
else if (this.h_post.Value.Trim() == "2")
|
|
|
{
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
{
|
|
|
if (this.h_Handle.Value.Trim() == "edit")
|
|
|
{
|
|
|
SaveWoOutActionEdit();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
SaveWoOutAction();//add
|
|
|
}
|
|
|
this.h_post.Value = "";
|
|
|
//return;
|
|
|
}
|
|
|
}
|
|
|
else if (this.h_post.Value.Trim() == "3")
|
|
|
{
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
{
|
|
|
if (this.h_Handle.Value.Trim() == "edit")
|
|
|
{
|
|
|
CargoRightTransferEdit();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
CargoRightTransfer();
|
|
|
}
|
|
|
this.h_post.Value = "";
|
|
|
}
|
|
|
}
|
|
|
else if (this.h_post.Value.Trim() == "4")
|
|
|
{
|
|
|
//仓储费率
|
|
|
if (!recvJSON_2.Trim().Equals(""))
|
|
|
{
|
|
|
SaveRateAction();
|
|
|
recvJSON_2 = "";
|
|
|
this.recvContainer_2.Value = "";
|
|
|
this.h_post.Value = "";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//
|
|
|
if (this.h_Handle.Value.Trim() == "edit")
|
|
|
{//获取出库单的信息
|
|
|
//DoWmsOutEdit(strSearch);
|
|
|
h_Mode.Value = "1";
|
|
|
getHJ();
|
|
|
//
|
|
|
#region 权限可视范围
|
|
|
RangeDA RangeDA = new RangeDA();
|
|
|
this.hdRangeV.Value = RangeDA.GetVISIBLERANGE(strUserID.Trim(), "modWmsOutList");
|
|
|
this.hdRangeO.Value = RangeDA.GetOPERATERANGE(strUserID.Trim(), "modWmsOutList");
|
|
|
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.GetWmsOutListCompany(strCompanyID, this.h_outgid.Value.Trim());
|
|
|
if (alt == "")
|
|
|
{
|
|
|
setIsDisabled(true);
|
|
|
}
|
|
|
}
|
|
|
else if (this.hdRangeO.Value.Trim().Equals("2"))//部门
|
|
|
{
|
|
|
alt = RangeDA.GetWmsOutListDEPT(strDeptName, this.h_outgid.Value.Trim(), strCompanyID, strUserID);
|
|
|
if (alt == "")
|
|
|
{
|
|
|
setIsDisabled(true);
|
|
|
}
|
|
|
}
|
|
|
else if (this.hdRangeO.Value.Trim().Equals("3"))//个人
|
|
|
{
|
|
|
alt = RangeDA.GetWmsOutListPerson(strUserID, this.h_outgid.Value.Trim(), strCompanyID);
|
|
|
if (alt == "")
|
|
|
{
|
|
|
setIsDisabled(true);
|
|
|
}
|
|
|
}
|
|
|
else if (this.hdRangeO.Value.Trim().Equals("4"))//无
|
|
|
{
|
|
|
setIsDisabled(true);
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
//加载下拉框
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initcomboOutCustomer();initComboTRUCKNAME();initComboARCLIENT();</script>");
|
|
|
}
|
|
|
|
|
|
#region 将页面post获取的仓储费率信息保存或更新“仓储费率明细表”wms_rate_detail,并返回操作结果
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的仓储费率信息保存或更新“仓储费率明细表”wms_rate_detail,并返回操作结果
|
|
|
/// </summary>
|
|
|
private void SaveRateAction()
|
|
|
{
|
|
|
IList<WmsRateDetailEntity> rateEntities = new List<WmsRateDetailEntity>();
|
|
|
|
|
|
if (!recvJSON_2.Trim().Equals(""))
|
|
|
{
|
|
|
rateEntities = ResolverecvJSON_2(recvJSON_2.Trim(), rateEntities);
|
|
|
this.recvContainer_2.Value = "";
|
|
|
}
|
|
|
|
|
|
WmsRateDetailDA rateDA = new WmsRateDetailDA();
|
|
|
foreach (WmsRateDetailEntity rateentity in rateEntities)
|
|
|
{
|
|
|
string strwhere = String.Format(" GID='{0}' ", rateentity.GID);
|
|
|
int strExists = rateDA.GetRecordCount(strwhere);
|
|
|
if (strExists == 1)
|
|
|
{
|
|
|
int iRecvState = rateDA.Update(rateentity, strShowName, this.txt_outbsno.Value.Trim());
|
|
|
}
|
|
|
else if (strExists == 0)
|
|
|
{
|
|
|
int iRecvState = rateDA.Add(rateentity, strShowName, this.txt_outbsno.Value.Trim());
|
|
|
}
|
|
|
//更新出库wms_out、wms_out的仓储费???
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 将页面post获取的仓储费率明细读入到仓储费率明细表实体类wms_rate_detail中
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的仓储费率明细读入到仓储费率明细表实体类wms_rate_detail中
|
|
|
/// </summary>
|
|
|
/// <param name="tempJSON"></param>
|
|
|
/// <param name="tempFeeEntities"></param>
|
|
|
private IList<WmsRateDetailEntity> ResolverecvJSON_2(string tempJSON, IList<WmsRateDetailEntity> 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)
|
|
|
{
|
|
|
WmsRateDetailEntity RateEntity = new WmsRateDetailEntity();
|
|
|
|
|
|
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("\"", "").Trim();
|
|
|
break;
|
|
|
case "cus":
|
|
|
RateEntity.CUSTOMERNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "fgrade":
|
|
|
RateEntity.FEEGRADE = int.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "feetype":
|
|
|
RateEntity.FEETYPE = int.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "startbillingdate":
|
|
|
RateEntity.STARTBILLINGDATE = DateTime.Parse(strArg[1].ToString().Replace("\"", "") == "" ? "0001-01-01" : strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "endbillingdate":
|
|
|
RateEntity.ENDBILLINGDATE = DateTime.Parse(strArg[1].ToString().Replace("\"", "") == "" ? "0001-01-01" : strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "fscale":
|
|
|
RateEntity.FEESCALE = int.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "funit":
|
|
|
RateEntity.FEEUNIT = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "fprice":
|
|
|
RateEntity.FEEPRICE = decimal.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "goodspfsl":
|
|
|
RateEntity.GOODSPFSL = decimal.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "outfee":
|
|
|
RateEntity.OUTFEE = decimal.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "remark":
|
|
|
RateEntity.REMARK = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "associatedno":
|
|
|
RateEntity.ASSOCIATEDNO = strArg[1].ToString().Replace("\"", "");
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
RateEntity.CREATEUSER = this.strUserID;
|
|
|
RateEntity.MODIFIEDUSER = this.strUserID;
|
|
|
tempRateEntities.Add(RateEntity);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return tempRateEntities;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 是否允许改
|
|
|
/// <summary>
|
|
|
/// 是否允许改
|
|
|
/// </summary>
|
|
|
/// <param name="strSearch"></param>
|
|
|
public void setIsDisabled(bool isdisabled)
|
|
|
{
|
|
|
this.h_isdisabled.Value = isdisabled.ToString();
|
|
|
//
|
|
|
Div7.Disabled = isdisabled;
|
|
|
Div8.Disabled = isdisabled;
|
|
|
btn_Out.Disabled = isdisabled;
|
|
|
ck_jsfee.Disabled = isdisabled;
|
|
|
mygrid_container_wmsin.Disabled = isdisabled;
|
|
|
btislock.Disabled = isdisabled;
|
|
|
btnotislock.Disabled = isdisabled;
|
|
|
//
|
|
|
//货主名称
|
|
|
sel_customer.Visible = false;
|
|
|
txt_customer.Visible = true;
|
|
|
txt_customer.Disabled = true;
|
|
|
//提单号
|
|
|
txt_blno.Disabled = true;
|
|
|
//仓库名称
|
|
|
sel_storage.Visible = false;
|
|
|
txt_storage.Visible = true;
|
|
|
txt_storage.Disabled = true;
|
|
|
//出库单号
|
|
|
txt_outbsno.Disabled = true;
|
|
|
//品名
|
|
|
sel_goods.Visible = false;
|
|
|
txt_goods.Visible = true;
|
|
|
txt_goods.Disabled = true;
|
|
|
//牌号
|
|
|
txt_goodsmodel.Disabled = true;
|
|
|
//
|
|
|
//应收客户
|
|
|
ddlARCLIENT.Disabled = isdisabled;
|
|
|
//应付客户
|
|
|
ddlTRUCKNAME.Disabled = isdisabled;
|
|
|
//出库日期
|
|
|
txt_outdate.Disabled = isdisabled;
|
|
|
//结束计费日期
|
|
|
txt_oldcustFeeDate.Disabled = isdisabled;
|
|
|
//转移对象
|
|
|
sel_outcustomer.Disabled = isdisabled;
|
|
|
//备案清单号
|
|
|
txt_customno.Disabled = isdisabled;
|
|
|
//重量
|
|
|
//txt_goodspfsl.Disabled = isdisabled;
|
|
|
//件数
|
|
|
//txt_packnum.Disabled = isdisabled;
|
|
|
//审批单号
|
|
|
txt_inspectionno.Disabled = isdisabled;
|
|
|
//
|
|
|
txt_totalno.Disabled = isdisabled;
|
|
|
//备注
|
|
|
txt_remark.Disabled = isdisabled;
|
|
|
//
|
|
|
//this.h_customer.Value = ds.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
|
|
|
//this.h_outdate.Value = DateTime.Parse(ds.Tables[0].Rows[0]["DODATE"].ToString().Trim()).ToString("yyyy-MM-dd");
|
|
|
//this.txt_outdate.Disabled = isdisabled;
|
|
|
//this.h_storage.Value = ds.Tables[0].Rows[0]["STORAGENAME"].ToString().Trim();
|
|
|
//this.h_goods.Value = ds.Tables[0].Rows[0]["GOODSNAME"].ToString().Trim();
|
|
|
//this.h_goodsmodel.Value = ds.Tables[0].Rows[0]["GOODSMODEL"].ToString().Trim();
|
|
|
//this.txt_goodsmodel.Disabled = isdisabled;
|
|
|
//this.h_storage.Value = ds.Tables[0].Rows[0]["STORAGENAME"].ToString().Trim();
|
|
|
//this.h_remark.Value = ds.Tables[0].Rows[0]["REMARK"].ToString().Trim();
|
|
|
//this.txt_remark.Disabled = isdisabled;
|
|
|
//this.h_bsno.Value = ds.Tables[0].Rows[0]["ASSOCIATEDNO"].ToString().Trim();
|
|
|
//this.h_opseaibsno.Value = h_bsno.Value;
|
|
|
//this.txt_blno.Disabled = isdisabled;
|
|
|
//this.h_outcustomer.Value = ds.Tables[0].Rows[0]["CLIENTNAMEOLD"].ToString().Trim();
|
|
|
//this.h_newcust.Value = this.h_outcustomer.Value;
|
|
|
//this.sel_outcustomer.Disabled = isdisabled;
|
|
|
//this.hd_comboARCLIENT.Value = ds.Tables[0].Rows[0]["ARCLIENT"].ToString().Trim();
|
|
|
//this.hd_comboTRUCKNAME.Value = ds.Tables[0].Rows[0]["TRUCKNAME"].ToString().Trim();
|
|
|
//this.txt_customno.Disabled = isdisabled;
|
|
|
//this.txt_inspectionno.Disabled = isdisabled;
|
|
|
//this.txt_oldcustFeeDate.Disabled = isdisabled;
|
|
|
//this.txt_outdate.Disabled = isdisabled;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 统计合计数
|
|
|
/// <summary>
|
|
|
/// 统计合计数
|
|
|
/// </summary>
|
|
|
/// <param name="strSearch"></param>
|
|
|
public void getHJ()
|
|
|
{
|
|
|
if (this.h_outgid.Value.Trim() != "")
|
|
|
{
|
|
|
this.h_outbsno.Value = T_ALL_DA.GetStrSQL("bsno", "select top 1 bsno from wms_out where gid='" + this.h_outgid.Value.Trim() + "'");
|
|
|
txt_outbsno.Value = this.h_outbsno.Value;
|
|
|
this.h_wmsoutbsno.Value = this.h_outbsno.Value;
|
|
|
//
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL("select GOODSPACKPFSL=isnull(sum(GOODSPACKPFSL),0),GOODSPFSL=isnull(sum(GOODSPFSL),0),ARFEE=isnull(sum(ARFEE),0),APFEE=isnull(sum(APFEE),0),GOODSOUTFEE=isnull(sum(GOODSOUTFEE),0),GOODSOUTFEEAP=isnull(sum(GOODSOUTFEEAP),0) from wms_out_detail where OUTBSNO='" + this.h_outbsno.Value.Trim() + "'");
|
|
|
if (ds != null)
|
|
|
{
|
|
|
//件数
|
|
|
this.dvGOODSPACKVal.InnerText = ds.Tables[0].Rows[0]["GOODSPACKPFSL"].ToString().Trim();
|
|
|
//this.txt_packnum.Value = ds.Tables[0].Rows[0]["GOODSPACKPFSL"].ToString().Trim();
|
|
|
this.h_packnum.Value = ds.Tables[0].Rows[0]["GOODSPACKPFSL"].ToString().Trim();
|
|
|
//计费数量
|
|
|
this.dvProfitTotalVal.InnerText = ds.Tables[0].Rows[0]["GOODSPFSL"].ToString().Trim();
|
|
|
this.h_outnum.Value = ds.Tables[0].Rows[0]["GOODSPFSL"].ToString().Trim();
|
|
|
this.h_goodspfsl.Value = this.h_outnum.Value.Trim();
|
|
|
//this.txt_goodspfsl.Value = this.h_outnum.Value.Trim();
|
|
|
//出库应收
|
|
|
this.dvRecvTotalVal.InnerText = ds.Tables[0].Rows[0]["ARFEE"].ToString().Trim();
|
|
|
//出库应付
|
|
|
this.dvPaySumVal.InnerText = ds.Tables[0].Rows[0]["APFEE"].ToString().Trim();
|
|
|
//仓储费应收
|
|
|
this.dvRVal.InnerText = ds.Tables[0].Rows[0]["GOODSOUTFEE"].ToString().Trim();
|
|
|
this.h_outfee.Value = ds.Tables[0].Rows[0]["GOODSOUTFEE"].ToString().Trim();
|
|
|
//仓储费应付
|
|
|
this.dvPVal.InnerText = ds.Tables[0].Rows[0]["GOODSOUTFEEAP"].ToString().Trim();
|
|
|
}
|
|
|
//
|
|
|
ds = T_ALL_DA.GetAllSQL("select *,convert(char(10),DODATE,20) as DODATE2,convert(char(10),OLDCUSTFEEDATE,20) as OLDCUSTFEEDATE2 from wms_out where gid='" + this.h_outgid.Value.Trim() + "'");
|
|
|
if (ds != null)
|
|
|
{
|
|
|
this.h_customer.Value = ds.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
|
|
|
this.txt_customer.Value = this.h_customer.Value;
|
|
|
this.h_outdate.Value = DateTime.Parse(ds.Tables[0].Rows[0]["DODATE"].ToString().Trim()).ToString("yyyy-MM-dd");
|
|
|
this.txt_outdate.Value = h_outdate.Value;
|
|
|
this.h_storage.Value = ds.Tables[0].Rows[0]["STORAGENAME"].ToString().Trim();
|
|
|
this.txt_storage.Value = this.h_storage.Value;
|
|
|
this.h_goods.Value = ds.Tables[0].Rows[0]["GOODSNAME"].ToString().Trim();
|
|
|
this.txt_goods.Value = this.h_goods.Value;
|
|
|
this.h_goodsmodel.Value = ds.Tables[0].Rows[0]["GOODSMODEL"].ToString().Trim();
|
|
|
this.txt_goodsmodel.Value = h_goodsmodel.Value;
|
|
|
this.h_storage.Value = ds.Tables[0].Rows[0]["STORAGENAME"].ToString().Trim();
|
|
|
this.h_totalno.Value = ds.Tables[0].Rows[0]["TOTALNO"].ToString().Trim();
|
|
|
this.txt_totalno.Value = this.h_totalno.Value.Trim();
|
|
|
this.h_remark.Value = ds.Tables[0].Rows[0]["REMARK"].ToString().Trim();
|
|
|
this.txt_remark.Value = this.h_remark.Value.Trim();
|
|
|
this.h_bsno.Value = ds.Tables[0].Rows[0]["ASSOCIATEDNO"].ToString().Trim();
|
|
|
this.h_opseaibsno.Value = h_bsno.Value;
|
|
|
if (this.h_opseaibsno.Value.Trim() == "")
|
|
|
{
|
|
|
this.txt_blno.Value = T_ALL_DA.GetStrSQL("BLNO", "select top 1 BLNO from wms where gid in (select inbsno from wms_out_detail where outbsno='" + ds.Tables[0].Rows[0]["bsno"].ToString().Trim() + "')");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.txt_blno.Value = T_ALL_DA.GetStrSQL("MBLNO", "select top 1 MBLNO from VW_Settlement where bsno='" + this.h_opseaibsno.Value.Trim() + "'");
|
|
|
}
|
|
|
this.h_outcustomer.Value = ds.Tables[0].Rows[0]["CLIENTNAMEOLD"].ToString().Trim();
|
|
|
this.h_newcust.Value = this.h_outcustomer.Value;
|
|
|
this.sel_outcustomer.Value = this.h_newcust.Value.Trim();
|
|
|
this.hd_comboARCLIENT.Value = ds.Tables[0].Rows[0]["ARCLIENT"].ToString().Trim();
|
|
|
this.hd_comboTRUCKNAME.Value = ds.Tables[0].Rows[0]["TRUCKNAME"].ToString().Trim();
|
|
|
this.txt_customno.Value = ds.Tables[0].Rows[0]["CUSTOMNO"].ToString().Trim();
|
|
|
this.txt_inspectionno.Value = ds.Tables[0].Rows[0]["INSPECTIONNO"].ToString().Trim();
|
|
|
this.txt_oldcustFeeDate.Value = ds.Tables[0].Rows[0]["OLDCUSTFEEDATE2"].ToString().Trim();
|
|
|
this.txt_outdate.Value = ds.Tables[0].Rows[0]["DODATE2"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 导出Excel
|
|
|
protected void btExcel1_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
//setExcelReport();
|
|
|
setExcelReport2();
|
|
|
}
|
|
|
|
|
|
protected void setExcelReport2()
|
|
|
{
|
|
|
if (this.hdSQL.Value.Trim() != "")
|
|
|
{
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(this.hdSQL.Value.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
ExcelDA ExcelDA = new EntityDA.ExcelDA();
|
|
|
MemoryStream ms = ExcelDA.RenderToExcel(DS.Tables[0], this.hdNAMES.Value.Trim());
|
|
|
ExcelDA.RenderToBrowser(ms, Context, "report.xls");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
protected void setExcelReport()
|
|
|
{
|
|
|
StringWriter sw = new StringWriter();
|
|
|
string sSQL = "";
|
|
|
//sw.WriteLine("结算单位\t委托编号\t主提单号\t分提单号\t船名\t航次\tETD\t目的港\t揽货人\t应收RMB\t实收RMB\t应收USD\t实收USD\t余额");
|
|
|
sw.WriteLine(this.hdNAMES.Value.Trim());
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(this.hdSQL.Value.Trim());
|
|
|
if (DS != null)
|
|
|
{
|
|
|
foreach (DataTable myTable in DS.Tables)
|
|
|
{
|
|
|
foreach (DataRow myRow in myTable.Rows)//遍历表
|
|
|
{
|
|
|
sSQL = "";
|
|
|
for (int i = 0; i < myTable.Columns.Count; i++)
|
|
|
{
|
|
|
if (sSQL.Trim() != "")
|
|
|
{
|
|
|
sSQL += "\t";
|
|
|
}
|
|
|
if (myRow[i].ToString() == null || myRow[i].ToString() == "")
|
|
|
{
|
|
|
sSQL += "";
|
|
|
if (sSQL.Trim() == "")
|
|
|
{
|
|
|
sSQL += "\t";
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
string ls = myRow[i].ToString().Trim();
|
|
|
if (i == 17)
|
|
|
{
|
|
|
ls = ls.Replace(" ", ",");
|
|
|
ls = ls.Replace("\r\n", "。");
|
|
|
}
|
|
|
sSQL += ls.Trim();
|
|
|
//sSQL += myRow[i].ToString();
|
|
|
}
|
|
|
}
|
|
|
sw.WriteLine(sSQL);
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
sw.Close();
|
|
|
switch ("MUEXCEL")
|
|
|
{
|
|
|
case "MUEXCEL":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xls");
|
|
|
Response.ContentType = "application/ms-excel";
|
|
|
break;
|
|
|
case "MUTEXT":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.txt");
|
|
|
Response.ContentType = "application/txt";
|
|
|
break;
|
|
|
case "MUWORD":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.doc");
|
|
|
Response.ContentType = "application/ms-word";
|
|
|
break;
|
|
|
case "MUPDF":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf");
|
|
|
Response.ContentType = "application/pdf";
|
|
|
break;
|
|
|
case "MUXML":
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xml");
|
|
|
Response.ContentType = "application/xml";
|
|
|
break;
|
|
|
}
|
|
|
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
|
|
|
Response.Write(sw);
|
|
|
Response.End();
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 读取出库单的信息 WmsOutEdit
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <param name="strSearch"></param>
|
|
|
private void DoWmsOutEdit(string strSearch)
|
|
|
{
|
|
|
if (strSearch != null)
|
|
|
{
|
|
|
if (!strSearch.Trim().Equals(""))
|
|
|
{
|
|
|
string tempSearch = strSearch;
|
|
|
tempSearch = tempSearch.Replace("{", "");
|
|
|
tempSearch = tempSearch.Replace("}", "");
|
|
|
tempSearch = tempSearch.Replace("[", "");
|
|
|
tempSearch = tempSearch.Replace("]", "");
|
|
|
|
|
|
string[] searchArg = tempSearch.Split(new char[] { ',' });
|
|
|
|
|
|
for (int i = 0; i < searchArg.Length; i++)
|
|
|
{
|
|
|
string[] strArg = searchArg[i].Split(new char[] { ':' });
|
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
{
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
{
|
|
|
case "id":
|
|
|
this.h_outgid.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
break;
|
|
|
case "bsno":
|
|
|
this.h_outbsno.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
txt_outbsno.Value = this.h_outbsno.Value;
|
|
|
this.h_wmsoutbsno.Value = this.h_outbsno.Value;
|
|
|
break;
|
|
|
case "cust":
|
|
|
h_customer.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
h_outcustomer.Value = h_customer.Value;
|
|
|
break;
|
|
|
case "outdate":
|
|
|
string dt =strArg[1].ToString().Replace("\"", "");
|
|
|
//h_outdate.Value = dt.Substring(0,dt.IndexOf(" "));
|
|
|
h_outdate.Value = dt;
|
|
|
txt_outdate.Value = dt;
|
|
|
break;
|
|
|
case "storage":
|
|
|
h_storage.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
break;
|
|
|
case "goodsname":
|
|
|
h_goods.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
case "goodsmodel":
|
|
|
h_goodsmodel.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
txt_goodsmodel.Value = h_goodsmodel.Value;
|
|
|
break;
|
|
|
case "outnum":
|
|
|
h_outnum.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
//txt_goodspfsl.Value = h_outnum.Value;
|
|
|
break;
|
|
|
case "outfee":
|
|
|
h_outfee.Value =strArg[1].ToString().Replace("\"", "");
|
|
|
break;
|
|
|
case "truckno":
|
|
|
//
|
|
|
string ls = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
//ls = ls.Replace(" ", " ");
|
|
|
//ls = ls.Replace("\r\n", " ");
|
|
|
//
|
|
|
h_truckno.Value = ls;
|
|
|
break;
|
|
|
case "totalno":
|
|
|
h_totalno.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
txt_totalno.Value = h_totalno.Value;
|
|
|
break;
|
|
|
case "remark":
|
|
|
h_remark.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
txt_remark.Value = h_remark.Value;
|
|
|
break;
|
|
|
case "opseaibsno":
|
|
|
h_bsno.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
this.h_opseaibsno.Value = h_bsno.Value;
|
|
|
this.txt_blno.Value = T_ALL_DA.GetStrSQL("MBLNO", "select top 1 MBLNO from VW_Settlement where bsno='" + this.h_opseaibsno.Value.Trim() + "'");
|
|
|
break;
|
|
|
case "packnum":
|
|
|
//txt_packnum.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
h_packnum.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
case "newcust":
|
|
|
this.h_newcust.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (h_remark.Value.Equals("货权转移") && !h_newcust.Value.Equals(""))
|
|
|
{
|
|
|
this.h_IsSetRate.Value = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
this.h_IsSetRate.Value = "0";
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 将页面post获取的费用信息保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain,并返回操作结果
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的费用信息保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain,并返回操作结果
|
|
|
/// </summary>
|
|
|
private void SaveFeeAction()
|
|
|
{
|
|
|
IList<FeeEntity> feeEntities = new List<FeeEntity>();
|
|
|
|
|
|
if (!recvJSON.Trim().Equals("") && !recvJSON.Trim().Equals("null") )
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
feeEntities = ResolveFeeJSON(recvJSON.Trim(), feeEntities);
|
|
|
recvContainer.Value = "";
|
|
|
}
|
|
|
|
|
|
if (!payJSON.Trim().Equals("") && !payJSON.Trim().Equals("null"))
|
|
|
{ //将应付费用信息从前台页面写入费用实体类feeEntities
|
|
|
feeEntities = ResolveFeeJSON(payJSON.Trim(), feeEntities);
|
|
|
payContainer.Value = "";
|
|
|
}
|
|
|
|
|
|
FeeDA feeDA = new FeeDA();
|
|
|
//如果是当前操作人权限范围只能查看应收或者应付时,单独更新费用利润
|
|
|
if (!ValidateUserFeeAuthority(1) || !ValidateUserFeeAuthority(2))
|
|
|
{ //将页面post获取的费用信息保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain,并返回操作结果
|
|
|
int iRecvState = feeDA.DoFee(feeEntities, strSeaBSNO, strUserID);
|
|
|
|
|
|
if (iRecvState == 1)
|
|
|
{
|
|
|
gainContainer.Value = "";
|
|
|
if (Session[strCacheName] != null)
|
|
|
{
|
|
|
Session.Remove(strCacheName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
FeeProfitEntity feeProfitEntity = new FeeProfitEntity();
|
|
|
//将页面post获取的利润值读入到利润实体类中
|
|
|
feeProfitEntity = GetRequestProfit();
|
|
|
|
|
|
int iRecvState = feeDA.DoFee(feeEntities, feeProfitEntity, strSeaBSNO);
|
|
|
|
|
|
if (iRecvState == 1)
|
|
|
{
|
|
|
gainContainer.Value = "";
|
|
|
if (Session[strCacheName] != null)
|
|
|
{
|
|
|
Session.Remove(strCacheName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
h_post.Value = "";//请求状态清空
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 正数四舍五入,负数是五舍六入。(个人以为第一种方法合适处置货泉盘算)
|
|
|
/// </summary>
|
|
|
/// <param name="value">四舍五入的数</param>
|
|
|
/// <param name="decimals">表示要保存的小数点后为数</param>
|
|
|
/// <returns></returns>
|
|
|
private Decimal Round(Decimal value, int decimals, string money)
|
|
|
{
|
|
|
if (value < 0)
|
|
|
{
|
|
|
return Math.Round(value + (Decimal)(5 / Math.Pow(10, decimals + 1)), decimals, MidpointRounding.AwayFromZero);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return Math.Round(value, decimals, MidpointRounding.AwayFromZero);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 正负数都四舍五入(适合数据统计的显示)
|
|
|
/// </summary>
|
|
|
/// <param name="d">四舍五入的数</param>
|
|
|
/// <param name="i">表示要保存的小数点后为数</param>
|
|
|
/// <returns></returns>
|
|
|
private Decimal Round(Decimal d, int i)
|
|
|
{
|
|
|
if (d >= 0)
|
|
|
{
|
|
|
d += (Decimal) (5 * Math.Pow(10, -(i + 1)));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
d += (Decimal) (- 5 * Math.Pow(10, -(i + 1)));
|
|
|
}
|
|
|
string str = d.ToString();
|
|
|
string[] strs = str.Split('.');
|
|
|
int idot = str.IndexOf('.');
|
|
|
string prestr = strs[0];
|
|
|
string poststr = strs[1];
|
|
|
if (poststr.Length > i)
|
|
|
{
|
|
|
poststr = str.Substring(idot + 1, i);
|
|
|
}
|
|
|
string strd = prestr + "." + poststr;
|
|
|
d = Decimal.Parse(strd);
|
|
|
return d;
|
|
|
}
|
|
|
|
|
|
#region 生成出库单 SaveWoOutAction
|
|
|
/// <summary>
|
|
|
/// 生成出库单
|
|
|
/// </summary>
|
|
|
private int SaveWoOutAction()
|
|
|
{
|
|
|
int iState = 0;
|
|
|
int result = 0;
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
Decimal totaloutfee = 0;//应收出库单的仓储费
|
|
|
Decimal totaloutfeeap = 0;//应付出库单的仓储费
|
|
|
int feedays = 0;//应收仓储天数
|
|
|
int feedaysap = 0;//应付仓储天数
|
|
|
Decimal sumfee = 0;//应收出库明细的仓储费
|
|
|
Decimal sumfeeap = 0;//应付出库明细的仓储费
|
|
|
//
|
|
|
//int prescale = 0;
|
|
|
//int nowscale = 0;
|
|
|
//int nowgrade = 0;
|
|
|
//Decimal price = 0;
|
|
|
//Decimal gradefee = 0;
|
|
|
string newGID = "";
|
|
|
string bsno = "";
|
|
|
|
|
|
//出库单信息
|
|
|
WmsOutDA WmsOutDA = new WmsOutDA();
|
|
|
WmsOutEntity WmsOutEntity = new WmsOutEntity();
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutEntity = ResolveWoJSON(WoJSON.Trim(), WmsOutEntity);
|
|
|
WoContainer.Value = "";
|
|
|
}
|
|
|
//出库单明细信息
|
|
|
WmsOutDetailDA WmsOutDetailDA = new WmsOutDetailDA();
|
|
|
IList<WmsOutDetailEntity> WmsOutDetailEntitys = new List<WmsOutDetailEntity>();
|
|
|
if (!WoDetailJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutDetailEntitys = ResolveWoDetailJSON(WoDetailJSON.Trim(), WmsOutDetailEntitys);
|
|
|
this.WoDetailContainer.Value = "";
|
|
|
}
|
|
|
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
#region 生成出库单并计算费用
|
|
|
#region 保存出库单wms_out 出库单明细wms_out_detail
|
|
|
//保存出库单wms_out
|
|
|
string ls = WmsOutEntity.TRUCKNO.ToString().Trim();
|
|
|
ls = ls.Replace("??"," ");
|
|
|
ls = ls.Replace("!!","\r\n");
|
|
|
//
|
|
|
Sqlstr = String.Format("insert into wms_out(GID,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSPFSL,REMARK,CREATEUSER,CREATETIME,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,INSPECTIONNO,CUSTOMNO,CLIENTNAMEOLD,OLDCUSTFEEDATE,TRUCKNAME,ARCLIENT,INGIDNEW,CHARGEUNIT,TOTALNO,CORPID)"
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',getdate(),'{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','','CBM','{19}','{20}')"
|
|
|
, WmsOutEntity.GID, WmsOutEntity.BSNO, WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.GOODSNAME, WmsOutEntity.GOODSMODEL, WmsOutEntity.GOODSPFSL, WmsOutEntity.REMARK, strUserID, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL, WmsOutEntity.INSPECTIONNO, WmsOutEntity.CUSTOMNO, WmsOutEntity.CLIENTNAMEOLD, WmsOutEntity.OLDCUSTFEEDATE, WmsOutEntity.TRUCKNAME, WmsOutEntity.ARCLIENT, WmsOutEntity.TOTALNO, strCompanyID);
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -1;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//保存出库单明细wms_out_detail
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
{
|
|
|
if (DateTime.Parse(WmsOutDetailEntity.DODATE.ToString("yyyy-MM-dd")) > DateTime.Parse(WmsOutEntity.DODATE.ToString("yyyy-MM-dd")))
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -12;
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>alert('出库日期不能小于入库日期!');</script>");
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//
|
|
|
newGID = Guid.NewGuid().ToString();
|
|
|
WmsOutDetailEntity.GID = newGID;
|
|
|
WmsOutDetailEntity.OUTBSNO = WmsOutEntity.BSNO;
|
|
|
Decimal outnums = Decimal.Parse(WmsOutDetailEntity.GOODSPFSL.ToString());//出库量
|
|
|
|
|
|
#region 计算仓储费
|
|
|
// <param name="sqlTran">事务</param>
|
|
|
// <param name="strSTARTBILLINGDATE">开始计费日期</param>
|
|
|
// <param name="strOLDCUSTFEEDATE">上家承担仓储期限</param>
|
|
|
// <param name="strINBSNO">出库明细关联的入库单wms或wms_in的BSNO</param>
|
|
|
// <param name="strCUSTOMERNAME">出库主表的客户名称</param>
|
|
|
// <param name="outnums">出库量</param>
|
|
|
// <param name="strASSOCIATEDNO">关联wms_out_detail的GID</param>
|
|
|
// <param name="strFEETYPE">区别费用收、付类型</param>
|
|
|
|
|
|
//计算应收仓储费
|
|
|
string getstr = WmsOutDetailDA.getWmsRate(sqlTran, WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim(), WmsOutDetailEntity.INBSNO.ToString().Trim(), WmsOutEntity.CUSTOMERNAME.ToString().Trim(), outnums, WmsOutDetailEntity.GID.ToString(), 1, strUserID, strShowName, this.txt_outbsno.Value.Trim(), this.ck_jsfee.Checked, false);
|
|
|
|
|
|
string[] strls = getstr.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
sumfee = Decimal.Parse(strls[0].ToString());
|
|
|
totaloutfee += sumfee;//仓储费合计
|
|
|
feedays += int.Parse(strls[1].ToString());
|
|
|
|
|
|
//计算应付仓储费
|
|
|
getstr = WmsOutDetailDA.getWmsRate(sqlTran, WmsOutDetailEntity.STARTBILLINGDATEAP.ToString().Trim(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim(), WmsOutDetailEntity.INBSNO.ToString().Trim(), WmsOutEntity.CUSTOMERNAME.ToString().Trim(), outnums, WmsOutDetailEntity.GID.ToString(), 2, strUserID, strShowName, this.txt_outbsno.Value.Trim(), this.ck_jsfee.Checked, false);
|
|
|
|
|
|
strls = getstr.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
sumfeeap = Decimal.Parse(strls[0].ToString());
|
|
|
totaloutfeeap += sumfeeap;//仓储费合计
|
|
|
feedaysap += int.Parse(strls[1].ToString());
|
|
|
//
|
|
|
#endregion
|
|
|
|
|
|
//保存wms_out_detail
|
|
|
WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = (sumfee == 0 ? 0 : decimal.Parse(Round(sumfee, 2, "").ToString()));
|
|
|
WmsOutDetailEntity.GOODSOUTFEEAP = (sumfeeap == 0 ? 0 : decimal.Parse(Round(sumfeeap, 2, "").ToString()));
|
|
|
WmsOutDetailEntity.ENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim().IndexOf("0001") > -1 ? DateTime.Parse("0001-01-01 00:00:00") : WmsOutEntity.OLDCUSTFEEDATE;//结束计费日期
|
|
|
WmsOutDetailEntity.ENDBILLINGDATEAP = WmsOutDetailEntity.STARTBILLINGDATEAP.ToString().Trim().IndexOf("0001") > -1 ? DateTime.Parse("0001-01-01 00:00:00") : WmsOutEntity.OLDCUSTFEEDATE;//结束计费日期
|
|
|
WmsOutDetailEntity.FEEDAYS = feedays;//计费天数iFEEDAYS
|
|
|
WmsOutDetailEntity.FEEDAYSAP = feedaysap;//计费天数iFEEDAYS
|
|
|
//
|
|
|
//bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
#region 提取规则编号 getCodeRuleWmsOutDetail
|
|
|
// <summary>
|
|
|
// 提取规则编号
|
|
|
// </summary>
|
|
|
// <param name="strRULENAME">规则项目名称</param>
|
|
|
// <param name="strfield">需要加规则的字段</param>
|
|
|
// <returns></returns>
|
|
|
//protected String getCodeRuleWmsOutDetail(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 *,getdate() DODATE from code_rule where RULENAME='出库明细单号' 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("出库明细单号", "BSNO");
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
//return "";
|
|
|
bsno = "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().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='" + strUserID + "')");
|
|
|
}
|
|
|
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='" + strUserID + "')");
|
|
|
}
|
|
|
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;
|
|
|
//
|
|
|
string strSQL = "select top 1 BSNO from [wms_out_detail] where BSNO like '" + strCONTENT.Trim() + "%' order by BSNO DESC";
|
|
|
DataSet ds1 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds1 != null)
|
|
|
{
|
|
|
if (ds1.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
strRULENOLENGTH = ds1.Tables[0].Rows[0]["BSNO"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
bsno = strCONTENT;
|
|
|
//return strCONTENT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// return "";
|
|
|
//}
|
|
|
#endregion
|
|
|
//
|
|
|
WmsOutDetailEntity.BSNO = bsno;
|
|
|
WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
//
|
|
|
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
|
|
|
ls = ls.Replace("??", " ");
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
//
|
|
|
string strSTARTBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "'" + WmsOutDetailEntity.STARTBILLINGDATE.ToString() + "',";
|
|
|
string strSTARTBILLINGDATE_name = strSTARTBILLINGDATE.Equals("") ? "" : "STARTBILLINGDATE,";
|
|
|
//
|
|
|
string strENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "'" + WmsOutDetailEntity.DODATE.ToString() + "',";//如果开始计费日期为空,则结束计费日期也为空,否则为出库日期。
|
|
|
string strENDBILLINGDATE_name = strENDBILLINGDATE.Equals("") ? "" : "ENDBILLINGDATE,";
|
|
|
//
|
|
|
Sqlstr = String.Format("insert into wms_out_detail (GID,INBSNO,OUTBSNO,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSPFSL,GOODSOUTFEE,CREATEUSER,CREATETIME,REMARK,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,GOODSOUTFEEAP,ARFEE,APFEE,CLIENTNAMEOLD,OLDCUSTFEEDATE,{21}{23}FEEDAYS,GOODSSTANDARD,GOODSGRADE,GOODSSLICE,CHARGEUNIT,CORPID) "
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate(),'{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}',{22}{24}'{25}','{26}','{27}','{28}','CBM','{29}')"
|
|
|
, WmsOutDetailEntity.GID, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.OUTBSNO, WmsOutDetailEntity.BSNO, WmsOutDetailEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutDetailEntity.STORAGENAME, WmsOutDetailEntity.GOODSNAME,WmsOutDetailEntity.GOODSMODEL, WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.GOODSOUTFEE, strUserID, WmsOutDetailEntity.REMARK, ls, WmsOutDetailEntity.ASSOCIATEDNO, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.GOODSOUTFEEAP, WmsOutDetailEntity.ARFEE, WmsOutDetailEntity.APFEE,
|
|
|
WmsOutDetailEntity.CLIENTNAMEOLD, this.txt_oldcustFeeDate.Value.Trim(), strSTARTBILLINGDATE_name, strSTARTBILLINGDATE, strENDBILLINGDATE_name, strENDBILLINGDATE, WmsOutDetailEntity.FEEDAYS, WmsOutDetailEntity.GOODSSTANDARD, WmsOutDetailEntity.GOODSGRADE, WmsOutDetailEntity.GOODSSLICE, strCompanyID);
|
|
|
//
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -5;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//修改入库单wms_in
|
|
|
Sqlstr = String.Format("update wms_in set GOODSSTOCK=GOODSSTOCK-{0},GOODSPACKSTOCK=GOODSPACKSTOCK-{1} where ISDELETE=0 and GID='{2}' ", WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO);
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//修改入库单wms
|
|
|
Sqlstr = String.Format("update wms set GOODSSTOCK=GOODSSTOCK-{0},GOODSPACKSTOCK=GOODSPACKSTOCK-{1} where ISDELETE=0 and gid=(select top 1 ASSOCIATEDNO from wms_in where gid='{2}') ", WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO);
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//}
|
|
|
//else if (feedays < 0 && !WmsOutDetailEntity.CUSTOMERNAMEPARENT.Equals(null) && !WmsOutDetailEntity.CUSTOMERNAMEPARENT.Equals("") && WmsOutDetailEntity.CUSTOMERNAMEPARENT != WmsOutDetailEntity.CUSTOMERNAME)
|
|
|
//{
|
|
|
// //重算原货主仓储费
|
|
|
// SetOutPWmsFee(WmsOutEntity.DODATE.ToString(), WmsOutDetailEntity.CUSTOMERNAME, WmsOutDetailEntity.INBSNO, sqlTran);//.ASSOCIATEDNO
|
|
|
//}
|
|
|
}// end 保存出库明细wms_out_detail
|
|
|
|
|
|
//修改wms_out的出库量、出库件数、应收应付装卸费
|
|
|
string lsSQL = "update wms_out set "
|
|
|
+ "GOODSPFSL=(select isnull(sum(GOODSPFSL),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",GOODSPACKPFSL=(select isnull(sum(GOODSPACKPFSL),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",ARFEE=(select isnull(sum(ARFEE),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",APFEE=(select isnull(sum(APFEE),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ " where ISLOCK=0 and GID='" + WmsOutEntity.GID.ToString().Trim() + "'";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSQL, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -7;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//修改wms_out的仓储费wmsOutEntity.GOODSOUTFEE
|
|
|
h_outfee.Value = totaloutfee.ToString();
|
|
|
WmsOutEntity.GOODSOUTFEE =decimal.Parse( Round(totaloutfee,2,"").ToString());
|
|
|
WmsOutEntity.GOODSOUTFEEAP = decimal.Parse(Round(totaloutfeeap, 2, "").ToString());
|
|
|
|
|
|
Sqlstr = String.Format("update wms_out set GOODSOUTFEE={0},GOODSOUTFEEAP={2} where GID='{1}'", WmsOutEntity.GOODSOUTFEE, WmsOutEntity.GID, WmsOutEntity.GOODSOUTFEEAP);
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -7;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//页面赋值
|
|
|
this.h_wmsoutbsno.Value = WmsOutEntity.BSNO.ToString();
|
|
|
this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL.ToString();
|
|
|
this.h_goodspfsl.Value = WmsOutEntity.GOODSPFSL.ToString();
|
|
|
this.h_totalno.Value = WmsOutEntity.TOTALNO.ToString();
|
|
|
this.h_remark.Value = WmsOutEntity.REMARK.ToString();
|
|
|
|
|
|
txt_outbsno.Value = h_outbsno.Value;
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
string strcustomer = h_customer.Value;
|
|
|
string goods = h_goods.Value;
|
|
|
txt_goodsmodel.Value = h_goodsmodel.Value;
|
|
|
#endregion
|
|
|
this.h_newcust.Value = "";
|
|
|
this.h_IsSetRate.Value = "0";//正常出库,不需要设置费率
|
|
|
//
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
sqlTran.Commit();
|
|
|
//
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParentEdit('" + WmsOutEntity.GID.ToString().Trim() + "','addwmsout',0,'" + WmsOutEntity.ASSOCIATEDNO.ToString().Trim() + "');</script>");
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
result = -10;//有异常,插入失败
|
|
|
sqlTran.Rollback();
|
|
|
result = -11;//插入异常,事务已回滚成功
|
|
|
Clearh();
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 更改出库单 SaveWoOutAction
|
|
|
/// <summary>
|
|
|
/// 更改出库单
|
|
|
/// </summary>
|
|
|
private int SaveWoOutActionEdit()
|
|
|
{
|
|
|
int iState = 0;
|
|
|
int result = 0;
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
Decimal totaloutfee = 0;//出库单的仓储费
|
|
|
Decimal totaloutfeeap = 0;//出库单的仓储费
|
|
|
Decimal sumfee = 0;
|
|
|
Decimal sumfeeap = 0;
|
|
|
//
|
|
|
//int prescale = 0;
|
|
|
//int nowscale = 0;
|
|
|
//int nowgrade = 0;
|
|
|
//Decimal price = 0;
|
|
|
//Decimal gradefee = 0;
|
|
|
//string newGID = "";
|
|
|
string bsno = "";
|
|
|
|
|
|
//出库单信息
|
|
|
WmsOutDA WmsOutDA = new WmsOutDA();
|
|
|
WmsOutEntity WmsOutEntity = new WmsOutEntity();
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutEntity = ResolveWoJSON(WoJSON.Trim(), WmsOutEntity);
|
|
|
WoContainer.Value = "";
|
|
|
}
|
|
|
//出库单明细信息
|
|
|
WmsOutDetailDA WmsOutDetailDA = new WmsOutDetailDA();
|
|
|
IList<WmsOutDetailEntity> WmsOutDetailEntitys = new List<WmsOutDetailEntity>();
|
|
|
if (!WoDetailJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutDetailEntitys = ResolveWoDetailJSON(WoDetailJSON.Trim(), WmsOutDetailEntitys);
|
|
|
this.WoDetailContainer.Value = "";
|
|
|
}
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
#region 生成出库单并计算费用
|
|
|
#region 保存出库单wms_out 出库单明细wms_out_detail
|
|
|
//保存出库单wms_out
|
|
|
string ls = WmsOutEntity.TRUCKNO.ToString().Trim();
|
|
|
ls = ls.Replace("??"," ");
|
|
|
ls = ls.Replace("!!","\r\n");
|
|
|
//
|
|
|
Sqlstr = String.Format("update wms_out set BSNO='{1}',CUSTOMERNAME='{2}',DODATE='{3}',STORAGENAME='{4}',GOODSNAME='{5}',GOODSMODEL='{6}',GOODSPFSL='{7}',REMARK='{8}',CREATEUSER='{9}',CREATETIME=getdate(),TRUCKNO='{10}',ASSOCIATEDNO='{11}',GOODSPACKPFSL='{12}',INSPECTIONNO='{13}',CUSTOMNO='{14}',CLIENTNAMEOLD='{15}',OLDCUSTFEEDATE='{16}',TRUCKNAME='{17}',ARCLIENT='{18}',TOTALNO='{19}',CORPID='{20}' where GID='{0}'"
|
|
|
, WmsOutEntity.GID, WmsOutEntity.BSNO, WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.GOODSNAME, WmsOutEntity.GOODSMODEL, WmsOutEntity.GOODSPFSL, WmsOutEntity.REMARK, strUserID, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL, WmsOutEntity.INSPECTIONNO, WmsOutEntity.CUSTOMNO, WmsOutEntity.CLIENTNAMEOLD, WmsOutEntity.OLDCUSTFEEDATE, WmsOutEntity.TRUCKNAME, WmsOutEntity.ARCLIENT, WmsOutEntity.TOTALNO, strCompanyID);
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -1;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//保存出库单明细wms_out_detail
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
{
|
|
|
if (DateTime.Parse(WmsOutDetailEntity.DODATE.ToString("yyyy-MM-dd")) > DateTime.Parse(WmsOutEntity.DODATE.ToString("yyyy-MM-dd")))
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -12;
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>alert('出库日期不能小于入库日期!');</script>");
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//
|
|
|
WmsOutDetailEntity.OUTBSNO = WmsOutEntity.BSNO;
|
|
|
Decimal outnums = Decimal.Parse(WmsOutDetailEntity.GOODSPFSL.ToString());//出库量
|
|
|
|
|
|
#region 计算仓储费
|
|
|
int feedays = 0;
|
|
|
int feedaysap = 0;
|
|
|
|
|
|
//计算应收仓储费
|
|
|
string getstr = WmsOutDetailDA.getWmsRate(sqlTran, WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim(), WmsOutDetailEntity.INBSNO.ToString().Trim(), WmsOutEntity.CUSTOMERNAME.ToString().Trim(), outnums, WmsOutDetailEntity.GID.ToString(), 1, strUserID, strShowName, this.txt_outbsno.Value.Trim(), this.ck_jsfee.Checked, false);
|
|
|
|
|
|
string[] strls = getstr.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
sumfee = Decimal.Parse(strls[0].ToString());
|
|
|
totaloutfee += sumfee;//仓储费合计
|
|
|
feedays += int.Parse(strls[1].ToString());
|
|
|
|
|
|
//计算应付仓储费
|
|
|
getstr = WmsOutDetailDA.getWmsRate(sqlTran, WmsOutDetailEntity.STARTBILLINGDATEAP.ToString().Trim(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim(), WmsOutDetailEntity.INBSNO.ToString().Trim(), WmsOutEntity.CUSTOMERNAME.ToString().Trim(), outnums, WmsOutDetailEntity.GID.ToString(), 2, strUserID, strShowName, this.txt_outbsno.Value.Trim(), this.ck_jsfee.Checked, false);
|
|
|
|
|
|
strls = getstr.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
sumfeeap = Decimal.Parse(strls[0].ToString());
|
|
|
totaloutfeeap += sumfeeap;//仓储费合计
|
|
|
feedaysap += int.Parse(strls[1].ToString());
|
|
|
#endregion
|
|
|
|
|
|
//保存wms_out_detail
|
|
|
WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = (sumfee == 0 ? 0 : Decimal.Parse(Round(sumfee, 2, "").ToString()));
|
|
|
WmsOutDetailEntity.GOODSOUTFEEAP = (sumfeeap == 0 ? 0 : decimal.Parse(Round(sumfeeap, 2, "").ToString()));
|
|
|
WmsOutDetailEntity.ENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim().IndexOf("0001") > -1 ? DateTime.Parse("0001-01-01 00:00:00") : WmsOutEntity.OLDCUSTFEEDATE;//结束计费日期
|
|
|
WmsOutDetailEntity.ENDBILLINGDATEAP = WmsOutDetailEntity.STARTBILLINGDATEAP.ToString().Trim().IndexOf("0001") > -1 ? DateTime.Parse("0001-01-01 00:00:00") : WmsOutEntity.OLDCUSTFEEDATE;//结束计费日期
|
|
|
WmsOutDetailEntity.FEEDAYS = feedays;//计费天数iFEEDAYS
|
|
|
WmsOutDetailEntity.FEEDAYSAP = feedaysap;//计费天数iFEEDAYS
|
|
|
//
|
|
|
//bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
#region 提取规则编号 getCodeRuleWmsOutDetail
|
|
|
// <summary>
|
|
|
// 提取规则编号
|
|
|
// </summary>
|
|
|
// <param name="strRULENAME">规则项目名称</param>
|
|
|
// <param name="strfield">需要加规则的字段</param>
|
|
|
// <returns></returns>
|
|
|
//protected String getCodeRuleWmsOutDetail(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 *,getdate() DODATE from code_rule where RULENAME='出库明细单号' 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("出库明细单号", "BSNO");
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
//return "";
|
|
|
bsno = "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().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='" + strUserID + "')");
|
|
|
}
|
|
|
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='" + strUserID + "')");
|
|
|
}
|
|
|
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;
|
|
|
//
|
|
|
string strSQL = "select top 1 BSNO from [wms_out_detail] where BSNO like '" + strCONTENT.Trim() + "%' order by BSNO DESC";
|
|
|
DataSet ds1 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds1 != null)
|
|
|
{
|
|
|
if (ds1.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
strRULENOLENGTH = ds1.Tables[0].Rows[0]["BSNO"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
bsno = strCONTENT;
|
|
|
//return strCONTENT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// return "";
|
|
|
//}
|
|
|
#endregion
|
|
|
//
|
|
|
//WmsOutDetailEntity.GID = newGID;
|
|
|
//WmsOutDetailEntity.BSNO = bsno;
|
|
|
WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
//
|
|
|
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
|
|
|
ls = ls.Replace("??", " ");
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
//
|
|
|
string strSTARTBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "STARTBILLINGDATE='" + WmsOutDetailEntity.STARTBILLINGDATE.ToString() + "',";
|
|
|
//
|
|
|
string strENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "ENDBILLINGDATE='" + WmsOutDetailEntity.DODATE.ToString() + "',";//如果开始计费日期为空,则结束计费日期也为空,否则为出库日期。
|
|
|
//
|
|
|
//修改入库单wms_in
|
|
|
Sqlstr = String.Format("update wms_in set GOODSPACKSTOCK=GOODSPACKSTOCK+(select top 1 GOODSPACKPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{0},GOODSSTOCK=GOODSSTOCK+(select top 1 GOODSPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{2} where isnull(ISDELETE,0)=0 and gid='{1}' ", WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.GOODSPFSL);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;
|
|
|
//Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//修改入库单wms
|
|
|
Sqlstr = String.Format("update wms set GOODSPACKSTOCK=GOODSPACKSTOCK+(select top 1 GOODSPACKPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{0},GOODSSTOCK=GOODSSTOCK+(select top 1 GOODSPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{2} where isnull(ISDELETE,0)=0 and gid=(select top 1 ASSOCIATEDNO from wms_in where gid='{1}') ", WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.GOODSPFSL);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;
|
|
|
//Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//
|
|
|
Sqlstr = String.Format("update wms_out_detail set INBSNO='{1}',OUTBSNO='{2}',BSNO='{3}',CUSTOMERNAME='{4}',DODATE='{5}',STORAGENAME='{6}',GOODSNAME='{7}',GOODSMODEL='{8}',GOODSPFSL='{9}',GOODSOUTFEE='{10}',CREATEUSER='{11}',CREATETIME=getdate(),REMARK='{12}',TRUCKNO='{13}',ASSOCIATEDNO='{14}',GOODSPACKPFSL='{15}',GOODSOUTFEEAP='{16}',ARFEE='{17}',APFEE='{18}',CLIENTNAMEOLD='{19}',OLDCUSTFEEDATE='{20}',{21}{22}FEEDAYS='{23}',GOODSSTANDARD='{24}',GOODSGRADE='{25}',GOODSSLICE='{26}',CORPID='{27}' where GID='{0}'"
|
|
|
, WmsOutDetailEntity.GID, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.OUTBSNO, WmsOutDetailEntity.BSNO, WmsOutDetailEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutDetailEntity.STORAGENAME, WmsOutDetailEntity.GOODSNAME,WmsOutDetailEntity.GOODSMODEL, WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.GOODSOUTFEE, strUserID, WmsOutDetailEntity.REMARK, ls, WmsOutDetailEntity.ASSOCIATEDNO, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.GOODSOUTFEEAP, WmsOutDetailEntity.ARFEE, WmsOutDetailEntity.APFEE,
|
|
|
WmsOutDetailEntity.CLIENTNAMEOLD, this.txt_oldcustFeeDate.Value.Trim(), strSTARTBILLINGDATE, strENDBILLINGDATE, WmsOutDetailEntity.FEEDAYS, WmsOutDetailEntity.GOODSSTANDARD, WmsOutDetailEntity.GOODSGRADE, WmsOutDetailEntity.GOODSSLICE, strCompanyID);
|
|
|
//
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -5;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
}// end 保存出库明细wms_out_detail
|
|
|
|
|
|
//修改wms_out的出库量、出库件数、应收应付装卸费
|
|
|
string lsSQL = "update wms_out set "
|
|
|
+ "GOODSPFSL=(select isnull(sum(GOODSPFSL),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",GOODSPACKPFSL=(select isnull(sum(GOODSPACKPFSL),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",ARFEE=(select isnull(sum(ARFEE),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",APFEE=(select isnull(sum(APFEE),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ " where ISLOCK=0 and GID='" + WmsOutEntity.GID.ToString().Trim() + "'";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSQL, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -7;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//修改wms_out的仓储费wmsOutEntity.GOODSOUTFEE
|
|
|
h_outfee.Value = totaloutfee.ToString();
|
|
|
WmsOutEntity.GOODSOUTFEE =decimal.Parse( Round(totaloutfee,2,"").ToString());
|
|
|
WmsOutEntity.GOODSOUTFEEAP = decimal.Parse(Round(totaloutfeeap, 2, "").ToString());
|
|
|
|
|
|
Sqlstr = String.Format("update wms_out set GOODSOUTFEE={0},GOODSOUTFEEAP={2} where GID='{1}'", WmsOutEntity.GOODSOUTFEE, WmsOutEntity.GID, WmsOutEntity.GOODSOUTFEEAP);
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -7;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//页面赋值
|
|
|
this.h_wmsoutbsno.Value = WmsOutEntity.BSNO.ToString();
|
|
|
this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL.ToString();
|
|
|
this.h_goodspfsl.Value = WmsOutEntity.GOODSPFSL.ToString();
|
|
|
this.h_totalno.Value = WmsOutEntity.TOTALNO.ToString();
|
|
|
this.h_remark.Value = WmsOutEntity.REMARK.ToString();
|
|
|
|
|
|
txt_outbsno.Value = h_outbsno.Value;
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
string strcustomer = h_customer.Value;
|
|
|
string goods = h_goods.Value;
|
|
|
txt_goodsmodel.Value = h_goodsmodel.Value;
|
|
|
#endregion
|
|
|
this.h_newcust.Value = "";
|
|
|
this.h_IsSetRate.Value = "0";//正常出库,不需要设置费率
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
sqlTran.Commit();
|
|
|
//
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParentEdit('" + WmsOutEntity.GID.ToString().Trim() + "','edit',0,'" + WmsOutEntity.ASSOCIATEDNO.ToString().Trim() + "');</script>");
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
result = -10;//有异常,插入失败
|
|
|
sqlTran.Rollback();
|
|
|
result = -11;//插入异常,事务已回滚成功
|
|
|
Clearh();
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
private void SetOutPWmsFee(string OutDate, string CustName, string Associatedno, SqlTransaction sqlTran)
|
|
|
{
|
|
|
#region
|
|
|
int iState = 0;
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
Decimal totaloutfee = 0;//出库单的仓储费
|
|
|
int prescale = 0;
|
|
|
int nowscale = 0;
|
|
|
int nowgrade = 0;
|
|
|
Decimal price = 0;
|
|
|
Decimal gradefee = 0;
|
|
|
Decimal sumfee = 0;
|
|
|
WmsOutDetailDA WmsOutDetailDA = new WmsOutDetailDA();
|
|
|
|
|
|
DataSet DsDetail;
|
|
|
DataTable TbDetail;
|
|
|
|
|
|
DataSet dsrate;
|
|
|
DataTable dtrate;
|
|
|
Decimal outnums = 0;
|
|
|
int feedays = 0;
|
|
|
string OUTBSNO = "";//wms_out.BSNO
|
|
|
|
|
|
//查找对应的wms_out_detail记录
|
|
|
Sqlstr = String.Format("select a.GID,a.DODATE,a.GOODSPACKPFSL,a.GOODSPFSL,a.OUTBSNO,c.CLIENTNAMEOLD,c.CLIENTNAME,a.ASSOCIATEDNO,a.INBSNO from wms_out_detail a inner join wms_out b on a.OUTBSNO=b.BSNO inner join wms_in c on c.GID=a.INBSNO and c.CLIENTNAMEOLD=b.CUSTOMERNAME and c.GOODSSTOCK=b.GOODSPFSL "
|
|
|
+ " where c.CUSTOMERNAME='{0}' and c.GID='{1}' and a.DODATE>'{2}' ", CustName, Associatedno, OutDate);
|
|
|
DsDetail = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr.ToString(), null);
|
|
|
TbDetail = DsDetail.Tables[0];
|
|
|
foreach (DataRow r in TbDetail.Rows)
|
|
|
{
|
|
|
OUTBSNO = r["OUTBSNO"].ToString();
|
|
|
outnums = Decimal.Parse(r["GOODSPFSL"].ToString());
|
|
|
feedays = WmsOutDetailDA.GetDaysCount("day", r["DODATE"].ToString(), OutDate);
|
|
|
if (feedays > 0)
|
|
|
{
|
|
|
Sqlstr = String.Format("SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT FROM wms_rate where BSNO=(select top 1 ASSOCIATEDNO from wms_in where gid='{1}') and CUSTOMERNAME like '%{0}%' order by BSNO,FEEGRADE ", CustName, r["INBSNO"].ToString());//r["ASSOCIATEDNO"].ToString()
|
|
|
dsrate = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr.ToString(), null);
|
|
|
dtrate = dsrate.Tables[0];
|
|
|
|
|
|
prescale = 0;
|
|
|
nowscale = 0;
|
|
|
nowgrade = 0;
|
|
|
price = 0;
|
|
|
|
|
|
gradefee = 0;
|
|
|
sumfee = 0;
|
|
|
foreach (DataRow drow in dtrate.Rows)
|
|
|
{
|
|
|
nowgrade = int.Parse(drow["FEEGRADE"].ToString());
|
|
|
nowscale = int.Parse(drow["FEESCALE"].ToString());
|
|
|
price = Decimal.Parse(drow["FEEPRICE"].ToString());
|
|
|
if (nowgrade.Equals(1))
|
|
|
{
|
|
|
if (feedays > nowscale)
|
|
|
{
|
|
|
gradefee = outnums * price * nowscale;
|
|
|
sumfee += gradefee;
|
|
|
prescale = nowscale;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
gradefee = outnums * price * (feedays - prescale);
|
|
|
sumfee += gradefee;
|
|
|
prescale = nowscale;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
else if (nowgrade > 1)
|
|
|
{
|
|
|
if (feedays > nowscale)
|
|
|
{
|
|
|
gradefee = outnums * price * (nowscale - prescale);
|
|
|
sumfee += gradefee;
|
|
|
prescale = nowscale;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
gradefee = outnums * price * (feedays - prescale);
|
|
|
sumfee += gradefee;
|
|
|
prescale = nowscale;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (feedays > nowscale)
|
|
|
{
|
|
|
gradefee = outnums * price * (feedays - nowscale);
|
|
|
sumfee += gradefee;
|
|
|
}
|
|
|
totaloutfee += sumfee;
|
|
|
//更新wms_out_detail
|
|
|
Sqlstr = String.Format("update wms_out_detail set DODATE='{0}',GOODSOUTFEE={1},GOODSOUTFEEAP={3} where GID='{2}' "
|
|
|
, OutDate, Decimal.Parse(Round(sumfee, 2, "").ToString()), r["GID"], 0.00);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr.ToString(), null);
|
|
|
}
|
|
|
else if (feedays < 0 && r["CLIENTNAME"].ToString().Trim() != r["CLIENTNAMEOLD"].ToString().Trim())
|
|
|
{
|
|
|
SetOutPWmsFee(OutDate, r["CLIENTNAMEOLD"].ToString(), r["INBSNO"].ToString(), sqlTran);
|
|
|
}
|
|
|
}
|
|
|
//查找到对应的wms_out记录,并更新wms_out OUTBSNO
|
|
|
Sqlstr = String.Format("update wms_out set DODATE='{0}',GOODSOUTFEE={1},GOODSOUTFEE={3} where BSNO='{2}' "
|
|
|
, OutDate, decimal.Parse(Round(totaloutfee, 2, "").ToString()), OUTBSNO,0.00);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr.ToString(), null);
|
|
|
#endregion
|
|
|
}
|
|
|
|
|
|
private void Clearh()
|
|
|
{
|
|
|
this.h_post.Value = "";
|
|
|
|
|
|
this.h_bsno.Value = "";
|
|
|
this.h_opseaibsno.Value = "";
|
|
|
|
|
|
this.h_wmsoutbsno.Value = "";
|
|
|
this.h_outgid.Value = "";
|
|
|
this.h_outbsno.Value = "";
|
|
|
txt_outbsno.Value = "";
|
|
|
//txt_packnum.Value = "";
|
|
|
h_packnum.Value = "";
|
|
|
//txt_goodspfsl.Value = "";
|
|
|
h_goodspfsl.Value = "";
|
|
|
}
|
|
|
|
|
|
#region 货权转移 CargoRightTransfer
|
|
|
/// <summary>
|
|
|
/// 货权转移
|
|
|
/// </summary>
|
|
|
private int CargoRightTransfer()
|
|
|
{
|
|
|
int iState = 0;
|
|
|
int result = 0;
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
Decimal totaloutfee = 0;//出库单的仓储费
|
|
|
//int prescale = 0;
|
|
|
//int nowscale = 0;
|
|
|
//int nowgrade = 0;
|
|
|
//Decimal price = 0;
|
|
|
//Decimal gradefee = 0;
|
|
|
Decimal sumfee = 0;
|
|
|
string newGID = "";
|
|
|
string bsno = "";
|
|
|
|
|
|
//出库单信息
|
|
|
WmsOutDA WmsOutDA = new WmsOutDA();
|
|
|
WmsOutEntity WmsOutEntity = new WmsOutEntity();
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutEntity = ResolveWoJSON(WoJSON.Trim(), WmsOutEntity);
|
|
|
WoContainer.Value = "";
|
|
|
}
|
|
|
//出库单明细信息
|
|
|
WmsOutDetailDA WmsOutDetailDA = new WmsOutDetailDA();
|
|
|
IList<WmsOutDetailEntity> WmsOutDetailEntitys = new List<WmsOutDetailEntity>();
|
|
|
if (!WoDetailJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutDetailEntitys = ResolveWoDetailJSON(WoDetailJSON.Trim(), WmsOutDetailEntitys);
|
|
|
this.WoDetailContainer.Value = "";
|
|
|
}
|
|
|
Decimal outnums = 0;
|
|
|
int feedays = 0;
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
#region 生成出库单并计算费用
|
|
|
#region 保存出库单wms_out 出库单明细wms_out_detail
|
|
|
//保存出库单wms_out
|
|
|
//
|
|
|
string ls = WmsOutEntity.TRUCKNO.ToString().Trim();
|
|
|
ls = ls.Replace("??", " ");
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
string strINGIDNEW = getWMSNO();//货权转移后的入库wmsgid
|
|
|
WmsOutEntity.ISCHANGE = true;
|
|
|
WmsOutEntity.REMARK = "货权转移" + WmsOutEntity.REMARK.ToString().Trim() == "" ? "" : ";" + WmsOutEntity.REMARK.ToString().Trim();
|
|
|
//
|
|
|
Sqlstr = String.Format("insert into wms_out(GID,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSPFSL,REMARK,CREATEUSER,CREATETIME,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,INSPECTIONNO,CUSTOMNO,CLIENTNAMEOLD,OLDCUSTFEEDATE,TRUCKNAME,ARCLIENT,INGIDNEW,CHARGEUNIT,ISCHANGE,TOTALNO,CORPID)"
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',getdate(),'{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','CBM','{20}','{21}','{22}' )"
|
|
|
, WmsOutEntity.GID, WmsOutEntity.BSNO, WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.GOODSNAME, WmsOutEntity.GOODSMODEL, WmsOutEntity.GOODSPFSL, WmsOutEntity.REMARK.ToString().Trim(), strUserID, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL, WmsOutEntity.INSPECTIONNO, WmsOutEntity.CUSTOMNO, WmsOutEntity.CLIENTNAMEOLD, WmsOutEntity.OLDCUSTFEEDATE, WmsOutEntity.TRUCKNAME, WmsOutEntity.ARCLIENT, strINGIDNEW, WmsOutEntity.ISCHANGE, WmsOutEntity.TOTALNO, strCompanyID);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -1;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//保存出库单明细wms_out_detail
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
{
|
|
|
if (DateTime.Parse(WmsOutDetailEntity.DODATE.ToString("yyyy-MM-dd")) > DateTime.Parse(WmsOutEntity.DODATE.ToString("yyyy-MM-dd")))
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -12;
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>alert('出库日期不能小于入库日期!');</script>");
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
outnums = Decimal.Parse(WmsOutDetailEntity.GOODSPFSL.ToString());
|
|
|
newGID = Guid.NewGuid().ToString();
|
|
|
WmsOutDetailEntity.GID = newGID;
|
|
|
|
|
|
#region 计算仓储费
|
|
|
//计算应收仓储费
|
|
|
string getstr = WmsOutDetailDA.getWmsRate(sqlTran, WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim(), WmsOutDetailEntity.INBSNO.ToString().Trim(), WmsOutEntity.CUSTOMERNAME.ToString().Trim(), outnums, WmsOutDetailEntity.GID.ToString(), 1, strUserID, strShowName, this.txt_outbsno.Value.Trim(), this.ck_jsfee.Checked, false);
|
|
|
|
|
|
string[] strls = getstr.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
sumfee = Decimal.Parse(strls[0].ToString());
|
|
|
totaloutfee += sumfee;//仓储费合计
|
|
|
feedays += int.Parse(strls[1].ToString());
|
|
|
#endregion
|
|
|
|
|
|
//保存wms_out_detail
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = (sumfee == 0 ? 0 : decimal.Parse(Round(sumfee, 2, "").ToString()));
|
|
|
WmsOutDetailEntity.GOODSOUTFEEAP = 0;
|
|
|
WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
WmsOutDetailEntity.ENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim().IndexOf("0001") > -1 ? DateTime.Parse("0001-01-01 00:00:00") : WmsOutEntity.OLDCUSTFEEDATE;//结束计费日期
|
|
|
WmsOutDetailEntity.FEEDAYS = feedays;//计费天数 iFEEDAYS
|
|
|
WmsOutDetailEntity.FEEDAYSAP = 0;//计费天数 iFEEDAYSAP
|
|
|
//
|
|
|
//bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
#region 提取规则编号 getCodeRuleWmsOutDetail
|
|
|
// <summary>
|
|
|
// 提取规则编号
|
|
|
// </summary>
|
|
|
// <param name="strRULENAME">规则项目名称</param>
|
|
|
// <param name="strfield">需要加规则的字段</param>
|
|
|
// <returns></returns>
|
|
|
//protected String getCodeRuleWmsOutDetail(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 *,getdate() DODATE from code_rule where RULENAME='出库明细单号' 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("出库明细单号", "BSNO");
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
//return "";
|
|
|
bsno = "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().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='" + strUserID + "')");
|
|
|
}
|
|
|
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='" + strUserID + "')");
|
|
|
}
|
|
|
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;
|
|
|
//
|
|
|
string strSQL = "select top 1 BSNO from [wms_out_detail] where BSNO like '" + strCONTENT.Trim() + "%' order by BSNO DESC";
|
|
|
DataSet ds1 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds1 != null)
|
|
|
{
|
|
|
if (ds1.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
strRULENOLENGTH = ds1.Tables[0].Rows[0]["BSNO"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
bsno = strCONTENT;
|
|
|
//return strCONTENT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// return "";
|
|
|
//}
|
|
|
#endregion
|
|
|
WmsOutDetailEntity.BSNO = bsno;
|
|
|
//
|
|
|
WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
WmsOutDetailEntity.ISCHANGE = true;
|
|
|
//
|
|
|
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
|
|
|
ls = ls.Replace("??", " ");
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
//
|
|
|
string strSTARTBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "'" + WmsOutDetailEntity.STARTBILLINGDATE.ToString() + "',";
|
|
|
string strSTARTBILLINGDATE_name = strSTARTBILLINGDATE.Equals("") ? "" : "STARTBILLINGDATE,";
|
|
|
//
|
|
|
string strENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "'" + WmsOutEntity.OLDCUSTFEEDATE.ToString() + "',";//如果开始计费日期为空,则结束计费日期也为空,否则为出库日期。
|
|
|
string strENDBILLINGDATE_name = strENDBILLINGDATE.Equals("") ? "" : "ENDBILLINGDATE,";
|
|
|
//
|
|
|
Sqlstr = String.Format("insert into wms_out_detail (GID,INBSNO,OUTBSNO,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSPFSL,GOODSOUTFEE,CREATEUSER,CREATETIME,REMARK,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,GOODSOUTFEEAP,ARFEE,APFEE,CLIENTNAMEOLD,OLDCUSTFEEDATE,{21}{23}FEEDAYS,GOODSSTANDARD,GOODSGRADE,GOODSSLICE,CHARGEUNIT,ISCHANGE,CORPID) "
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}',getdate(),'{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}',{22}{24}'{25}','{26}','{27}','{28}','CBM','{29}','{30}')"
|
|
|
, WmsOutDetailEntity.GID, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.OUTBSNO, WmsOutDetailEntity.BSNO, WmsOutDetailEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutDetailEntity.STORAGENAME, WmsOutDetailEntity.GOODSNAME, WmsOutDetailEntity.GOODSMODEL, WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.GOODSOUTFEE, strUserID, "货权转移", ls, WmsOutDetailEntity.ASSOCIATEDNO, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.GOODSOUTFEEAP, WmsOutDetailEntity.ARFEE, WmsOutDetailEntity.APFEE,
|
|
|
WmsOutDetailEntity.CLIENTNAMEOLD, WmsOutEntity.OLDCUSTFEEDATE, strSTARTBILLINGDATE_name, strSTARTBILLINGDATE, strENDBILLINGDATE_name, strENDBILLINGDATE, WmsOutDetailEntity.FEEDAYS, WmsOutDetailEntity.GOODSSTANDARD, WmsOutDetailEntity.GOODSGRADE, WmsOutDetailEntity.GOODSSLICE, WmsOutDetailEntity.ISCHANGE, strCompanyID);
|
|
|
//
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -5;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//修改入库单wms_in
|
|
|
Sqlstr = String.Format("update wms_in set GOODSSTOCK=GOODSSTOCK-{0},GOODSPACKSTOCK=GOODSPACKSTOCK-{1} where ISDELETE=0 and GID='{2}' ", WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//修改入库单wms
|
|
|
Sqlstr = String.Format("update wms set GOODSSTOCK=GOODSSTOCK-{0},GOODSPACKSTOCK=GOODSPACKSTOCK-{1} where ISDELETE=0 and gid=(select top 1 ASSOCIATEDNO from wms_in where gid='{2}') ", WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
}// end 保存出库明细wms_out_detail
|
|
|
|
|
|
//修改wms_out的出库量、出库件数、应收应付装卸费
|
|
|
string lsSQL = "update wms_out set "
|
|
|
+ "GOODSPFSL=(select isnull(sum(GOODSPFSL),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",GOODSPACKPFSL=(select isnull(sum(GOODSPACKPFSL),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",ARFEE=(select isnull(sum(ARFEE),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",APFEE=(select isnull(sum(APFEE),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ " where ISLOCK=0 and GID='" + WmsOutEntity.GID.ToString().Trim() + "'";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSQL, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -7;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//修改wms_out的仓储费wmsOutEntity.GOODSOUTFEE
|
|
|
h_outfee.Value = totaloutfee.ToString();
|
|
|
WmsOutEntity.GOODSOUTFEE = decimal.Parse(Round(totaloutfee, 2, "").ToString());
|
|
|
WmsOutEntity.GOODSOUTFEEAP = 0;
|
|
|
|
|
|
Sqlstr = String.Format("update wms_out set GOODSOUTFEE={0},GOODSOUTFEEAP={2} where GID='{1}'", WmsOutEntity.GOODSOUTFEE, WmsOutEntity.GID, WmsOutEntity.GOODSOUTFEEAP);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -7;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//页面赋值
|
|
|
this.h_wmsoutbsno.Value = WmsOutEntity.BSNO.ToString();
|
|
|
this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL.ToString();
|
|
|
this.h_goodspfsl.Value = WmsOutEntity.GOODSPFSL.ToString();
|
|
|
this.h_totalno.Value = WmsOutEntity.TOTALNO.ToString();
|
|
|
this.h_remark.Value = WmsOutEntity.REMARK.ToString();
|
|
|
|
|
|
txt_outbsno.Value = h_outbsno.Value;
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
string strcustomer = h_customer.Value;
|
|
|
string goods = h_goods.Value;
|
|
|
txt_goodsmodel.Value = h_goodsmodel.Value;
|
|
|
#endregion
|
|
|
|
|
|
#region 货权转移到 outcustomer.value
|
|
|
WmsInEntity WmsInEntity = new WmsInEntity();
|
|
|
WmsInDA wmsinDA = new WmsInDA();
|
|
|
WmsEntity WmsEntity = new WmsEntity();
|
|
|
WmsDA wmsDA = new WmsDA();
|
|
|
string Inbsno = "";
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
{
|
|
|
Inbsno = WmsOutDetailEntity.INBSNO;
|
|
|
break;
|
|
|
}
|
|
|
//
|
|
|
#region 插入入库主表
|
|
|
#region 提取原入库wms数据
|
|
|
string SQL_SELECT_WMS_GID = "select GID, WMSNO, WMSDATE, CUSTOMERNAME, WMSOP, STOREMAN, MODIFIEDUSER, MODIFIEDTIME, ISDELETE, DELETEUSER, DELETETIME,TRUCKNAME, GOODSPACK, GOODSPACKSTOCK, GOODSRKSL, GOODSSTOCK, ARFEE, APFEE, ASSOCIATEDNO, BLNO, FREESTORAGEPERIOD, CONTRACTNO, GOODSNAME, GOODSMODEL, CLIENTCODEOLD, CLIENTNAMEOLD, STORAGENAME, CHARGEUNIT, STARTBILLINGDATE,CUSTOMNO,CUSTNO,GOODSSTANDARD,ARCLIENT,FREESTORAGEPERIODAP,STARTBILLINGDATEAP,CORPID,BZTCHNO,CREATEUSER,CREATETIME from wms where GID=(select top 1 ASSOCIATEDNO from wms_in where gid='" + Inbsno.Trim() + "') and ISDELETE=0";
|
|
|
SqlDataReader sqlRead = SqlHelper.ExecuteQueryReader(sqlTran, CommandType.Text, SQL_SELECT_WMS_GID, null);
|
|
|
while (sqlRead.Read())
|
|
|
{
|
|
|
if (!sqlRead.IsDBNull(0)) { WmsEntity.GID = sqlRead.GetString(0); } // 唯一编码 newid()
|
|
|
if (!sqlRead.IsDBNull(1)) { WmsEntity.WMSNO = sqlRead.GetString(1); } //
|
|
|
if (!sqlRead.IsDBNull(2)) { WmsEntity.WMSDATE = sqlRead.GetDateTime(2); } //
|
|
|
if (!sqlRead.IsDBNull(3)) { WmsEntity.CUSTOMERNAME = sqlRead.GetString(3); } //
|
|
|
if (!sqlRead.IsDBNull(4)) { WmsEntity.WMSOP = sqlRead.GetString(4); } //
|
|
|
if (!sqlRead.IsDBNull(5)) { WmsEntity.STOREMAN = sqlRead.GetString(5); }
|
|
|
if (!sqlRead.IsDBNull(6)) { WmsEntity.MODIFIEDUSER = sqlRead.GetString(6); }
|
|
|
if (!sqlRead.IsDBNull(7)) { WmsEntity.MODIFIEDTIME = sqlRead.GetDateTime(7); }
|
|
|
if (!sqlRead.IsDBNull(8)) { WmsEntity.ISDELETE = sqlRead.GetBoolean(8); } // 是否废除
|
|
|
if (!sqlRead.IsDBNull(9)) { WmsEntity.DELETEUSER = sqlRead.GetString(9); } // 废除操作人
|
|
|
if (!sqlRead.IsDBNull(10)) { WmsEntity.DELETETIME = sqlRead.GetDateTime(10); } // 废除时间
|
|
|
if (!sqlRead.IsDBNull(11)) { WmsEntity.TRUCKNAME = sqlRead.GetString(11); } //
|
|
|
if (!sqlRead.IsDBNull(12)) { WmsEntity.GOODSPACK = sqlRead.GetDecimal(12); } //
|
|
|
if (!sqlRead.IsDBNull(13)) { WmsEntity.GOODSPACKSTOCK = sqlRead.GetDecimal(13); } //
|
|
|
if (!sqlRead.IsDBNull(14)) { WmsEntity.GOODSRKSL = sqlRead.GetDecimal(14); } //
|
|
|
if (!sqlRead.IsDBNull(15)) { WmsEntity.GOODSSTOCK = sqlRead.GetDecimal(15); } //
|
|
|
if (!sqlRead.IsDBNull(16)) { WmsEntity.ARFEE = sqlRead.GetDecimal(16); } //
|
|
|
if (!sqlRead.IsDBNull(17)) { WmsEntity.APFEE = sqlRead.GetDecimal(17); } //
|
|
|
if (!sqlRead.IsDBNull(18)) { WmsEntity.ASSOCIATEDNO = sqlRead.GetString(18); } //
|
|
|
if (!sqlRead.IsDBNull(19)) { WmsEntity.BLNO = sqlRead.GetString(19); } //
|
|
|
if (!sqlRead.IsDBNull(20)) { WmsEntity.FREESTORAGEPERIOD = sqlRead.GetInt32(20); } //
|
|
|
if (!sqlRead.IsDBNull(21)) { WmsEntity.CONTRACTNO = sqlRead.GetString(21); } //
|
|
|
if (!sqlRead.IsDBNull(22)) { WmsEntity.GOODSNAME = sqlRead.GetString(22); } //
|
|
|
if (!sqlRead.IsDBNull(23)) { WmsEntity.GOODSMODEL = sqlRead.GetString(23); } //
|
|
|
if (!sqlRead.IsDBNull(24)) { WmsEntity.CLIENTCODEOLD = sqlRead.GetString(24); } //
|
|
|
if (!sqlRead.IsDBNull(25)) { WmsEntity.CLIENTNAMEOLD = sqlRead.GetString(25); } //
|
|
|
if (!sqlRead.IsDBNull(26)) { WmsEntity.STORAGENAME = sqlRead.GetString(26); } //
|
|
|
if (!sqlRead.IsDBNull(27)) { WmsEntity.CHARGEUNIT = sqlRead.GetString(27); } //
|
|
|
if (!sqlRead.IsDBNull(28)) { WmsEntity.STARTBILLINGDATE = sqlRead.GetDateTime(28); } //
|
|
|
if (!sqlRead.IsDBNull(29)) { WmsEntity.CUSTOMNO = sqlRead.GetString(29); }//
|
|
|
if (!sqlRead.IsDBNull(30)) { WmsEntity.CUSTNO = sqlRead.GetString(30); }
|
|
|
if (!sqlRead.IsDBNull(31)) { WmsEntity.GOODSSTANDARD = sqlRead.GetString(31); }
|
|
|
if (!sqlRead.IsDBNull(32)) { WmsEntity.ARCLIENT = sqlRead.GetString(32); }
|
|
|
if (!sqlRead.IsDBNull(33)) { WmsEntity.FREESTORAGEPERIODAP = sqlRead.GetInt32(33); } //
|
|
|
if (!sqlRead.IsDBNull(34)) { WmsEntity.STARTBILLINGDATEAP = sqlRead.GetDateTime(34); } //
|
|
|
if (!sqlRead.IsDBNull(35)) { WmsEntity.CORPID = sqlRead.GetString(35); }
|
|
|
if (!sqlRead.IsDBNull(36)) { WmsEntity.BZTCHNO = sqlRead.GetString(36); }
|
|
|
if (!sqlRead.IsDBNull(37)) { WmsEntity.CREATEUSER = sqlRead.GetString(37); }
|
|
|
if (!sqlRead.IsDBNull(38)) { WmsEntity.CREATETIME = sqlRead.GetDateTime(38); }
|
|
|
}
|
|
|
sqlRead.Close();
|
|
|
sqlRead.Dispose();
|
|
|
#endregion
|
|
|
//
|
|
|
#region 提取货权转移的wms_out的数据
|
|
|
WmsOutEntity model = new WmsOutEntity();
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
string SQL_SELECT_WMS_OUT_GID = "select top 1 GID, AREACODE, AREANAME, GOODSCODE, GOODSNAME, GOODSTYPE, GOODSMODEL, GOODSSTANDARD, GOODSPACK, GOODSPFSL, GOODSOUTFEE, ASSOCIATEDNO, TRUCKNO, REMARK, ISDELETE, DELETETIME, DELETEUSER, CREATEUSER, CREATETIME, MODIFIEDUSER, MODIFIEDTIME, GOODSPACKPFSL, BSNO, TRUCKNAME, WMSOP, STOREMAN, ISLOCK, LOCKUSER, LOCKTIME, GOODSOUTFEEAP, ARFEE, APFEE, INSPECTIONNO, CLIENTGID, CUSTOMNO, CORPID, CLIENTNAMEOLD, OLDCUSTFEEDATE, CLIENTBSNO, ARCLIENT, INGIDNEW, TOTALNO, REMARK2, VALIDDATE, CLIENTCODE, CHARGEUNIT, CUSTOMERNAME, DODATE, STORAGECODE, STORAGENAME,TOTALNO,CORPID from wms_out where GID='" + WmsOutEntity.GID.ToString().Trim() + "' ";
|
|
|
SqlDataReader sqlRead1 = SqlHelper.ExecuteQueryReader(sqlTran, CommandType.Text, SQL_SELECT_WMS_OUT_GID, null);
|
|
|
while (sqlRead1.Read())
|
|
|
{
|
|
|
if (sqlRead1["GID"] != null && sqlRead1["GID"].ToString() != "")
|
|
|
{
|
|
|
model.GID = sqlRead1["GID"].ToString();
|
|
|
}
|
|
|
model.GID = sqlRead1["GID"].ToString();
|
|
|
model.AREACODE = sqlRead1["AREACODE"].ToString();
|
|
|
model.AREANAME = sqlRead1["AREANAME"].ToString();
|
|
|
model.GOODSCODE = sqlRead1["GOODSCODE"].ToString();
|
|
|
model.GOODSNAME = sqlRead1["GOODSNAME"].ToString();
|
|
|
model.GOODSTYPE = sqlRead1["GOODSTYPE"].ToString();
|
|
|
model.GOODSMODEL = sqlRead1["GOODSMODEL"].ToString();
|
|
|
model.GOODSSTANDARD = sqlRead1["GOODSSTANDARD"].ToString();
|
|
|
model.GOODSPACK = sqlRead1["GOODSPACK"].ToString();
|
|
|
if (sqlRead1["GOODSPFSL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPFSL = decimal.Parse(sqlRead1["GOODSPFSL"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["GOODSOUTFEE"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSOUTFEE = decimal.Parse(sqlRead1["GOODSOUTFEE"].ToString());
|
|
|
}
|
|
|
model.ASSOCIATEDNO = sqlRead1["ASSOCIATEDNO"].ToString();
|
|
|
model.TRUCKNO = sqlRead1["TRUCKNO"].ToString();
|
|
|
model.TOTALNO = sqlRead1["TOTALNO"].ToString();
|
|
|
model.REMARK = sqlRead1["REMARK"].ToString();
|
|
|
if (sqlRead1["ISDELETE"].ToString() != "")
|
|
|
{
|
|
|
if ((sqlRead1["ISDELETE"].ToString() == "1") || (sqlRead1["ISDELETE"].ToString().ToLower() == "true"))
|
|
|
{
|
|
|
model.ISDELETE = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
model.ISDELETE = false;
|
|
|
}
|
|
|
}
|
|
|
if (sqlRead1["DELETETIME"].ToString() != "")
|
|
|
{
|
|
|
model.DELETETIME = DateTime.Parse(sqlRead1["DELETETIME"].ToString());
|
|
|
}
|
|
|
model.DELETEUSER = sqlRead1["DELETEUSER"].ToString();
|
|
|
model.CREATEUSER = sqlRead1["CREATEUSER"].ToString();
|
|
|
if (sqlRead1["CREATETIME"].ToString() != "")
|
|
|
{
|
|
|
model.CREATETIME = DateTime.Parse(sqlRead1["CREATETIME"].ToString());
|
|
|
}
|
|
|
model.MODIFIEDUSER = sqlRead1["MODIFIEDUSER"].ToString();
|
|
|
if (sqlRead1["MODIFIEDTIME"].ToString() != "")
|
|
|
{
|
|
|
model.MODIFIEDTIME = DateTime.Parse(sqlRead1["MODIFIEDTIME"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["GOODSPACKPFSL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPACKPFSL = decimal.Parse(sqlRead1["GOODSPACKPFSL"].ToString());
|
|
|
}
|
|
|
model.BSNO = sqlRead1["BSNO"].ToString();
|
|
|
model.TRUCKNAME = sqlRead1["TRUCKNAME"].ToString();
|
|
|
model.WMSOP = sqlRead1["WMSOP"].ToString();
|
|
|
model.STOREMAN = sqlRead1["STOREMAN"].ToString();
|
|
|
if (sqlRead1["ISLOCK"].ToString() != "")
|
|
|
{
|
|
|
if ((sqlRead1["ISLOCK"].ToString() == "1") || (sqlRead1["ISLOCK"].ToString().ToLower() == "true"))
|
|
|
{
|
|
|
model.ISLOCK = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
model.ISLOCK = false;
|
|
|
}
|
|
|
}
|
|
|
model.LOCKUSER = sqlRead1["LOCKUSER"].ToString();
|
|
|
if (sqlRead1["LOCKTIME"].ToString() != "")
|
|
|
{
|
|
|
model.LOCKTIME = DateTime.Parse(sqlRead1["LOCKTIME"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["GOODSOUTFEEAP"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSOUTFEEAP = decimal.Parse(sqlRead1["GOODSOUTFEEAP"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["ARFEE"].ToString() != "")
|
|
|
{
|
|
|
model.ARFEE = decimal.Parse(sqlRead1["ARFEE"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["APFEE"].ToString() != "")
|
|
|
{
|
|
|
model.APFEE = decimal.Parse(sqlRead1["APFEE"].ToString());
|
|
|
}
|
|
|
model.INSPECTIONNO = sqlRead1["INSPECTIONNO"].ToString();
|
|
|
model.CLIENTGID = sqlRead1["CLIENTGID"].ToString();
|
|
|
model.CUSTOMNO = sqlRead1["CUSTOMNO"].ToString();
|
|
|
model.CORPID = sqlRead1["CORPID"].ToString();
|
|
|
model.CLIENTNAMEOLD = sqlRead1["CLIENTNAMEOLD"].ToString();
|
|
|
if (sqlRead1["OLDCUSTFEEDATE"].ToString() != "")
|
|
|
{
|
|
|
model.OLDCUSTFEEDATE = DateTime.Parse(sqlRead1["OLDCUSTFEEDATE"].ToString());
|
|
|
}
|
|
|
model.CLIENTBSNO = sqlRead1["CLIENTBSNO"].ToString();
|
|
|
model.ARCLIENT = sqlRead1["ARCLIENT"].ToString();
|
|
|
model.INGIDNEW = sqlRead1["INGIDNEW"].ToString();
|
|
|
model.TOTALNO = sqlRead1["TOTALNO"].ToString();
|
|
|
model.REMARK2 = sqlRead1["REMARK2"].ToString();
|
|
|
if (sqlRead1["VALIDDATE"].ToString() != "")
|
|
|
{
|
|
|
model.VALIDDATE = DateTime.Parse(sqlRead1["VALIDDATE"].ToString());
|
|
|
}
|
|
|
model.CLIENTCODE = sqlRead1["CLIENTCODE"].ToString();
|
|
|
model.CHARGEUNIT = sqlRead1["CHARGEUNIT"].ToString();
|
|
|
model.CUSTOMERNAME = sqlRead1["CUSTOMERNAME"].ToString();
|
|
|
if (sqlRead1["DODATE"].ToString() != "")
|
|
|
{
|
|
|
model.DODATE = DateTime.Parse(sqlRead1["DODATE"].ToString());
|
|
|
}
|
|
|
model.STORAGECODE = sqlRead1["STORAGECODE"].ToString();
|
|
|
model.STORAGENAME = sqlRead1["STORAGENAME"].ToString();
|
|
|
model.CORPID = sqlRead1["CORPID"].ToString();
|
|
|
}
|
|
|
sqlRead1.Close();
|
|
|
sqlRead1.Dispose();
|
|
|
#endregion
|
|
|
//
|
|
|
WmsEntity.GID = strINGIDNEW;
|
|
|
//
|
|
|
#region 提取规则编号 getCodeRule("入库单号", "WMSNO")
|
|
|
// <summary>
|
|
|
// 提取规则编号
|
|
|
// </summary>
|
|
|
// <param name="strRULENAME">规则项目名称</param>
|
|
|
// <param name="strfield">需要加规则的字段</param>
|
|
|
// <returns></returns>
|
|
|
//protected String getCodeRule(string strRULENAME, string strfield)
|
|
|
//{
|
|
|
//调用编码规则
|
|
|
string tbWMSNO = "";
|
|
|
string strRULEYEAR1 = "";
|
|
|
string strRULECONTENT1 = "";
|
|
|
string strCODENAME1 = "";
|
|
|
string strDEPTNO1 = "";
|
|
|
string strRULENOLENGTH1 = "";
|
|
|
int iRULENOLENGTH1 = 0;
|
|
|
int inum1 = 0;
|
|
|
string strCONTENT1 = "";
|
|
|
DataSet ds2 = T_ALL_DA.GetAllSQL("select *,getdate() DODATE from code_rule where RULENAME='入库单号' and RULETYPE=3");
|
|
|
if (ds2 != null)
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
getCodeRuleEnabled("入库单号", "WMSNO");
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
//return "";
|
|
|
tbWMSNO = "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds2.Tables[0].Rows[0]["DODATE"].ToString().Trim());
|
|
|
if (ds2.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yyyy") + dETD.ToString("MM");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yy") + dETD.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
|
|
|
{
|
|
|
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
|
|
|
if (ds2.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strCODENAME1 = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
}
|
|
|
if (ds2.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strDEPTNO1 = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
}
|
|
|
strRULECONTENT1 = ds2.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
|
|
|
strRULECONTENT1 = strRULECONTENT1.Replace("《COMPANY》", strCODENAME1);
|
|
|
strRULECONTENT1 = strRULECONTENT1.Replace("《DEPT》", strDEPTNO1);
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
|
|
|
{
|
|
|
iRULENOLENGTH1 = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iRULENOLENGTH1 = int.Parse(ds2.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
|
|
|
}
|
|
|
strCONTENT1 = strRULECONTENT1 + strRULEYEAR1;
|
|
|
//
|
|
|
//获取分公司的票号头字符
|
|
|
string tempBANKSHEAD = "";
|
|
|
string strSQL = "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'";
|
|
|
DataSet ds21 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds21 != null)
|
|
|
{
|
|
|
if (ds21.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
tempBANKSHEAD = ds21.Tables[0].Rows[0]["BANKSHEAD"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
strCONTENT1 = tempBANKSHEAD + strCONTENT1;
|
|
|
//
|
|
|
strSQL = "select top 1 WMSNO from [wms] where WMSNO like '" + strCONTENT1.Trim() + "%' order by WMSNO DESC";
|
|
|
ds21 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds21 != null)
|
|
|
{
|
|
|
if (ds21.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
strRULENOLENGTH1 = ds21.Tables[0].Rows[0]["WMSNO"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
if (strRULENOLENGTH1 == "")
|
|
|
{
|
|
|
strRULENOLENGTH1 = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strRULENOLENGTH1 = strRULENOLENGTH1.Replace(strCONTENT1.Trim(), "");
|
|
|
inum1 = int.Parse(strRULENOLENGTH1.Trim());
|
|
|
inum1 = inum1 + 1;
|
|
|
strRULENOLENGTH1 = inum1.ToString();
|
|
|
}
|
|
|
int j = iRULENOLENGTH1 - strRULENOLENGTH1.Length;
|
|
|
for (int i = 1; i <= j; i++)
|
|
|
{
|
|
|
strRULENOLENGTH1 = "0" + strRULENOLENGTH1;
|
|
|
}
|
|
|
//
|
|
|
strCONTENT1 = strCONTENT1 + strRULENOLENGTH1;
|
|
|
tbWMSNO = strCONTENT1;
|
|
|
//return strCONTENT1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// return "";
|
|
|
//}
|
|
|
#endregion
|
|
|
WmsEntity.WMSNO = tbWMSNO;//调用编码规则
|
|
|
//
|
|
|
WmsEntity.CUSTOMERNAME = this.h_outcustomer.Value.ToString().Trim();
|
|
|
WmsEntity.WMSOP = strShowName.Trim();
|
|
|
WmsEntity.STOREMAN = strShowName.Trim();
|
|
|
WmsEntity.MODIFIEDUSER = strUserID;
|
|
|
//
|
|
|
WmsEntity.WMSDATE = model.DODATE;
|
|
|
WmsEntity.STARTBILLINGDATE = DateTime.Parse(this.txt_oldcustFeeDate.Value.Trim()).AddDays(1);
|
|
|
int iFeeDay = WmsOutDetailDA.GetDaysCount("day", model.DODATE.ToString(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim());//WmsOutEntity.DODATE.ToString());
|
|
|
WmsEntity.FREESTORAGEPERIOD = 0;
|
|
|
if (iFeeDay > 0)
|
|
|
{
|
|
|
WmsEntity.FREESTORAGEPERIOD = iFeeDay;
|
|
|
}
|
|
|
//
|
|
|
WmsEntity.GOODSPACK = model.GOODSPACKPFSL;
|
|
|
WmsEntity.GOODSPACKSTOCK = model.GOODSPACKPFSL;
|
|
|
WmsEntity.GOODSPACKACTUAL = model.GOODSPACKPFSL;
|
|
|
WmsEntity.GOODSRKSL = model.GOODSPFSL;
|
|
|
WmsEntity.GOODSSTOCK = model.GOODSPFSL;
|
|
|
WmsEntity.GOODSRKSLACTUAL = model.GOODSPFSL;
|
|
|
WmsEntity.ARFEE = 0;
|
|
|
WmsEntity.APFEE = 0;
|
|
|
WmsEntity.CLIENTNAMEOLD = model.CUSTOMERNAME;// 原客户名称
|
|
|
WmsEntity.ISLOCK = false;// true;
|
|
|
WmsEntity.LOCKUSER = strUserID;
|
|
|
WmsEntity.CUSTOMNO = model.CUSTOMNO;
|
|
|
WmsEntity.ARCLIENT = "";
|
|
|
WmsEntity.TRUCKNAME = "";
|
|
|
WmsEntity.ISCHANGE = true;
|
|
|
WmsEntity.CORPID = strCompanyID;
|
|
|
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
|
|
|
new SqlParameter("@WMSNO", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@WMSDATE", SqlDbType.DateTime) ,
|
|
|
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@WMSOP", SqlDbType.VarChar,10) ,
|
|
|
new SqlParameter("@STOREMAN", SqlDbType.VarChar,10) ,
|
|
|
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
|
|
|
new SqlParameter("@TRUCKNAME", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@GOODSPACK", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSPACKSTOCK", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSRKSL", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSSTOCK", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@ARFEE", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@APFEE", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@ASSOCIATEDNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@BLNO", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@FREESTORAGEPERIOD", SqlDbType.Int,4) ,
|
|
|
new SqlParameter("@CONTRACTNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@GOODSNAME", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@GOODSMODEL", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@CLIENTCODEOLD", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@CLIENTNAMEOLD", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@STORAGENAME", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@CHARGEUNIT", SqlDbType.VarChar,10) ,
|
|
|
new SqlParameter("@ISLOCK", SqlDbType.Bit) ,
|
|
|
new SqlParameter("@LOCKUSER", SqlDbType.VarChar,36) ,
|
|
|
new SqlParameter("@STARTBILLINGDATE", SqlDbType.DateTime) ,
|
|
|
new SqlParameter("@CUSTOMNO", SqlDbType.VarChar,30) ,
|
|
|
new SqlParameter("@CUSTNO",SqlDbType.VarChar,30),
|
|
|
new SqlParameter("@GOODSSTANDARD",SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@ARCLIENT", SqlDbType.VarChar,20),
|
|
|
new SqlParameter("@ISCHANGE", SqlDbType.Bit),
|
|
|
new SqlParameter("@FREESTORAGEPERIODAP", SqlDbType.Int,4) ,
|
|
|
new SqlParameter("@STARTBILLINGDATEAP", SqlDbType.DateTime) ,
|
|
|
new SqlParameter("@CORPID", SqlDbType.VarChar,36) ,
|
|
|
new SqlParameter("@BZTCHNO", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@CREATEUSER", SqlDbType.VarChar,36)
|
|
|
};
|
|
|
|
|
|
parameters[0].Value = WmsEntity.GID;
|
|
|
parameters[1].Value = WmsEntity.WMSNO;
|
|
|
parameters[2].Value = WmsEntity.WMSDATE;
|
|
|
parameters[3].Value = WmsEntity.CUSTOMERNAME;
|
|
|
parameters[4].Value = WmsEntity.WMSOP;
|
|
|
parameters[5].Value = WmsEntity.STOREMAN;
|
|
|
parameters[6].Value = WmsEntity.MODIFIEDUSER;
|
|
|
parameters[7].Value = WmsEntity.TRUCKNAME;
|
|
|
parameters[8].Value = WmsEntity.GOODSPACK;
|
|
|
parameters[9].Value = WmsEntity.GOODSPACKSTOCK;
|
|
|
parameters[10].Value = WmsEntity.GOODSRKSL;
|
|
|
parameters[11].Value = WmsEntity.GOODSSTOCK;
|
|
|
parameters[12].Value = WmsEntity.ARFEE;
|
|
|
parameters[13].Value = WmsEntity.APFEE;
|
|
|
parameters[14].Value = WmsEntity.ASSOCIATEDNO;
|
|
|
parameters[15].Value = WmsEntity.BLNO;
|
|
|
parameters[16].Value = WmsEntity.FREESTORAGEPERIOD;
|
|
|
parameters[17].Value = WmsEntity.CONTRACTNO;
|
|
|
parameters[18].Value = WmsEntity.GOODSNAME;
|
|
|
parameters[19].Value = WmsEntity.GOODSMODEL;
|
|
|
parameters[20].Value = WmsEntity.CLIENTCODEOLD;
|
|
|
parameters[21].Value = WmsEntity.CLIENTNAMEOLD;
|
|
|
parameters[22].Value = WmsEntity.STORAGENAME;
|
|
|
parameters[23].Value = WmsEntity.CHARGEUNIT;
|
|
|
parameters[24].Value = WmsEntity.ISLOCK;
|
|
|
parameters[25].Value = WmsEntity.LOCKUSER;
|
|
|
parameters[26].Value = WmsEntity.STARTBILLINGDATE;
|
|
|
parameters[27].Value = WmsEntity.CUSTOMNO;
|
|
|
parameters[28].Value = WmsEntity.CUSTNO;
|
|
|
parameters[29].Value = WmsEntity.GOODSSTANDARD;
|
|
|
parameters[30].Value = WmsEntity.ARCLIENT;
|
|
|
parameters[31].Value = WmsEntity.ISCHANGE;
|
|
|
parameters[32].Value = WmsEntity.FREESTORAGEPERIODAP;
|
|
|
parameters[33].Value = WmsEntity.STARTBILLINGDATEAP;
|
|
|
parameters[34].Value = WmsEntity.CORPID;
|
|
|
parameters[35].Value = WmsEntity.BZTCHNO;
|
|
|
parameters[36].Value = WmsEntity.CREATEUSER;
|
|
|
|
|
|
string lsSql = "insert into wms(GID,WMSNO,WMSDATE,CUSTOMERNAME,WMSOP,STOREMAN,MODIFIEDUSER,MODIFIEDTIME,ISDELETE,DELETEUSER,DELETETIME,TRUCKNAME,GOODSPACK,GOODSPACKSTOCK,GOODSRKSL,GOODSSTOCK,ARFEE,APFEE,ASSOCIATEDNO,BLNO,FREESTORAGEPERIOD,CONTRACTNO,GOODSNAME,GOODSMODEL,CLIENTCODEOLD,CLIENTNAMEOLD,STORAGENAME,CHARGEUNIT,ISLOCK,LOCKUSER,LOCKTIME,STARTBILLINGDATE,CUSTOMNO,CUSTNO,GOODSSTANDARD,ARCLIENT,ISCHANGE,FREESTORAGEPERIODAP,STARTBILLINGDATEAP,CORPID,BZTCHNO,CREATEUSER,CREATETIME) values (@GID,@WMSNO,@WMSDATE,@CUSTOMERNAME,@WMSOP,@STOREMAN,@MODIFIEDUSER,getdate(),0,'',getdate(),@TRUCKNAME,@GOODSPACK,@GOODSPACKSTOCK,@GOODSRKSL,@GOODSSTOCK,@ARFEE,@APFEE,@ASSOCIATEDNO,@BLNO,@FREESTORAGEPERIOD,@CONTRACTNO,@GOODSNAME,@GOODSMODEL,@CLIENTCODEOLD,@CLIENTNAMEOLD,@STORAGENAME,@CHARGEUNIT,@ISLOCK,@LOCKUSER,getdate(),@STARTBILLINGDATE,@CUSTOMNO,@CUSTNO,@GOODSSTANDARD,@ARCLIENT,@ISCHANGE,@FREESTORAGEPERIODAP,@STARTBILLINGDATEAP,@CORPID,@BZTCHNO,@CREATEUSER,getdate())";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSql, parameters);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -9;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
//
|
|
|
#region 插入入库明细表
|
|
|
//
|
|
|
//保存出库单明细wms_out_detail
|
|
|
int n = 0;
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
{
|
|
|
n = n + 1;
|
|
|
#region 提取出库相对应的原入库wms_in数据
|
|
|
string SQL_SELECT_WMS_IN_GID = "select top 1 GID,ASSOCIATEDNO,BLNO,CONTRACTNO,CNTRNO,SEALNO,BSNO,CLIENTCODE,CLIENTNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSRKSL,GOODSSTOCK,ISLOCK,LOCKTIME,LOCKUSER,ISDELETE,DELETETIME,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,REMARK,FREESTORAGEPERIOD,GOODSPACKSTOCK,GOODSKGS,CLIENTCODEOLD,CLIENTNAMEOLD,KINDPKGS,ARFEE,APFEE,CTNALL,GOODSTHICKNESS,GOODSWIDTH,GOODSLENGTH,GOODSSLICE,GOODSGRADE,STACKLOCATION,CORPID,LINENUM from wms_in where gid='" + WmsOutDetailEntity.INBSNO.ToString().Trim() + "' and ISDELETE=0";
|
|
|
sqlRead = SqlHelper.ExecuteQueryReader(sqlTran, CommandType.Text, SQL_SELECT_WMS_IN_GID, null);
|
|
|
while (sqlRead.Read())
|
|
|
{
|
|
|
if (!sqlRead.IsDBNull(0)) { WmsInEntity.GID = sqlRead.GetString(0); }// 惟一编号
|
|
|
if (!sqlRead.IsDBNull(1)) { WmsInEntity.ASSOCIATEDNO = sqlRead.GetString(1); }// 关联号
|
|
|
if (!sqlRead.IsDBNull(2)) { WmsInEntity.BLNO = sqlRead.GetString(2); }// 提单号
|
|
|
if (!sqlRead.IsDBNull(3)) { WmsInEntity.CONTRACTNO = sqlRead.GetString(3); }// 合同号
|
|
|
if (!sqlRead.IsDBNull(4)) { WmsInEntity.CNTRNO = sqlRead.GetString(4); }// 箱号
|
|
|
if (!sqlRead.IsDBNull(5)) { WmsInEntity.SEALNO = sqlRead.GetString(5); }// 封号
|
|
|
if (!sqlRead.IsDBNull(6)) { WmsInEntity.BSNO = sqlRead.GetString(6); }// 仓单明细号
|
|
|
if (!sqlRead.IsDBNull(7)) { WmsInEntity.CLIENTCODE = sqlRead.GetString(7); }// 客户编码
|
|
|
if (!sqlRead.IsDBNull(8)) { WmsInEntity.CLIENTNAME = sqlRead.GetString(8); }// 客户名称
|
|
|
if (!sqlRead.IsDBNull(9)) { WmsInEntity.DODATE = sqlRead.GetDateTime(9); }// 操作时间
|
|
|
if (!sqlRead.IsDBNull(10)) { WmsInEntity.STORAGECODE = sqlRead.GetString(10); }// 仓库编码
|
|
|
if (!sqlRead.IsDBNull(11)) { WmsInEntity.STORAGENAME = sqlRead.GetString(11); }// 仓库名称
|
|
|
if (!sqlRead.IsDBNull(12)) { WmsInEntity.AREACODE = sqlRead.GetString(12); }// 库位编码
|
|
|
if (!sqlRead.IsDBNull(13)) { WmsInEntity.AREANAME = sqlRead.GetString(13); }// 库位名称
|
|
|
if (!sqlRead.IsDBNull(14)) { WmsInEntity.GOODSCODE = sqlRead.GetString(14); }// 货物编号
|
|
|
if (!sqlRead.IsDBNull(15)) { WmsInEntity.GOODSNAME = sqlRead.GetString(15); }// 货物名称
|
|
|
if (!sqlRead.IsDBNull(16)) { WmsInEntity.GOODSTYPE = sqlRead.GetString(16); }// 货物类型
|
|
|
if (!sqlRead.IsDBNull(17)) { WmsInEntity.GOODSMODEL = sqlRead.GetString(17); }// 型号
|
|
|
if (!sqlRead.IsDBNull(18)) { WmsInEntity.GOODSSTANDARD = sqlRead.GetString(18); }// 规格
|
|
|
if (!sqlRead.IsDBNull(19)) { WmsInEntity.GOODSPACK = sqlRead.GetDecimal(19); }// 件数
|
|
|
if (!sqlRead.IsDBNull(20)) { WmsInEntity.CHARGEUNIT = sqlRead.GetString(20); }// 计费单位
|
|
|
//if (!sqlRead.IsDBNull(21)) { WmsInEntity.CHARGEPRICE = sqlRead.GetDecimal(21); }// 计费单价
|
|
|
if (!sqlRead.IsDBNull(21)) { WmsInEntity.GOODSRKSL = sqlRead.GetDecimal(21); }// 入库量
|
|
|
if (!sqlRead.IsDBNull(22)) { WmsInEntity.GOODSSTOCK = sqlRead.GetDecimal(22); }// 库存量
|
|
|
if (!sqlRead.IsDBNull(23)) { WmsInEntity.ISLOCK = sqlRead.GetBoolean(23); }// 是否锁定
|
|
|
if (!sqlRead.IsDBNull(24)) { WmsInEntity.LOCKTIME = sqlRead.GetDateTime(24); }// 锁定时间
|
|
|
if (!sqlRead.IsDBNull(25)) { WmsInEntity.LOCKUSER = sqlRead.GetString(25); }// 锁定操作人
|
|
|
if (!sqlRead.IsDBNull(26)) { WmsInEntity.ISDELETE = sqlRead.GetBoolean(26); }// 是否废除
|
|
|
if (!sqlRead.IsDBNull(27)) { WmsInEntity.DELETETIME = sqlRead.GetDateTime(27); }// 废除时间
|
|
|
if (!sqlRead.IsDBNull(28)) { WmsInEntity.DELETEUSER = sqlRead.GetString(28); }// 废除操作人
|
|
|
if (!sqlRead.IsDBNull(29)) { WmsInEntity.CREATEUSER = sqlRead.GetString(29); }// 创建人
|
|
|
if (!sqlRead.IsDBNull(30)) { WmsInEntity.CREATETIME = sqlRead.GetDateTime(30); }// 创建时间
|
|
|
if (!sqlRead.IsDBNull(31)) { WmsInEntity.MODIFIEDUSER = sqlRead.GetString(31); }// 最后一次更新操作人
|
|
|
if (!sqlRead.IsDBNull(32)) { WmsInEntity.MODIFIEDTIME = sqlRead.GetDateTime(32); }// 最后一次更新操作时间
|
|
|
if (!sqlRead.IsDBNull(33)) { WmsInEntity.REMARK = sqlRead.GetString(33); }// 备注
|
|
|
if (!sqlRead.IsDBNull(34)) { WmsInEntity.FREESTORAGEPERIOD = sqlRead.GetInt32(34); }// 免仓储期
|
|
|
if (!sqlRead.IsDBNull(35)) { WmsInEntity.GOODSPACKSTOCK = sqlRead.GetDecimal(35); }// 剩余件数
|
|
|
if (!sqlRead.IsDBNull(36)) { WmsInEntity.GOODSKGS = sqlRead.GetDecimal(36); }// 重量
|
|
|
if (!sqlRead.IsDBNull(37)) { WmsInEntity.CLIENTCODEOLD = sqlRead.GetString(37); }// 原客户编码
|
|
|
if (!sqlRead.IsDBNull(38)) { WmsInEntity.CLIENTNAMEOLD = sqlRead.GetString(38); }// 原客户名称
|
|
|
if (!sqlRead.IsDBNull(39)) { WmsInEntity.KINDPKGS = sqlRead.GetString(39); }//
|
|
|
if (!sqlRead.IsDBNull(40)) { WmsInEntity.ARFEE = sqlRead.GetDecimal(40); }//
|
|
|
if (!sqlRead.IsDBNull(41)) { WmsInEntity.APFEE = sqlRead.GetDecimal(41); }//
|
|
|
if (!sqlRead.IsDBNull(42)) { WmsInEntity.CTNALL = sqlRead.GetString(42); }//
|
|
|
if (!sqlRead.IsDBNull(43)) { WmsInEntity.GOODSTHICKNESS = sqlRead.GetDecimal(43); }//
|
|
|
if (!sqlRead.IsDBNull(44)) { WmsInEntity.GOODSWIDTH = sqlRead.GetDecimal(44); }//
|
|
|
if (!sqlRead.IsDBNull(45)) { WmsInEntity.GOODSLENGTH = sqlRead.GetDecimal(45); }//
|
|
|
if (!sqlRead.IsDBNull(46)) { WmsInEntity.GOODSSLICE = sqlRead.GetDecimal(46); }//
|
|
|
if (!sqlRead.IsDBNull(47)) { WmsInEntity.GOODSGRADE = sqlRead.GetString(47); }//
|
|
|
if (!sqlRead.IsDBNull(48)) { WmsInEntity.STACKLOCATION = sqlRead.GetString(48); }//
|
|
|
if (!sqlRead.IsDBNull(49)) { WmsInEntity.CORPID = sqlRead.GetString(49); }//
|
|
|
if (!sqlRead.IsDBNull(50)) { WmsInEntity.LINENUM = sqlRead.GetInt32(50); }//
|
|
|
}
|
|
|
sqlRead.Close();
|
|
|
sqlRead.Dispose();
|
|
|
#endregion
|
|
|
WmsInEntity.GID = Guid.NewGuid().ToString();
|
|
|
WmsInEntity.ASSOCIATEDNO = WmsEntity.GID;
|
|
|
//
|
|
|
#region 提取规则编号 getCodeRule("入库明细单号", "BSNO", "wms_in")
|
|
|
// <summary>
|
|
|
// 提取规则编号
|
|
|
// </summary>
|
|
|
// <param name="strRULENAME">规则项目名称</param>
|
|
|
// <param name="strfield">需要加规则的字段</param>
|
|
|
// <returns></returns>
|
|
|
//protected String getCodeRule(string strRULENAME, string strfield)
|
|
|
//{
|
|
|
//调用编码规则
|
|
|
string tbBSNO = "";
|
|
|
strRULEYEAR1 = "";
|
|
|
strRULECONTENT1 = "";
|
|
|
strCODENAME1 = "";
|
|
|
strDEPTNO1 = "";
|
|
|
strRULENOLENGTH1 = "";
|
|
|
iRULENOLENGTH1 = 0;
|
|
|
inum1 = 0;
|
|
|
strCONTENT1 = "";
|
|
|
ds2 = T_ALL_DA.GetAllSQL("select *,getdate() DODATE from code_rule where RULENAME='入库明细单号' and RULETYPE=3");
|
|
|
if (ds2 != null)
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
getCodeRuleEnabled("入库明细单号", "BSNO");
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
//return "";
|
|
|
tbBSNO = "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds2.Tables[0].Rows[0]["DODATE"].ToString().Trim());
|
|
|
if (ds2.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yyyy") + dETD.ToString("MM");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yy") + dETD.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
|
|
|
{
|
|
|
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
|
|
|
if (ds2.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strCODENAME1 = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
}
|
|
|
if (ds2.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strDEPTNO1 = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
}
|
|
|
strRULECONTENT1 = ds2.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
|
|
|
strRULECONTENT1 = strRULECONTENT1.Replace("《COMPANY》", strCODENAME1);
|
|
|
strRULECONTENT1 = strRULECONTENT1.Replace("《DEPT》", strDEPTNO1);
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
|
|
|
{
|
|
|
iRULENOLENGTH1 = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iRULENOLENGTH1 = int.Parse(ds2.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
|
|
|
}
|
|
|
strCONTENT1 = strRULECONTENT1 + strRULEYEAR1;
|
|
|
//
|
|
|
//获取分公司的票号头字符
|
|
|
string tempBANKSHEAD = "";
|
|
|
string strSQL = "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'";
|
|
|
DataSet ds21 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds21 != null)
|
|
|
{
|
|
|
if (ds21.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
tempBANKSHEAD = ds21.Tables[0].Rows[0]["BANKSHEAD"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
strCONTENT1 = tempBANKSHEAD + strCONTENT1;
|
|
|
//
|
|
|
strSQL = "select top 1 BSNO from [wms_in] where BSNO like '" + strCONTENT1.Trim() + "%' order by BSNO DESC";
|
|
|
ds21 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds21 != null)
|
|
|
{
|
|
|
if (ds21.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
strRULENOLENGTH1 = ds21.Tables[0].Rows[0]["BSNO"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
if (strRULENOLENGTH1 == "")
|
|
|
{
|
|
|
strRULENOLENGTH1 = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strRULENOLENGTH1 = strRULENOLENGTH1.Replace(strCONTENT1.Trim(), "");
|
|
|
inum1 = int.Parse(strRULENOLENGTH1.Trim());
|
|
|
inum1 = inum1 + 1;
|
|
|
strRULENOLENGTH1 = inum1.ToString();
|
|
|
}
|
|
|
int j = iRULENOLENGTH1 - strRULENOLENGTH1.Length;
|
|
|
for (int i = 1; i <= j; i++)
|
|
|
{
|
|
|
strRULENOLENGTH1 = "0" + strRULENOLENGTH1;
|
|
|
}
|
|
|
//
|
|
|
strCONTENT1 = strCONTENT1 + strRULENOLENGTH1;
|
|
|
tbBSNO = strCONTENT1;
|
|
|
//return strCONTENT1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// return "";
|
|
|
//}
|
|
|
#endregion
|
|
|
WmsInEntity.BSNO = tbBSNO;//调用编码规则
|
|
|
//
|
|
|
WmsInEntity.DODATE = model.DODATE;
|
|
|
WmsInEntity.CLIENTNAME = this.h_outcustomer.Value.ToString().Trim();
|
|
|
WmsInEntity.GOODSRKSL = WmsOutDetailEntity.GOODSPFSL;//入库数量
|
|
|
WmsInEntity.GOODSSTOCK = WmsOutDetailEntity.GOODSPFSL;//入库数量
|
|
|
WmsInEntity.GOODSPACK = WmsOutDetailEntity.GOODSPACKPFSL;//件数
|
|
|
WmsInEntity.GOODSPACKSTOCK = WmsOutDetailEntity.GOODSPACKPFSL;//件数
|
|
|
WmsInEntity.REMARK = "货权转移";
|
|
|
WmsInEntity.CREATEUSER = strUserID;// 创建人
|
|
|
WmsInEntity.MODIFIEDUSER = strUserID;// 最后一次更新操作人
|
|
|
WmsInEntity.CLIENTNAMEOLD = WmsOutDetailEntity.CUSTOMERNAME;//货权转移前货主
|
|
|
WmsInEntity.ARFEE = 0;
|
|
|
WmsInEntity.APFEE = 0;
|
|
|
WmsInEntity.ISLOCK = false;// true;
|
|
|
WmsInEntity.LOCKUSER = strUserID;
|
|
|
WmsInEntity.ISCHANGE = true;
|
|
|
WmsInEntity.CORPID = strCompanyID;
|
|
|
|
|
|
SqlParameter[] parms = new SqlParameter[]{
|
|
|
new SqlParameter("@GID",SqlDbType.VarChar,100),//惟一编号
|
|
|
new SqlParameter("@ASSOCIATEDNO",SqlDbType.VarChar,100),//关联号
|
|
|
new SqlParameter("@BLNO",SqlDbType.VarChar,30),//提单号
|
|
|
new SqlParameter("@CONTRACTNO",SqlDbType.VarChar,100),//合同号
|
|
|
new SqlParameter("@CNTRNO",SqlDbType.VarChar,30),//箱号
|
|
|
new SqlParameter("@SEALNO",SqlDbType.VarChar,12),//封号
|
|
|
new SqlParameter("@BSNO",SqlDbType.VarChar,100),//仓单明细号
|
|
|
new SqlParameter("@CLIENTCODE",SqlDbType.VarChar,20),//客户编码
|
|
|
new SqlParameter("@CLIENTNAME",SqlDbType.VarChar,20),//客户名称
|
|
|
new SqlParameter("@STORAGECODE",SqlDbType.VarChar,50),//仓库编码
|
|
|
new SqlParameter("@STORAGENAME",SqlDbType.VarChar,100),//仓库名称
|
|
|
new SqlParameter("@AREACODE",SqlDbType.VarChar,50),//库位编码
|
|
|
new SqlParameter("@AREANAME",SqlDbType.VarChar,100),//库位名称
|
|
|
new SqlParameter("@GOODSCODE",SqlDbType.VarChar,50),//货物编号
|
|
|
new SqlParameter("@GOODSNAME",SqlDbType.VarChar,100),//货物名称/品名
|
|
|
new SqlParameter("@GOODSTYPE",SqlDbType.VarChar,50),//货物类型
|
|
|
new SqlParameter("@GOODSMODEL",SqlDbType.VarChar,100),//型号
|
|
|
new SqlParameter("@GOODSSTANDARD",SqlDbType.VarChar,100),//规格
|
|
|
new SqlParameter("@GOODSPACK",SqlDbType.Decimal),//件数
|
|
|
new SqlParameter("@CHARGEUNIT",SqlDbType.VarChar,10),//计费单位
|
|
|
//new SqlParameter("@CHARGEPRICE",SqlDbType.Decimal),//计费单价
|
|
|
new SqlParameter("@GOODSRKSL",SqlDbType.Decimal),//入库量
|
|
|
new SqlParameter("@GOODSSTOCK",SqlDbType.Decimal) ,//库存量
|
|
|
new SqlParameter("@ISLOCK",SqlDbType.Bit),//是否锁定
|
|
|
new SqlParameter("@LOCKUSER",SqlDbType.VarChar,36),//锁定操作人
|
|
|
new SqlParameter("@ISDELETE",SqlDbType.Bit),//是否废除
|
|
|
new SqlParameter("@DELETEUSER",SqlDbType.VarChar,36),//废除操作人
|
|
|
new SqlParameter("@CREATEUSER",SqlDbType.VarChar,36),//创建人
|
|
|
new SqlParameter("@MODIFIEDUSER",SqlDbType.VarChar,36),//最后一次更新操作人
|
|
|
new SqlParameter("@REMARK",SqlDbType.VarChar,1024),//备注
|
|
|
new SqlParameter("@FREESTORAGEPERIOD",SqlDbType.Int),//
|
|
|
new SqlParameter("@GOODSPACKSTOCK",SqlDbType.Decimal),//
|
|
|
new SqlParameter("@GOODSKGS",SqlDbType.Decimal),//重量
|
|
|
new SqlParameter("@CLIENTCODEOLD",SqlDbType.VarChar,20),//原客户编码
|
|
|
new SqlParameter("@CLIENTNAMEOLD",SqlDbType.VarChar,20),//原客户名称
|
|
|
new SqlParameter("@KINDPKGS",SqlDbType.VarChar,20),//
|
|
|
new SqlParameter("@ARFEE",SqlDbType.Decimal),//
|
|
|
new SqlParameter("@APFEE",SqlDbType.Decimal),//
|
|
|
new SqlParameter("@CTNALL",SqlDbType.VarChar,10),
|
|
|
new SqlParameter("@GOODSTHICKNESS", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSWIDTH", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSLENGTH", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSSLICE", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSGRADE", SqlDbType.VarChar,50) ,
|
|
|
new SqlParameter("@STACKLOCATION", SqlDbType.VarChar,50) ,
|
|
|
new SqlParameter("@ISCHANGE",SqlDbType.Bit) ,
|
|
|
new SqlParameter("@CORPID", SqlDbType.VarChar,36)
|
|
|
};
|
|
|
|
|
|
parms[0].Value = WmsInEntity.GID;// 惟一编号
|
|
|
parms[1].Value = WmsInEntity.ASSOCIATEDNO;// 关联号
|
|
|
parms[2].Value = WmsInEntity.BLNO;// 提单号
|
|
|
parms[3].Value = WmsInEntity.CONTRACTNO;// 合同号
|
|
|
parms[4].Value = WmsInEntity.CNTRNO;// 箱号
|
|
|
parms[5].Value = WmsInEntity.SEALNO;// 封号
|
|
|
parms[6].Value = WmsInEntity.BSNO;// 仓单明细号
|
|
|
parms[7].Value = WmsInEntity.CLIENTCODE;// 客户编码
|
|
|
parms[8].Value = WmsInEntity.CLIENTNAME;// 客户名称
|
|
|
parms[9].Value = WmsInEntity.STORAGECODE;// 仓库编码
|
|
|
parms[10].Value = WmsInEntity.STORAGENAME;// 仓库名称
|
|
|
parms[11].Value = WmsInEntity.AREACODE;// 库位编码
|
|
|
parms[12].Value = WmsInEntity.AREANAME;// 库位名称
|
|
|
parms[13].Value = WmsInEntity.GOODSCODE;// 货物编号
|
|
|
parms[14].Value = WmsInEntity.GOODSNAME;// 货物名称
|
|
|
parms[15].Value = WmsInEntity.GOODSTYPE;// 货物类型
|
|
|
parms[16].Value = WmsInEntity.GOODSMODEL;// 型号
|
|
|
parms[17].Value = WmsInEntity.GOODSSTANDARD;// 规格
|
|
|
parms[18].Value = WmsInEntity.GOODSPACK;// 件数
|
|
|
parms[19].Value = WmsInEntity.CHARGEUNIT;// 计费单位
|
|
|
//parms[20].Value = WmsInEntity.CHARGEPRICE;// 计费单价
|
|
|
parms[20].Value = WmsInEntity.GOODSRKSL;// 入库量
|
|
|
parms[21].Value = WmsInEntity.GOODSSTOCK;// 库存量
|
|
|
parms[22].Value = WmsInEntity.ISLOCK;// 是否锁定
|
|
|
parms[23].Value = WmsInEntity.LOCKUSER;// 锁定操作人
|
|
|
parms[24].Value = WmsInEntity.ISDELETE;// 是否废除
|
|
|
parms[25].Value = WmsInEntity.DELETEUSER;// 废除操作人
|
|
|
parms[26].Value = WmsInEntity.CREATEUSER;// 创建人
|
|
|
parms[27].Value = WmsInEntity.MODIFIEDUSER;// 最后一次更新操作人
|
|
|
parms[28].Value = WmsInEntity.REMARK;// 备注
|
|
|
parms[29].Value = WmsInEntity.FREESTORAGEPERIOD;//
|
|
|
parms[30].Value = WmsInEntity.GOODSPACKSTOCK;//
|
|
|
parms[31].Value = WmsInEntity.GOODSKGS;// 重量
|
|
|
parms[32].Value = WmsInEntity.CLIENTCODEOLD;// 客户编码
|
|
|
parms[33].Value = WmsInEntity.CLIENTNAMEOLD;// 客户名称
|
|
|
parms[34].Value = WmsInEntity.KINDPKGS;//
|
|
|
parms[35].Value = WmsInEntity.ARFEE;//
|
|
|
parms[36].Value = WmsInEntity.APFEE;//
|
|
|
parms[37].Value = WmsInEntity.CTNALL;//
|
|
|
parms[38].Value = WmsInEntity.GOODSTHICKNESS;
|
|
|
parms[39].Value = WmsInEntity.GOODSWIDTH;
|
|
|
parms[40].Value = WmsInEntity.GOODSLENGTH;
|
|
|
parms[41].Value = WmsInEntity.GOODSSLICE;
|
|
|
parms[42].Value = WmsInEntity.GOODSGRADE;
|
|
|
parms[43].Value = WmsInEntity.STACKLOCATION;
|
|
|
parms[44].Value = WmsInEntity.ISCHANGE;
|
|
|
parms[45].Value = WmsInEntity.CORPID;
|
|
|
//
|
|
|
lsSql = "insert into wms_in(GID,ASSOCIATEDNO,BLNO,CONTRACTNO,CNTRNO,SEALNO,BSNO,CLIENTCODE,CLIENTNAME,{0}STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSRKSL,GOODSSTOCK,ISLOCK,LOCKUSER,ISDELETE,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,REMARK,FREESTORAGEPERIOD,GOODSPACKSTOCK,GOODSKGS,CLIENTCODEOLD,CLIENTNAMEOLD,KINDPKGS,ARFEE,APFEE,CTNALL,GOODSTHICKNESS,GOODSWIDTH,GOODSLENGTH,GOODSSLICE,GOODSGRADE,STACKLOCATION,ISCHANGE,CORPID,LINENUM) "
|
|
|
+ " values(@GID,@ASSOCIATEDNO,@BLNO,@CONTRACTNO,@CNTRNO,@SEALNO,@BSNO,@CLIENTCODE,@CLIENTNAME,{1}@STORAGECODE,@STORAGENAME,@AREACODE,@AREANAME,@GOODSCODE,@GOODSNAME,@GOODSTYPE,@GOODSMODEL,@GOODSSTANDARD,@GOODSPACK,@CHARGEUNIT,@GOODSRKSL,@GOODSSTOCK,@ISLOCK,@LOCKUSER,@ISDELETE,@DELETEUSER,@CREATEUSER,getdate(),@MODIFIEDUSER,getdate(),@REMARK,@FREESTORAGEPERIOD,@GOODSPACKSTOCK,@GOODSKGS,@CLIENTCODEOLD,@CLIENTNAMEOLD,@KINDPKGS,@ARFEE,@APFEE,@CTNALL,@GOODSTHICKNESS,@GOODSWIDTH,@GOODSLENGTH,@GOODSSLICE,@GOODSGRADE,@STACKLOCATION,@ISCHANGE,@CORPID," + n + ")";
|
|
|
//
|
|
|
string strDODATE = model.DODATE.ToString().IndexOf("0001") > -1 ? "" : "'" + model.DODATE.ToString() + "',";
|
|
|
string strDODATE_name = strDODATE.Equals("") ? "" : "DODATE,";
|
|
|
lsSql = String.Format(lsSql, strDODATE_name, strDODATE);
|
|
|
//
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSql, parms);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -9;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//
|
|
|
#region 依据原入库的费率,插入货权转移的仓储应付费率设置wms_rate
|
|
|
lsSql = "insert into wms_rate([GID],[FEEGRADE],[FEESCALE],[FEEPRICE],[FEEUNIT],[CREATEUSER],[CREATETIME],[MODIFIEDUSER],[MODIFIEDTIME],[REMARK],[BSNO],[CUSTOMERNAME],[FEETYPE],[ENDBILLINGDATE],[ADDPRICE],[RATETYPE],[FEENAME],[ISCHANGE],[CAPPRICE]) select newid(),1,[FEESCALE],[FEEPRICE],[FEEUNIT],[CREATEUSER],getdate(),[MODIFIEDUSER],getdate(),[REMARK],'" + strINGIDNEW.Trim() + "','" + WmsEntity.CUSTOMERNAME.ToString().Trim() + "',[FEETYPE],[ENDBILLINGDATE],[ADDPRICE],[RATETYPE],[FEENAME],'True',CAPPRICE from wms_rate where FEETYPE=2 and BSNO=(select top 1 ASSOCIATEDNO from wms_in where gid='" + Inbsno.Trim() + "')";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSql, parameters);
|
|
|
if (iState < 0)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -9;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
//
|
|
|
#endregion
|
|
|
//
|
|
|
this.h_newcust.Value = WmsInEntity.CLIENTNAME;
|
|
|
this.h_IsSetRate.Value = "1"; //货权转移,可以设置费率
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
sqlTran.Commit();
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParent('" + WmsOutEntity.GID.ToString().Trim() + "','addwmsout','" + WmsEntity.GID.ToString().Trim() + "','" + WmsEntity.ASSOCIATEDNO.ToString().Trim() + "');</script>");
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
result = -1;//有异常,插入失败
|
|
|
sqlTran.Rollback();
|
|
|
result = -2;//插入异常,事务已回滚成功
|
|
|
Clearh();
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 更改货权转移
|
|
|
/// <summary>
|
|
|
/// 更改货权转移
|
|
|
/// </summary>
|
|
|
private int CargoRightTransferEdit()
|
|
|
{
|
|
|
int iState = 0;
|
|
|
int result = 0;
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
Decimal totaloutfee = 0;//出库单的仓储费
|
|
|
//int prescale = 0;
|
|
|
//int nowscale = 0;
|
|
|
//int nowgrade = 0;
|
|
|
//Decimal price = 0;
|
|
|
//Decimal gradefee = 0;
|
|
|
//string newGID = "";
|
|
|
Decimal sumfee = 0;
|
|
|
string bsno = "";
|
|
|
|
|
|
//出库单信息
|
|
|
WmsOutDA WmsOutDA = new WmsOutDA();
|
|
|
WmsOutEntity WmsOutEntity = new WmsOutEntity();
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutEntity = ResolveWoJSON(WoJSON.Trim(), WmsOutEntity);
|
|
|
WoContainer.Value = "";
|
|
|
}
|
|
|
//出库单明细信息
|
|
|
WmsOutDetailDA WmsOutDetailDA = new WmsOutDetailDA();
|
|
|
IList<WmsOutDetailEntity> WmsOutDetailEntitys = new List<WmsOutDetailEntity>();
|
|
|
if (!WoDetailJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutDetailEntitys = ResolveWoDetailJSON(WoDetailJSON.Trim(), WmsOutDetailEntitys);
|
|
|
this.WoDetailContainer.Value = "";
|
|
|
}
|
|
|
Decimal outnums = 0;
|
|
|
int feedays = 0;
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
#region 生成出库单并计算费用
|
|
|
#region 保存出库单wms_out 出库单明细wms_out_detail
|
|
|
//保存出库单wms_out
|
|
|
string ls = WmsOutEntity.TRUCKNO.ToString().Trim();
|
|
|
ls = ls.Replace("??", " ");
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
//
|
|
|
Sqlstr = String.Format("update wms_out set BSNO='{1}',CUSTOMERNAME='{2}',DODATE='{3}',STORAGENAME='{4}',GOODSNAME='{5}',GOODSMODEL='{6}',GOODSPFSL='{7}',REMARK='{8}',CREATEUSER='{9}',CREATETIME=getdate(),TRUCKNO='{10}',ASSOCIATEDNO='{11}',GOODSPACKPFSL='{12}',INSPECTIONNO='{13}',CUSTOMNO='{14}',CLIENTNAMEOLD='{15}',OLDCUSTFEEDATE='{16}',TRUCKNAME='{17}',ARCLIENT='{18}',TOTALNO='{19}',CORPID='{20}' where GID='{0}'"
|
|
|
, WmsOutEntity.GID, WmsOutEntity.BSNO, WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.GOODSNAME, WmsOutEntity.GOODSMODEL, WmsOutEntity.GOODSPFSL, WmsOutEntity.REMARK, strUserID, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL, WmsOutEntity.INSPECTIONNO, WmsOutEntity.CUSTOMNO, WmsOutEntity.CLIENTNAMEOLD, WmsOutEntity.OLDCUSTFEEDATE, WmsOutEntity.TRUCKNAME, WmsOutEntity.ARCLIENT, WmsOutEntity.TOTALNO,strCompanyID);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -1;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//保存出库单明细wms_out_detail
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
{
|
|
|
if (DateTime.Parse(WmsOutDetailEntity.DODATE.ToString("yyyy-MM-dd")) > DateTime.Parse(WmsOutEntity.DODATE.ToString("yyyy-MM-dd")))
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -12;
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key10", "<script>alert('出库日期不能小于入库日期!');</script>");
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//
|
|
|
WmsOutDetailEntity.OUTBSNO = WmsOutEntity.BSNO;
|
|
|
outnums = Decimal.Parse(WmsOutDetailEntity.GOODSPFSL.ToString());//出库量
|
|
|
|
|
|
#region 计算仓储费
|
|
|
//计算应收仓储费
|
|
|
string getstr = WmsOutDetailDA.getWmsRate(sqlTran, WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim(), WmsOutDetailEntity.INBSNO.ToString().Trim(), WmsOutEntity.CUSTOMERNAME.ToString().Trim(), outnums, WmsOutDetailEntity.GID.ToString(), 1, strUserID, strShowName, this.txt_outbsno.Value.Trim(), this.ck_jsfee.Checked, false);
|
|
|
|
|
|
string[] strls = getstr.Trim().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
sumfee = Decimal.Parse(strls[0].ToString());
|
|
|
totaloutfee += sumfee;//仓储费合计
|
|
|
feedays += int.Parse(strls[1].ToString());
|
|
|
#endregion
|
|
|
|
|
|
//保存wms_out_detail
|
|
|
WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = (sumfee == 0 ? 0 : decimal.Parse(Round(sumfee, 2, "").ToString()));
|
|
|
WmsOutDetailEntity.GOODSOUTFEEAP = 0;
|
|
|
WmsOutDetailEntity.ENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim().IndexOf("0001") > -1 ? DateTime.Parse("0001-01-01 00:00:00") : WmsOutEntity.OLDCUSTFEEDATE;//结束计费日期
|
|
|
WmsOutDetailEntity.FEEDAYS = feedays;//计费天数iFEEDAYS
|
|
|
WmsOutDetailEntity.FEEDAYSAP = 0;//计费天数iFEEDAYS
|
|
|
//
|
|
|
//bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
#region 提取规则编号 getCodeRuleWmsOutDetail
|
|
|
// <summary>
|
|
|
// 提取规则编号
|
|
|
// </summary>
|
|
|
// <param name="strRULENAME">规则项目名称</param>
|
|
|
// <param name="strfield">需要加规则的字段</param>
|
|
|
// <returns></returns>
|
|
|
//protected String getCodeRuleWmsOutDetail(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 *,getdate() DODATE from code_rule where RULENAME='出库明细单号' 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("出库明细单号", "BSNO");
|
|
|
//
|
|
|
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
//return "";
|
|
|
bsno = "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().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='" + strUserID + "')");
|
|
|
}
|
|
|
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='" + strUserID + "')");
|
|
|
}
|
|
|
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;
|
|
|
//
|
|
|
string strSQL = "select top 1 BSNO from [wms_out_detail] where BSNO like '" + strCONTENT.Trim() + "%' order by BSNO DESC";
|
|
|
DataSet ds1 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds1 != null)
|
|
|
{
|
|
|
if (ds1.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
strRULENOLENGTH = ds1.Tables[0].Rows[0]["BSNO"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
bsno = strCONTENT;
|
|
|
//return strCONTENT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// return "";
|
|
|
//}
|
|
|
#endregion
|
|
|
//
|
|
|
//newGID = Guid.NewGuid().ToString();
|
|
|
//WmsOutDetailEntity.GID = newGID;
|
|
|
//WmsOutDetailEntity.BSNO = bsno;
|
|
|
WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
//
|
|
|
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
|
|
|
ls = ls.Replace("??", " ");
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
//
|
|
|
string strSTARTBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "STARTBILLINGDATE='" + WmsOutDetailEntity.STARTBILLINGDATE.ToString() + "',";
|
|
|
//
|
|
|
string strENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "ENDBILLINGDATE='" + WmsOutDetailEntity.DODATE.ToString() + "',";//如果开始计费日期为空,则结束计费日期也为空,否则为出库日期。
|
|
|
//
|
|
|
//修改入库单wms_in
|
|
|
Sqlstr = String.Format("update wms_in set GOODSPACKSTOCK=GOODSPACKSTOCK+(select top 1 GOODSPACKPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{0},GOODSSTOCK=GOODSSTOCK+(select top 1 GOODSPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{2} where isnull(ISDELETE,0)=0 and gid='{1}' ", WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.GOODSPFSL);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;
|
|
|
//Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//修改入库单wms
|
|
|
Sqlstr = String.Format("update wms set GOODSPACKSTOCK=GOODSPACKSTOCK+(select top 1 GOODSPACKPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{0},GOODSSTOCK=GOODSSTOCK+(select top 1 GOODSPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{2} where isnull(ISDELETE,0)=0 and gid=(select top 1 ASSOCIATEDNO from wms_in where gid='{1}') ", WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.GOODSPFSL);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -6;
|
|
|
//Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//
|
|
|
Sqlstr = String.Format("update wms_out_detail set INBSNO='{1}',OUTBSNO='{2}',BSNO='{3}',CUSTOMERNAME='{4}',DODATE='{5}',STORAGENAME='{6}',GOODSNAME='{7}',GOODSMODEL='{8}',GOODSPFSL='{9}',GOODSOUTFEE='{10}',CREATEUSER='{11}',CREATETIME=getdate(),REMARK='{12}',TRUCKNO='{13}',ASSOCIATEDNO='{14}',GOODSPACKPFSL='{15}',GOODSOUTFEEAP='{16}',ARFEE='{17}',APFEE='{18}',CLIENTNAMEOLD='{19}',OLDCUSTFEEDATE='{20}',{21}{22}FEEDAYS='{23}',GOODSSTANDARD='{24}',GOODSGRADE='{25}',GOODSSLICE='{26}',CORPID='{27}' where GID='{0}'"
|
|
|
, WmsOutDetailEntity.GID, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.OUTBSNO, WmsOutDetailEntity.BSNO, WmsOutDetailEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutDetailEntity.STORAGENAME, WmsOutDetailEntity.GOODSNAME, WmsOutDetailEntity.GOODSMODEL, WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.GOODSOUTFEE, strUserID, WmsOutDetailEntity.REMARK, ls, WmsOutDetailEntity.ASSOCIATEDNO, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.GOODSOUTFEEAP, WmsOutDetailEntity.ARFEE, WmsOutDetailEntity.APFEE,
|
|
|
WmsOutDetailEntity.CLIENTNAMEOLD, this.txt_oldcustFeeDate.Value.Trim(), strSTARTBILLINGDATE, strENDBILLINGDATE, WmsOutDetailEntity.FEEDAYS, WmsOutDetailEntity.GOODSSTANDARD, WmsOutDetailEntity.GOODSGRADE, WmsOutDetailEntity.GOODSSLICE, strCompanyID);
|
|
|
//
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -5;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
}// end 保存出库明细wms_out_detail
|
|
|
|
|
|
//修改wms_out的出库量、出库件数、应收应付装卸费
|
|
|
string lsSQL = "update wms_out set "
|
|
|
+ "GOODSPFSL=(select isnull(sum(GOODSPFSL),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",GOODSPACKPFSL=(select isnull(sum(GOODSPACKPFSL),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",ARFEE=(select isnull(sum(ARFEE),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ ",APFEE=(select isnull(sum(APFEE),0) from wms_out_detail where OUTBSNO=wms_out.BSNO)"
|
|
|
+ " where ISLOCK=0 and GID='" + WmsOutEntity.GID.ToString().Trim() + "'";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSQL, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -7;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//修改wms_out的仓储费wmsOutEntity.GOODSOUTFEE
|
|
|
h_outfee.Value = totaloutfee.ToString();
|
|
|
WmsOutEntity.GOODSOUTFEE = decimal.Parse(Round(totaloutfee, 2, "").ToString());
|
|
|
WmsOutEntity.GOODSOUTFEEAP = 0;
|
|
|
|
|
|
Sqlstr = String.Format("update wms_out set GOODSOUTFEE={0},GOODSOUTFEEAP={2} where GID='{1}'", WmsOutEntity.GOODSOUTFEE, WmsOutEntity.GID, WmsOutEntity.GOODSOUTFEEAP);
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -7;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
//页面赋值
|
|
|
this.h_wmsoutbsno.Value = WmsOutEntity.BSNO.ToString();
|
|
|
this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL.ToString();
|
|
|
this.h_goodspfsl.Value = WmsOutEntity.GOODSPFSL.ToString();
|
|
|
this.h_totalno.Value = WmsOutEntity.TOTALNO.ToString();
|
|
|
this.h_remark.Value = WmsOutEntity.REMARK.ToString();
|
|
|
|
|
|
txt_outbsno.Value = h_outbsno.Value;
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
string strcustomer = h_customer.Value;
|
|
|
string goods = h_goods.Value;
|
|
|
txt_goodsmodel.Value = h_goodsmodel.Value;
|
|
|
#endregion
|
|
|
|
|
|
#region 货权转移到 outcustomer.value
|
|
|
WmsInEntity WmsInEntity = new WmsInEntity();
|
|
|
WmsInDA wmsinDA = new WmsInDA();
|
|
|
WmsEntity WmsEntity = new WmsEntity();
|
|
|
WmsDA wmsDA = new WmsDA();
|
|
|
//
|
|
|
//
|
|
|
#region 提取货权转移的wms_out的数据
|
|
|
WmsOutEntity model = new WmsOutEntity();
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
string SQL_SELECT_WMS_OUT_GID = "select top 1 GID, AREACODE, AREANAME, GOODSCODE, GOODSNAME, GOODSTYPE, GOODSMODEL, GOODSSTANDARD, GOODSPACK, GOODSPFSL, GOODSOUTFEE, ASSOCIATEDNO, TRUCKNO, REMARK, ISDELETE, DELETETIME, DELETEUSER, CREATEUSER, CREATETIME, MODIFIEDUSER, MODIFIEDTIME, GOODSPACKPFSL, BSNO, TRUCKNAME, WMSOP, STOREMAN, ISLOCK, LOCKUSER, LOCKTIME, GOODSOUTFEEAP, ARFEE, APFEE, INSPECTIONNO, CLIENTGID, CUSTOMNO, CORPID, CLIENTNAMEOLD, OLDCUSTFEEDATE, CLIENTBSNO, ARCLIENT, INGIDNEW, TOTALNO, REMARK2, VALIDDATE, CLIENTCODE, CHARGEUNIT, CUSTOMERNAME, DODATE, STORAGECODE, STORAGENAME,TOTALNO,CORPID from wms_out where GID='" + WmsOutEntity.GID.ToString().Trim() + "' ";
|
|
|
SqlDataReader sqlRead1 = SqlHelper.ExecuteQueryReader(sqlTran, CommandType.Text, SQL_SELECT_WMS_OUT_GID, null);
|
|
|
while (sqlRead1.Read())
|
|
|
{
|
|
|
if (sqlRead1["GID"] != null && sqlRead1["GID"].ToString() != "")
|
|
|
{
|
|
|
model.GID = sqlRead1["GID"].ToString();
|
|
|
}
|
|
|
model.GID = sqlRead1["GID"].ToString();
|
|
|
model.AREACODE = sqlRead1["AREACODE"].ToString();
|
|
|
model.AREANAME = sqlRead1["AREANAME"].ToString();
|
|
|
model.GOODSCODE = sqlRead1["GOODSCODE"].ToString();
|
|
|
model.GOODSNAME = sqlRead1["GOODSNAME"].ToString();
|
|
|
model.GOODSTYPE = sqlRead1["GOODSTYPE"].ToString();
|
|
|
model.GOODSMODEL = sqlRead1["GOODSMODEL"].ToString();
|
|
|
model.GOODSSTANDARD = sqlRead1["GOODSSTANDARD"].ToString();
|
|
|
model.GOODSPACK = sqlRead1["GOODSPACK"].ToString();
|
|
|
if (sqlRead1["GOODSPFSL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPFSL = decimal.Parse(sqlRead1["GOODSPFSL"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["GOODSOUTFEE"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSOUTFEE = decimal.Parse(sqlRead1["GOODSOUTFEE"].ToString());
|
|
|
}
|
|
|
model.ASSOCIATEDNO = sqlRead1["ASSOCIATEDNO"].ToString();
|
|
|
model.TRUCKNO = sqlRead1["TRUCKNO"].ToString();
|
|
|
model.TOTALNO = sqlRead1["TOTALNO"].ToString();
|
|
|
model.REMARK = sqlRead1["REMARK"].ToString();
|
|
|
if (sqlRead1["ISDELETE"].ToString() != "")
|
|
|
{
|
|
|
if ((sqlRead1["ISDELETE"].ToString() == "1") || (sqlRead1["ISDELETE"].ToString().ToLower() == "true"))
|
|
|
{
|
|
|
model.ISDELETE = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
model.ISDELETE = false;
|
|
|
}
|
|
|
}
|
|
|
if (sqlRead1["DELETETIME"].ToString() != "")
|
|
|
{
|
|
|
model.DELETETIME = DateTime.Parse(sqlRead1["DELETETIME"].ToString());
|
|
|
}
|
|
|
model.DELETEUSER = sqlRead1["DELETEUSER"].ToString();
|
|
|
model.CREATEUSER = sqlRead1["CREATEUSER"].ToString();
|
|
|
if (sqlRead1["CREATETIME"].ToString() != "")
|
|
|
{
|
|
|
model.CREATETIME = DateTime.Parse(sqlRead1["CREATETIME"].ToString());
|
|
|
}
|
|
|
model.MODIFIEDUSER = sqlRead1["MODIFIEDUSER"].ToString();
|
|
|
if (sqlRead1["MODIFIEDTIME"].ToString() != "")
|
|
|
{
|
|
|
model.MODIFIEDTIME = DateTime.Parse(sqlRead1["MODIFIEDTIME"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["GOODSPACKPFSL"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSPACKPFSL = decimal.Parse(sqlRead1["GOODSPACKPFSL"].ToString());
|
|
|
}
|
|
|
model.BSNO = sqlRead1["BSNO"].ToString();
|
|
|
model.TRUCKNAME = sqlRead1["TRUCKNAME"].ToString();
|
|
|
model.WMSOP = sqlRead1["WMSOP"].ToString();
|
|
|
model.STOREMAN = sqlRead1["STOREMAN"].ToString();
|
|
|
if (sqlRead1["ISLOCK"].ToString() != "")
|
|
|
{
|
|
|
if ((sqlRead1["ISLOCK"].ToString() == "1") || (sqlRead1["ISLOCK"].ToString().ToLower() == "true"))
|
|
|
{
|
|
|
model.ISLOCK = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
model.ISLOCK = false;
|
|
|
}
|
|
|
}
|
|
|
model.LOCKUSER = sqlRead1["LOCKUSER"].ToString();
|
|
|
if (sqlRead1["LOCKTIME"].ToString() != "")
|
|
|
{
|
|
|
model.LOCKTIME = DateTime.Parse(sqlRead1["LOCKTIME"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["GOODSOUTFEEAP"].ToString() != "")
|
|
|
{
|
|
|
model.GOODSOUTFEEAP = decimal.Parse(sqlRead1["GOODSOUTFEEAP"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["ARFEE"].ToString() != "")
|
|
|
{
|
|
|
model.ARFEE = decimal.Parse(sqlRead1["ARFEE"].ToString());
|
|
|
}
|
|
|
if (sqlRead1["APFEE"].ToString() != "")
|
|
|
{
|
|
|
model.APFEE = decimal.Parse(sqlRead1["APFEE"].ToString());
|
|
|
}
|
|
|
model.INSPECTIONNO = sqlRead1["INSPECTIONNO"].ToString();
|
|
|
model.CLIENTGID = sqlRead1["CLIENTGID"].ToString();
|
|
|
model.CUSTOMNO = sqlRead1["CUSTOMNO"].ToString();
|
|
|
model.CORPID = sqlRead1["CORPID"].ToString();
|
|
|
model.CLIENTNAMEOLD = sqlRead1["CLIENTNAMEOLD"].ToString();
|
|
|
if (sqlRead1["OLDCUSTFEEDATE"].ToString() != "")
|
|
|
{
|
|
|
model.OLDCUSTFEEDATE = DateTime.Parse(sqlRead1["OLDCUSTFEEDATE"].ToString());
|
|
|
}
|
|
|
model.CLIENTBSNO = sqlRead1["CLIENTBSNO"].ToString();
|
|
|
model.ARCLIENT = sqlRead1["ARCLIENT"].ToString();
|
|
|
model.INGIDNEW = sqlRead1["INGIDNEW"].ToString();
|
|
|
model.TOTALNO = sqlRead1["TOTALNO"].ToString();
|
|
|
model.REMARK2 = sqlRead1["REMARK2"].ToString();
|
|
|
if (sqlRead1["VALIDDATE"].ToString() != "")
|
|
|
{
|
|
|
model.VALIDDATE = DateTime.Parse(sqlRead1["VALIDDATE"].ToString());
|
|
|
}
|
|
|
model.CLIENTCODE = sqlRead1["CLIENTCODE"].ToString();
|
|
|
model.CHARGEUNIT = sqlRead1["CHARGEUNIT"].ToString();
|
|
|
model.CUSTOMERNAME = sqlRead1["CUSTOMERNAME"].ToString();
|
|
|
if (sqlRead1["DODATE"].ToString() != "")
|
|
|
{
|
|
|
model.DODATE = DateTime.Parse(sqlRead1["DODATE"].ToString());
|
|
|
}
|
|
|
model.STORAGECODE = sqlRead1["STORAGECODE"].ToString();
|
|
|
model.STORAGENAME = sqlRead1["STORAGENAME"].ToString();
|
|
|
model.CORPID = sqlRead1["CORPID"].ToString();
|
|
|
}
|
|
|
sqlRead1.Close();
|
|
|
sqlRead1.Dispose();
|
|
|
#endregion
|
|
|
//
|
|
|
#region 插入入库主表
|
|
|
string strINGIDNEW = model.INGIDNEW.ToString().Trim();//货权转移后的入库wmsgid
|
|
|
#region 提取原入库wms数据
|
|
|
string SQL_SELECT_WMS_GID = "select GID, WMSNO, WMSDATE, CUSTOMERNAME, WMSOP, STOREMAN, MODIFIEDUSER, MODIFIEDTIME, ISDELETE, DELETEUSER, DELETETIME,TRUCKNAME, GOODSPACK, GOODSPACKSTOCK, GOODSRKSL, GOODSSTOCK, ARFEE, APFEE, ASSOCIATEDNO, BLNO, FREESTORAGEPERIOD, CONTRACTNO, GOODSNAME, GOODSMODEL, CLIENTCODEOLD, CLIENTNAMEOLD, STORAGENAME, CHARGEUNIT, STARTBILLINGDATE,CUSTOMNO,CUSTNO,GOODSSTANDARD,ARCLIENT,FREESTORAGEPERIODAP,STARTBILLINGDATEAP,CORPID,BZTCHNO,CREATEUSER,CREATETIME from wms where GID='" + strINGIDNEW.Trim() + "' and ISDELETE=0";
|
|
|
SqlDataReader sqlRead = SqlHelper.ExecuteQueryReader(sqlTran, CommandType.Text, SQL_SELECT_WMS_GID, null);
|
|
|
while (sqlRead.Read())
|
|
|
{
|
|
|
if (!sqlRead.IsDBNull(0)) { WmsEntity.GID = sqlRead.GetString(0); } // 唯一编码 newid()
|
|
|
if (!sqlRead.IsDBNull(1)) { WmsEntity.WMSNO = sqlRead.GetString(1); } //
|
|
|
if (!sqlRead.IsDBNull(2)) { WmsEntity.WMSDATE = sqlRead.GetDateTime(2); } //
|
|
|
if (!sqlRead.IsDBNull(3)) { WmsEntity.CUSTOMERNAME = sqlRead.GetString(3); } //
|
|
|
if (!sqlRead.IsDBNull(4)) { WmsEntity.WMSOP = sqlRead.GetString(4); } //
|
|
|
if (!sqlRead.IsDBNull(5)) { WmsEntity.STOREMAN = sqlRead.GetString(5); }
|
|
|
if (!sqlRead.IsDBNull(6)) { WmsEntity.MODIFIEDUSER = sqlRead.GetString(6); }
|
|
|
if (!sqlRead.IsDBNull(7)) { WmsEntity.MODIFIEDTIME = sqlRead.GetDateTime(7); }
|
|
|
if (!sqlRead.IsDBNull(8)) { WmsEntity.ISDELETE = sqlRead.GetBoolean(8); } // 是否废除
|
|
|
if (!sqlRead.IsDBNull(9)) { WmsEntity.DELETEUSER = sqlRead.GetString(9); } // 废除操作人
|
|
|
if (!sqlRead.IsDBNull(10)) { WmsEntity.DELETETIME = sqlRead.GetDateTime(10); } // 废除时间
|
|
|
if (!sqlRead.IsDBNull(11)) { WmsEntity.TRUCKNAME = sqlRead.GetString(11); } //
|
|
|
if (!sqlRead.IsDBNull(12)) { WmsEntity.GOODSPACK = sqlRead.GetDecimal(12); } //
|
|
|
if (!sqlRead.IsDBNull(13)) { WmsEntity.GOODSPACKSTOCK = sqlRead.GetDecimal(13); } //
|
|
|
if (!sqlRead.IsDBNull(14)) { WmsEntity.GOODSRKSL = sqlRead.GetDecimal(14); } //
|
|
|
if (!sqlRead.IsDBNull(15)) { WmsEntity.GOODSSTOCK = sqlRead.GetDecimal(15); } //
|
|
|
if (!sqlRead.IsDBNull(16)) { WmsEntity.ARFEE = sqlRead.GetDecimal(16); } //
|
|
|
if (!sqlRead.IsDBNull(17)) { WmsEntity.APFEE = sqlRead.GetDecimal(17); } //
|
|
|
if (!sqlRead.IsDBNull(18)) { WmsEntity.ASSOCIATEDNO = sqlRead.GetString(18); } //
|
|
|
if (!sqlRead.IsDBNull(19)) { WmsEntity.BLNO = sqlRead.GetString(19); } //
|
|
|
if (!sqlRead.IsDBNull(20)) { WmsEntity.FREESTORAGEPERIOD = sqlRead.GetInt32(20); } //
|
|
|
if (!sqlRead.IsDBNull(21)) { WmsEntity.CONTRACTNO = sqlRead.GetString(21); } //
|
|
|
if (!sqlRead.IsDBNull(22)) { WmsEntity.GOODSNAME = sqlRead.GetString(22); } //
|
|
|
if (!sqlRead.IsDBNull(23)) { WmsEntity.GOODSMODEL = sqlRead.GetString(23); } //
|
|
|
if (!sqlRead.IsDBNull(24)) { WmsEntity.CLIENTCODEOLD = sqlRead.GetString(24); } //
|
|
|
if (!sqlRead.IsDBNull(25)) { WmsEntity.CLIENTNAMEOLD = sqlRead.GetString(25); } //
|
|
|
if (!sqlRead.IsDBNull(26)) { WmsEntity.STORAGENAME = sqlRead.GetString(26); } //
|
|
|
if (!sqlRead.IsDBNull(27)) { WmsEntity.CHARGEUNIT = sqlRead.GetString(27); } //
|
|
|
if (!sqlRead.IsDBNull(28)) { WmsEntity.STARTBILLINGDATE = sqlRead.GetDateTime(28); } //
|
|
|
if (!sqlRead.IsDBNull(29)) { WmsEntity.CUSTOMNO = sqlRead.GetString(29); }//
|
|
|
if (!sqlRead.IsDBNull(30)) { WmsEntity.CUSTNO = sqlRead.GetString(30); }
|
|
|
if (!sqlRead.IsDBNull(31)) { WmsEntity.GOODSSTANDARD = sqlRead.GetString(31); }
|
|
|
if (!sqlRead.IsDBNull(32)) { WmsEntity.ARCLIENT = sqlRead.GetString(32); }
|
|
|
if (!sqlRead.IsDBNull(33)) { WmsEntity.FREESTORAGEPERIODAP = sqlRead.GetInt32(33); } //
|
|
|
if (!sqlRead.IsDBNull(34)) { WmsEntity.STARTBILLINGDATEAP = sqlRead.GetDateTime(34); } //
|
|
|
if (!sqlRead.IsDBNull(35)) { WmsEntity.CORPID = sqlRead.GetString(35); } //
|
|
|
if (!sqlRead.IsDBNull(36)) { WmsEntity.BZTCHNO = sqlRead.GetString(36); }
|
|
|
if (!sqlRead.IsDBNull(37)) { WmsEntity.CREATEUSER = sqlRead.GetString(37); }
|
|
|
if (!sqlRead.IsDBNull(38)) { WmsEntity.CREATETIME = sqlRead.GetDateTime(38); }
|
|
|
}
|
|
|
sqlRead.Close();
|
|
|
sqlRead.Dispose();
|
|
|
#endregion
|
|
|
//
|
|
|
//WmsEntity.GID = strINGIDNEW;
|
|
|
//WmsEntity.WMSNO = tbWMSNO;//调用编码规则
|
|
|
//
|
|
|
WmsEntity.CUSTOMERNAME = this.h_outcustomer.Value.ToString().Trim();
|
|
|
WmsEntity.WMSOP = strShowName.Trim();
|
|
|
WmsEntity.STOREMAN = strShowName.Trim();
|
|
|
WmsEntity.MODIFIEDUSER = strUserID;
|
|
|
//
|
|
|
WmsEntity.WMSDATE = model.DODATE;
|
|
|
WmsEntity.STARTBILLINGDATE = DateTime.Parse(this.txt_oldcustFeeDate.Value.Trim()).AddDays(1);
|
|
|
int iFeeDay = WmsOutDetailDA.GetDaysCount("day", model.DODATE.ToString(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim());//WmsOutEntity.DODATE.ToString());
|
|
|
WmsEntity.FREESTORAGEPERIOD = 0;
|
|
|
if (iFeeDay > 0)
|
|
|
{
|
|
|
WmsEntity.FREESTORAGEPERIOD = iFeeDay;
|
|
|
}
|
|
|
//
|
|
|
WmsEntity.GOODSPACK = model.GOODSPACKPFSL;
|
|
|
WmsEntity.GOODSPACKSTOCK = model.GOODSPACKPFSL;
|
|
|
WmsEntity.GOODSRKSL = model.GOODSPFSL;
|
|
|
WmsEntity.GOODSSTOCK = model.GOODSPFSL;
|
|
|
WmsEntity.ARFEE = 0;
|
|
|
WmsEntity.APFEE = 0;
|
|
|
WmsEntity.CLIENTNAMEOLD = model.CUSTOMERNAME;// 原客户名称
|
|
|
WmsEntity.ISLOCK = false;// true;
|
|
|
WmsEntity.LOCKUSER = strUserID;
|
|
|
WmsEntity.CORPID = strCompanyID;
|
|
|
|
|
|
SqlParameter[] parameters = {
|
|
|
new SqlParameter("@GID", SqlDbType.VarChar,36) ,
|
|
|
new SqlParameter("@WMSNO", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@WMSDATE", SqlDbType.DateTime) ,
|
|
|
new SqlParameter("@CUSTOMERNAME", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@WMSOP", SqlDbType.VarChar,10) ,
|
|
|
new SqlParameter("@STOREMAN", SqlDbType.VarChar,10) ,
|
|
|
new SqlParameter("@MODIFIEDUSER", SqlDbType.VarChar,36) ,
|
|
|
//new SqlParameter("@TRUCKNAME", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@GOODSPACK", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSPACKSTOCK", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSRKSL", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSSTOCK", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@ARFEE", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@APFEE", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@ASSOCIATEDNO", SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@BLNO", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@FREESTORAGEPERIOD", SqlDbType.Int,4) ,
|
|
|
new SqlParameter("@CONTRACTNO", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@GOODSNAME", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@GOODSMODEL", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@CLIENTCODEOLD", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@CLIENTNAMEOLD", SqlDbType.VarChar,20) ,
|
|
|
new SqlParameter("@STORAGENAME", SqlDbType.VarChar,100) ,
|
|
|
new SqlParameter("@CHARGEUNIT", SqlDbType.VarChar,10) ,
|
|
|
new SqlParameter("@STARTBILLINGDATE", SqlDbType.DateTime),
|
|
|
new SqlParameter("@CUSTOMNO",SqlDbType.VarChar,20),
|
|
|
new SqlParameter("@CUSTNO",SqlDbType.VarChar,30),
|
|
|
new SqlParameter("@GOODSSTANDARD",SqlDbType.VarChar,100),
|
|
|
new SqlParameter("@CORPID",SqlDbType.VarChar,36),
|
|
|
new SqlParameter("@BZTCHNO",SqlDbType.VarChar,100)
|
|
|
//new SqlParameter("@FREESTORAGEPERIODAP", SqlDbType.Int,4) ,
|
|
|
//new SqlParameter("@STARTBILLINGDATEAP", SqlDbType.DateTime)
|
|
|
};
|
|
|
|
|
|
parameters[0].Value = WmsEntity.GID;
|
|
|
parameters[1].Value = WmsEntity.WMSNO;
|
|
|
parameters[2].Value = WmsEntity.WMSDATE;
|
|
|
parameters[3].Value = WmsEntity.CUSTOMERNAME;
|
|
|
parameters[4].Value = WmsEntity.WMSOP;
|
|
|
parameters[5].Value = WmsEntity.STOREMAN;
|
|
|
parameters[6].Value = WmsEntity.MODIFIEDUSER;
|
|
|
parameters[7].Value = WmsEntity.GOODSPACK;
|
|
|
parameters[8].Value = WmsEntity.GOODSPACKSTOCK;
|
|
|
parameters[9].Value = WmsEntity.GOODSRKSL;
|
|
|
parameters[10].Value = WmsEntity.GOODSSTOCK;
|
|
|
parameters[11].Value = WmsEntity.ARFEE;
|
|
|
parameters[12].Value = WmsEntity.APFEE;
|
|
|
parameters[13].Value = WmsEntity.ASSOCIATEDNO;
|
|
|
parameters[14].Value = WmsEntity.BLNO;
|
|
|
parameters[15].Value = WmsEntity.FREESTORAGEPERIOD;
|
|
|
parameters[16].Value = WmsEntity.CONTRACTNO;
|
|
|
parameters[17].Value = WmsEntity.GOODSNAME;
|
|
|
parameters[18].Value = WmsEntity.GOODSMODEL;
|
|
|
parameters[19].Value = WmsEntity.CLIENTCODEOLD;
|
|
|
parameters[20].Value = WmsEntity.CLIENTNAMEOLD;
|
|
|
parameters[21].Value = WmsEntity.STORAGENAME;
|
|
|
parameters[22].Value = WmsEntity.CHARGEUNIT;
|
|
|
parameters[23].Value = WmsEntity.STARTBILLINGDATE;
|
|
|
parameters[24].Value = WmsEntity.CUSTOMNO;
|
|
|
parameters[25].Value = WmsEntity.CUSTNO;
|
|
|
parameters[26].Value = WmsEntity.GOODSSTANDARD;
|
|
|
parameters[27].Value = WmsEntity.CORPID;
|
|
|
parameters[28].Value = WmsEntity.BZTCHNO;
|
|
|
//parameters[27].Value = WmsEntity.FREESTORAGEPERIODAP;
|
|
|
//parameters[28].Value = WmsEntity.STARTBILLINGDATEAP;
|
|
|
|
|
|
string lsSql = "update wms set WMSNO = @WMSNO,WMSDATE = @WMSDATE,CUSTOMERNAME = @CUSTOMERNAME,WMSOP = @WMSOP,STOREMAN = @STOREMAN,MODIFIEDUSER = @MODIFIEDUSER,MODIFIEDTIME = getdate(),GOODSPACK = @GOODSPACK,GOODSPACKSTOCK = @GOODSPACKSTOCK,GOODSRKSL = @GOODSRKSL,GOODSSTOCK = @GOODSSTOCK,ARFEE = @ARFEE,APFEE = @APFEE,ASSOCIATEDNO = @ASSOCIATEDNO,BLNO = @BLNO,FREESTORAGEPERIOD = @FREESTORAGEPERIOD,CONTRACTNO = @CONTRACTNO,GOODSNAME = @GOODSNAME,GOODSMODEL = @GOODSMODEL,CLIENTCODEOLD = @CLIENTCODEOLD,CLIENTNAMEOLD = @CLIENTNAMEOLD,STORAGENAME = @STORAGENAME,CHARGEUNIT = @CHARGEUNIT ,STARTBILLINGDATE = @STARTBILLINGDATE,CUSTOMNO=@CUSTOMNO,CUSTNO=@CUSTNO,GOODSSTANDARD=@GOODSSTANDARD,CORPID=@CORPID,BZTCHNO=@BZTCHNO where GID=@GID ";//,FREESTORAGEPERIODAP=@FREESTORAGEPERIODAP,STARTBILLINGDATEAP=@STARTBILLINGDATEAP
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSql, parameters);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -9;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
#endregion
|
|
|
//
|
|
|
#region 插入入库明细表
|
|
|
//删除wms_in当前的数据
|
|
|
lsSql = "delete from wms_in where ASSOCIATEDNO = '" + WmsEntity.GID.ToString().Trim() + "' ";
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSql, null);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -9;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
//保存出库单明细wms_out_detail
|
|
|
int n = 0;
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
{
|
|
|
n = n + 1;
|
|
|
#region 提取出库相对应的原入库wms_in数据
|
|
|
string SQL_SELECT_WMS_IN_GID = "select top 1 GID,ASSOCIATEDNO,BLNO,CONTRACTNO,CNTRNO,SEALNO,BSNO,CLIENTCODE,CLIENTNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSRKSL,GOODSSTOCK,ISLOCK,LOCKTIME,LOCKUSER,ISDELETE,DELETETIME,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,REMARK,FREESTORAGEPERIOD,GOODSPACKSTOCK,GOODSKGS,CLIENTCODEOLD,CLIENTNAMEOLD,KINDPKGS,ARFEE,APFEE,CTNALL,GOODSTHICKNESS,GOODSWIDTH,GOODSLENGTH,GOODSSLICE,GOODSGRADE,STACKLOCATION,CORPID,LINENUM from wms_in where gid='" + WmsOutDetailEntity.INBSNO.ToString().Trim() + "' and ISDELETE=0";
|
|
|
sqlRead = SqlHelper.ExecuteQueryReader(sqlTran, CommandType.Text, SQL_SELECT_WMS_IN_GID, null);
|
|
|
while (sqlRead.Read())
|
|
|
{
|
|
|
if (!sqlRead.IsDBNull(0)) { WmsInEntity.GID = sqlRead.GetString(0); }// 惟一编号
|
|
|
if (!sqlRead.IsDBNull(1)) { WmsInEntity.ASSOCIATEDNO = sqlRead.GetString(1); }// 关联号
|
|
|
if (!sqlRead.IsDBNull(2)) { WmsInEntity.BLNO = sqlRead.GetString(2); }// 提单号
|
|
|
if (!sqlRead.IsDBNull(3)) { WmsInEntity.CONTRACTNO = sqlRead.GetString(3); }// 合同号
|
|
|
if (!sqlRead.IsDBNull(4)) { WmsInEntity.CNTRNO = sqlRead.GetString(4); }// 箱号
|
|
|
if (!sqlRead.IsDBNull(5)) { WmsInEntity.SEALNO = sqlRead.GetString(5); }// 封号
|
|
|
if (!sqlRead.IsDBNull(6)) { WmsInEntity.BSNO = sqlRead.GetString(6); }// 仓单明细号
|
|
|
if (!sqlRead.IsDBNull(7)) { WmsInEntity.CLIENTCODE = sqlRead.GetString(7); }// 客户编码
|
|
|
if (!sqlRead.IsDBNull(8)) { WmsInEntity.CLIENTNAME = sqlRead.GetString(8); }// 客户名称
|
|
|
if (!sqlRead.IsDBNull(9)) { WmsInEntity.DODATE = sqlRead.GetDateTime(9); }// 操作时间
|
|
|
if (!sqlRead.IsDBNull(10)) { WmsInEntity.STORAGECODE = sqlRead.GetString(10); }// 仓库编码
|
|
|
if (!sqlRead.IsDBNull(11)) { WmsInEntity.STORAGENAME = sqlRead.GetString(11); }// 仓库名称
|
|
|
if (!sqlRead.IsDBNull(12)) { WmsInEntity.AREACODE = sqlRead.GetString(12); }// 库位编码
|
|
|
if (!sqlRead.IsDBNull(13)) { WmsInEntity.AREANAME = sqlRead.GetString(13); }// 库位名称
|
|
|
if (!sqlRead.IsDBNull(14)) { WmsInEntity.GOODSCODE = sqlRead.GetString(14); }// 货物编号
|
|
|
if (!sqlRead.IsDBNull(15)) { WmsInEntity.GOODSNAME = sqlRead.GetString(15); }// 货物名称
|
|
|
if (!sqlRead.IsDBNull(16)) { WmsInEntity.GOODSTYPE = sqlRead.GetString(16); }// 货物类型
|
|
|
if (!sqlRead.IsDBNull(17)) { WmsInEntity.GOODSMODEL = sqlRead.GetString(17); }// 型号
|
|
|
if (!sqlRead.IsDBNull(18)) { WmsInEntity.GOODSSTANDARD = sqlRead.GetString(18); }// 规格
|
|
|
if (!sqlRead.IsDBNull(19)) { WmsInEntity.GOODSPACK = sqlRead.GetDecimal(19); }// 件数
|
|
|
if (!sqlRead.IsDBNull(20)) { WmsInEntity.CHARGEUNIT = sqlRead.GetString(20); }// 计费单位
|
|
|
//if (!sqlRead.IsDBNull(21)) { WmsInEntity.CHARGEPRICE = sqlRead.GetDecimal(21); }// 计费单价
|
|
|
if (!sqlRead.IsDBNull(21)) { WmsInEntity.GOODSRKSL = sqlRead.GetDecimal(21); }// 入库量
|
|
|
if (!sqlRead.IsDBNull(22)) { WmsInEntity.GOODSSTOCK = sqlRead.GetDecimal(22); }// 库存量
|
|
|
if (!sqlRead.IsDBNull(23)) { WmsInEntity.ISLOCK = sqlRead.GetBoolean(23); }// 是否锁定
|
|
|
if (!sqlRead.IsDBNull(24)) { WmsInEntity.LOCKTIME = sqlRead.GetDateTime(24); }// 锁定时间
|
|
|
if (!sqlRead.IsDBNull(25)) { WmsInEntity.LOCKUSER = sqlRead.GetString(25); }// 锁定操作人
|
|
|
if (!sqlRead.IsDBNull(26)) { WmsInEntity.ISDELETE = sqlRead.GetBoolean(26); }// 是否废除
|
|
|
if (!sqlRead.IsDBNull(27)) { WmsInEntity.DELETETIME = sqlRead.GetDateTime(27); }// 废除时间
|
|
|
if (!sqlRead.IsDBNull(28)) { WmsInEntity.DELETEUSER = sqlRead.GetString(28); }// 废除操作人
|
|
|
if (!sqlRead.IsDBNull(29)) { WmsInEntity.CREATEUSER = sqlRead.GetString(29); }// 创建人
|
|
|
if (!sqlRead.IsDBNull(30)) { WmsInEntity.CREATETIME = sqlRead.GetDateTime(30); }// 创建时间
|
|
|
if (!sqlRead.IsDBNull(31)) { WmsInEntity.MODIFIEDUSER = sqlRead.GetString(31); }// 最后一次更新操作人
|
|
|
if (!sqlRead.IsDBNull(32)) { WmsInEntity.MODIFIEDTIME = sqlRead.GetDateTime(32); }// 最后一次更新操作时间
|
|
|
if (!sqlRead.IsDBNull(33)) { WmsInEntity.REMARK = sqlRead.GetString(33); }// 备注
|
|
|
if (!sqlRead.IsDBNull(34)) { WmsInEntity.FREESTORAGEPERIOD = sqlRead.GetInt32(34); }// 免仓储期
|
|
|
if (!sqlRead.IsDBNull(35)) { WmsInEntity.GOODSPACKSTOCK = sqlRead.GetDecimal(35); }// 剩余件数
|
|
|
if (!sqlRead.IsDBNull(36)) { WmsInEntity.GOODSKGS = sqlRead.GetDecimal(36); }// 重量
|
|
|
if (!sqlRead.IsDBNull(37)) { WmsInEntity.CLIENTCODEOLD = sqlRead.GetString(37); }// 原客户编码
|
|
|
if (!sqlRead.IsDBNull(38)) { WmsInEntity.CLIENTNAMEOLD = sqlRead.GetString(38); }// 原客户名称
|
|
|
if (!sqlRead.IsDBNull(39)) { WmsInEntity.KINDPKGS = sqlRead.GetString(39); }//
|
|
|
if (!sqlRead.IsDBNull(40)) { WmsInEntity.ARFEE = sqlRead.GetDecimal(40); }//
|
|
|
if (!sqlRead.IsDBNull(41)) { WmsInEntity.APFEE = sqlRead.GetDecimal(41); }//
|
|
|
if (!sqlRead.IsDBNull(42)) { WmsInEntity.CTNALL = sqlRead.GetString(42); }//
|
|
|
if (!sqlRead.IsDBNull(43)) { WmsInEntity.GOODSTHICKNESS = sqlRead.GetDecimal(43); }//
|
|
|
if (!sqlRead.IsDBNull(44)) { WmsInEntity.GOODSWIDTH = sqlRead.GetDecimal(44); }//
|
|
|
if (!sqlRead.IsDBNull(45)) { WmsInEntity.GOODSLENGTH = sqlRead.GetDecimal(45); }//
|
|
|
if (!sqlRead.IsDBNull(46)) { WmsInEntity.GOODSSLICE = sqlRead.GetDecimal(46); }//
|
|
|
if (!sqlRead.IsDBNull(47)) { WmsInEntity.GOODSGRADE = sqlRead.GetString(47); }//
|
|
|
if (!sqlRead.IsDBNull(48)) { WmsInEntity.STACKLOCATION = sqlRead.GetString(48); }//
|
|
|
if (!sqlRead.IsDBNull(49)) { WmsInEntity.CORPID = sqlRead.GetString(49); }//
|
|
|
if (!sqlRead.IsDBNull(50)) { WmsInEntity.LINENUM = sqlRead.GetInt32(50); }//
|
|
|
}
|
|
|
sqlRead.Close();
|
|
|
sqlRead.Dispose();
|
|
|
#endregion
|
|
|
WmsInEntity.GID = Guid.NewGuid().ToString();
|
|
|
WmsInEntity.ASSOCIATEDNO = WmsEntity.GID;
|
|
|
//
|
|
|
#region 提取规则编号 getCodeRule("入库明细单号", "BSNO", "wms_in")
|
|
|
string tbBSNO = "";
|
|
|
string strRULEYEAR1 = "";
|
|
|
string strRULECONTENT1 = "";
|
|
|
string strCODENAME1 = "";
|
|
|
string strDEPTNO1 = "";
|
|
|
string strRULENOLENGTH1 = "";
|
|
|
int iRULENOLENGTH1 = 0;
|
|
|
int inum1 = 0;
|
|
|
string strCONTENT1 = "";
|
|
|
DataSet ds2 = T_ALL_DA.GetAllSQL("select *,getdate() DODATE from code_rule where RULENAME='入库明细单号' and RULETYPE=3");
|
|
|
if (ds2 != null)
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
getCodeRuleEnabled("入库明细单号", "BSNO");
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
//return "";
|
|
|
tbBSNO = "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds2.Tables[0].Rows[0]["DODATE"].ToString().Trim());
|
|
|
if (ds2.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yyyy") + dETD.ToString("MM");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yy") + dETD.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = dETD.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
|
|
|
{
|
|
|
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
|
|
|
if (ds2.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yy") + fwqdate.ToString("MM");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yyyy");
|
|
|
}
|
|
|
else if (ds2.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
{
|
|
|
strRULEYEAR1 = fwqdate.ToString("yy");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strCODENAME1 = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
}
|
|
|
if (ds2.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
strDEPTNO1 = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
}
|
|
|
strRULECONTENT1 = ds2.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
|
|
|
strRULECONTENT1 = strRULECONTENT1.Replace("《COMPANY》", strCODENAME1);
|
|
|
strRULECONTENT1 = strRULECONTENT1.Replace("《DEPT》", strDEPTNO1);
|
|
|
//
|
|
|
if (ds2.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
|
|
|
{
|
|
|
iRULENOLENGTH1 = 0;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
iRULENOLENGTH1 = int.Parse(ds2.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
|
|
|
}
|
|
|
strCONTENT1 = strRULECONTENT1 + strRULEYEAR1;
|
|
|
//
|
|
|
//获取分公司的票号头字符
|
|
|
string tempBANKSHEAD = "";
|
|
|
string strSQL = "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'";
|
|
|
DataSet ds21 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds21 != null)
|
|
|
{
|
|
|
if (ds21.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
tempBANKSHEAD = ds21.Tables[0].Rows[0]["BANKSHEAD"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
strCONTENT1 = tempBANKSHEAD + strCONTENT1;
|
|
|
//
|
|
|
strSQL = "select top 1 BSNO from [wms_in] where BSNO like '" + strCONTENT1.Trim() + "%' order by BSNO DESC";
|
|
|
ds21 = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, strSQL, null);
|
|
|
if (ds21 != null)
|
|
|
{
|
|
|
if (ds21.Tables[0].Rows.Count > 0)
|
|
|
{
|
|
|
strRULENOLENGTH1 = ds21.Tables[0].Rows[0]["BSNO"].ToString().Trim();
|
|
|
}
|
|
|
}
|
|
|
if (strRULENOLENGTH1 == "")
|
|
|
{
|
|
|
strRULENOLENGTH1 = "1";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strRULENOLENGTH1 = strRULENOLENGTH1.Replace(strCONTENT1.Trim(), "");
|
|
|
inum1 = int.Parse(strRULENOLENGTH1.Trim());
|
|
|
inum1 = inum1 + 1;
|
|
|
strRULENOLENGTH1 = inum1.ToString();
|
|
|
}
|
|
|
int j = iRULENOLENGTH1 - strRULENOLENGTH1.Length;
|
|
|
for (int i = 1; i <= j; i++)
|
|
|
{
|
|
|
strRULENOLENGTH1 = "0" + strRULENOLENGTH1;
|
|
|
}
|
|
|
//
|
|
|
strCONTENT1 = strCONTENT1 + strRULENOLENGTH1;
|
|
|
tbBSNO = strCONTENT1;
|
|
|
//return strCONTENT1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
// return "";
|
|
|
//}
|
|
|
#endregion
|
|
|
WmsInEntity.BSNO = tbBSNO;//调用编码规则
|
|
|
//
|
|
|
WmsInEntity.DODATE = model.DODATE;
|
|
|
WmsInEntity.CLIENTNAME = this.h_outcustomer.Value.ToString().Trim();
|
|
|
WmsInEntity.GOODSRKSL = WmsOutDetailEntity.GOODSPFSL;//入库数量
|
|
|
WmsInEntity.GOODSSTOCK = WmsOutDetailEntity.GOODSPFSL;//入库数量
|
|
|
WmsInEntity.GOODSPACK = WmsOutDetailEntity.GOODSPACKPFSL;//件数
|
|
|
WmsInEntity.GOODSPACKSTOCK = WmsOutDetailEntity.GOODSPACKPFSL;//件数
|
|
|
WmsInEntity.REMARK = "货权转移";
|
|
|
WmsInEntity.CREATEUSER = strUserID;// 创建人
|
|
|
WmsInEntity.MODIFIEDUSER = strUserID;// 最后一次更新操作人
|
|
|
WmsInEntity.CLIENTNAMEOLD = WmsOutDetailEntity.CUSTOMERNAME;//货权转移前货主
|
|
|
WmsInEntity.ARFEE = 0;
|
|
|
WmsInEntity.APFEE = 0;
|
|
|
WmsInEntity.ISLOCK = false;// true;
|
|
|
WmsInEntity.LOCKUSER = strUserID;
|
|
|
WmsInEntity.CORPID = strCompanyID;
|
|
|
|
|
|
SqlParameter[] parms = new SqlParameter[]{
|
|
|
new SqlParameter("@GID",SqlDbType.VarChar,100),//惟一编号
|
|
|
new SqlParameter("@ASSOCIATEDNO",SqlDbType.VarChar,100),//关联号
|
|
|
new SqlParameter("@BLNO",SqlDbType.VarChar,30),//提单号
|
|
|
new SqlParameter("@CONTRACTNO",SqlDbType.VarChar,100),//合同号
|
|
|
new SqlParameter("@CNTRNO",SqlDbType.VarChar,30),//箱号
|
|
|
new SqlParameter("@SEALNO",SqlDbType.VarChar,12),//封号
|
|
|
new SqlParameter("@BSNO",SqlDbType.VarChar,100),//仓单明细号
|
|
|
new SqlParameter("@CLIENTCODE",SqlDbType.VarChar,20),//客户编码
|
|
|
new SqlParameter("@CLIENTNAME",SqlDbType.VarChar,20),//客户名称
|
|
|
new SqlParameter("@STORAGECODE",SqlDbType.VarChar,50),//仓库编码
|
|
|
new SqlParameter("@STORAGENAME",SqlDbType.VarChar,100),//仓库名称
|
|
|
new SqlParameter("@AREACODE",SqlDbType.VarChar,50),//库位编码
|
|
|
new SqlParameter("@AREANAME",SqlDbType.VarChar,100),//库位名称
|
|
|
new SqlParameter("@GOODSCODE",SqlDbType.VarChar,50),//货物编号
|
|
|
new SqlParameter("@GOODSNAME",SqlDbType.VarChar,100),//货物名称/品名
|
|
|
new SqlParameter("@GOODSTYPE",SqlDbType.VarChar,50),//货物类型
|
|
|
new SqlParameter("@GOODSMODEL",SqlDbType.VarChar,100),//型号
|
|
|
new SqlParameter("@GOODSSTANDARD",SqlDbType.VarChar,100),//规格
|
|
|
new SqlParameter("@GOODSPACK",SqlDbType.Decimal),//件数
|
|
|
new SqlParameter("@CHARGEUNIT",SqlDbType.VarChar,10),//计费单位
|
|
|
//new SqlParameter("@CHARGEPRICE",SqlDbType.Decimal),//计费单价
|
|
|
new SqlParameter("@GOODSRKSL",SqlDbType.Decimal),//入库量
|
|
|
new SqlParameter("@GOODSSTOCK",SqlDbType.Decimal) ,//库存量
|
|
|
new SqlParameter("@ISLOCK",SqlDbType.Bit),//是否锁定
|
|
|
new SqlParameter("@LOCKUSER",SqlDbType.VarChar,36),//锁定操作人
|
|
|
new SqlParameter("@ISDELETE",SqlDbType.Bit),//是否废除
|
|
|
new SqlParameter("@DELETEUSER",SqlDbType.VarChar,36),//废除操作人
|
|
|
new SqlParameter("@CREATEUSER",SqlDbType.VarChar,36),//创建人
|
|
|
new SqlParameter("@MODIFIEDUSER",SqlDbType.VarChar,36),//最后一次更新操作人
|
|
|
new SqlParameter("@REMARK",SqlDbType.VarChar,1024),//备注
|
|
|
new SqlParameter("@FREESTORAGEPERIOD",SqlDbType.Int),//
|
|
|
new SqlParameter("@GOODSPACKSTOCK",SqlDbType.Decimal),//
|
|
|
new SqlParameter("@GOODSKGS",SqlDbType.Decimal),//重量
|
|
|
new SqlParameter("@CLIENTCODEOLD",SqlDbType.VarChar,20),//原客户编码
|
|
|
new SqlParameter("@CLIENTNAMEOLD",SqlDbType.VarChar,20),//原客户名称
|
|
|
new SqlParameter("@KINDPKGS",SqlDbType.VarChar,20),//
|
|
|
new SqlParameter("@ARFEE",SqlDbType.Decimal),//
|
|
|
new SqlParameter("@APFEE",SqlDbType.Decimal),//
|
|
|
new SqlParameter("@CTNALL",SqlDbType.VarChar,10),
|
|
|
new SqlParameter("@GOODSTHICKNESS", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSWIDTH", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSLENGTH", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSSLICE", SqlDbType.Decimal,9) ,
|
|
|
new SqlParameter("@GOODSGRADE", SqlDbType.VarChar,50) ,
|
|
|
new SqlParameter("@STACKLOCATION", SqlDbType.VarChar,50) ,
|
|
|
new SqlParameter("@CORPID", SqlDbType.VarChar,36)
|
|
|
};
|
|
|
|
|
|
parms[0].Value = WmsInEntity.GID;// 惟一编号
|
|
|
parms[1].Value = WmsInEntity.ASSOCIATEDNO;// 关联号
|
|
|
parms[2].Value = WmsInEntity.BLNO;// 提单号
|
|
|
parms[3].Value = WmsInEntity.CONTRACTNO;// 合同号
|
|
|
parms[4].Value = WmsInEntity.CNTRNO;// 箱号
|
|
|
parms[5].Value = WmsInEntity.SEALNO;// 封号
|
|
|
parms[6].Value = WmsInEntity.BSNO;// 仓单明细号
|
|
|
parms[7].Value = WmsInEntity.CLIENTCODE;// 客户编码
|
|
|
parms[8].Value = WmsInEntity.CLIENTNAME;// 客户名称
|
|
|
parms[9].Value = WmsInEntity.STORAGECODE;// 仓库编码
|
|
|
parms[10].Value = WmsInEntity.STORAGENAME;// 仓库名称
|
|
|
parms[11].Value = WmsInEntity.AREACODE;// 库位编码
|
|
|
parms[12].Value = WmsInEntity.AREANAME;// 库位名称
|
|
|
parms[13].Value = WmsInEntity.GOODSCODE;// 货物编号
|
|
|
parms[14].Value = WmsInEntity.GOODSNAME;// 货物名称
|
|
|
parms[15].Value = WmsInEntity.GOODSTYPE;// 货物类型
|
|
|
parms[16].Value = WmsInEntity.GOODSMODEL;// 型号
|
|
|
parms[17].Value = WmsInEntity.GOODSSTANDARD;// 规格
|
|
|
parms[18].Value = WmsInEntity.GOODSPACK;// 件数
|
|
|
parms[19].Value = WmsInEntity.CHARGEUNIT;// 计费单位
|
|
|
//parms[20].Value = WmsInEntity.CHARGEPRICE;// 计费单价
|
|
|
parms[20].Value = WmsInEntity.GOODSRKSL;// 入库量
|
|
|
parms[21].Value = WmsInEntity.GOODSSTOCK;// 库存量
|
|
|
parms[22].Value = WmsInEntity.ISLOCK;// 是否锁定
|
|
|
parms[23].Value = WmsInEntity.LOCKUSER;// 锁定操作人
|
|
|
parms[24].Value = WmsInEntity.ISDELETE;// 是否废除
|
|
|
parms[25].Value = WmsInEntity.DELETEUSER;// 废除操作人
|
|
|
parms[26].Value = WmsInEntity.CREATEUSER;// 创建人
|
|
|
parms[27].Value = WmsInEntity.MODIFIEDUSER;// 最后一次更新操作人
|
|
|
parms[28].Value = WmsInEntity.REMARK;// 备注
|
|
|
parms[29].Value = WmsInEntity.FREESTORAGEPERIOD;//
|
|
|
parms[30].Value = WmsInEntity.GOODSPACKSTOCK;//
|
|
|
parms[31].Value = WmsInEntity.GOODSKGS;// 重量
|
|
|
parms[32].Value = WmsInEntity.CLIENTCODEOLD;// 客户编码
|
|
|
parms[33].Value = WmsInEntity.CLIENTNAMEOLD;// 客户名称
|
|
|
parms[34].Value = WmsInEntity.KINDPKGS;//
|
|
|
parms[35].Value = WmsInEntity.ARFEE;//
|
|
|
parms[36].Value = WmsInEntity.APFEE;//
|
|
|
parms[37].Value = WmsInEntity.CTNALL;//
|
|
|
parms[38].Value = WmsInEntity.GOODSTHICKNESS;
|
|
|
parms[39].Value = WmsInEntity.GOODSWIDTH;
|
|
|
parms[40].Value = WmsInEntity.GOODSLENGTH;
|
|
|
parms[41].Value = WmsInEntity.GOODSSLICE;
|
|
|
parms[42].Value = WmsInEntity.GOODSGRADE;
|
|
|
parms[43].Value = WmsInEntity.STACKLOCATION;
|
|
|
parms[44].Value = WmsInEntity.CORPID;
|
|
|
//
|
|
|
lsSql = "insert into wms_in(GID,ASSOCIATEDNO,BLNO,CONTRACTNO,CNTRNO,SEALNO,BSNO,CLIENTCODE,CLIENTNAME,{0}STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,CHARGEUNIT,GOODSRKSL,GOODSSTOCK,ISLOCK,LOCKUSER,ISDELETE,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,REMARK,FREESTORAGEPERIOD,GOODSPACKSTOCK,GOODSKGS,CLIENTCODEOLD,CLIENTNAMEOLD,KINDPKGS,ARFEE,APFEE,CTNALL,GOODSTHICKNESS,GOODSWIDTH,GOODSLENGTH,GOODSSLICE,GOODSGRADE,STACKLOCATION,CORPID,LINENUM) "
|
|
|
+ " values(@GID,@ASSOCIATEDNO,@BLNO,@CONTRACTNO,@CNTRNO,@SEALNO,@BSNO,@CLIENTCODE,@CLIENTNAME,{1}@STORAGECODE,@STORAGENAME,@AREACODE,@AREANAME,@GOODSCODE,@GOODSNAME,@GOODSTYPE,@GOODSMODEL,@GOODSSTANDARD,@GOODSPACK,@CHARGEUNIT,@GOODSRKSL,@GOODSSTOCK,@ISLOCK,@LOCKUSER,@ISDELETE,@DELETEUSER,@CREATEUSER,getdate(),@MODIFIEDUSER,getdate(),@REMARK,@FREESTORAGEPERIOD,@GOODSPACKSTOCK,@GOODSKGS,@CLIENTCODEOLD,@CLIENTNAMEOLD,@KINDPKGS,@ARFEE,@APFEE,@CTNALL,@GOODSTHICKNESS,@GOODSWIDTH,@GOODSLENGTH,@GOODSSLICE,@GOODSGRADE,@STACKLOCATION,@CORPID," + n + ")";
|
|
|
//
|
|
|
string strDODATE = model.DODATE.ToString().IndexOf("0001") > -1 ? "" : "'" + model.DODATE.ToString() + "',";
|
|
|
string strDODATE_name = strDODATE.Equals("") ? "" : "DODATE,";
|
|
|
lsSql = String.Format(lsSql, strDODATE_name, strDODATE);
|
|
|
//
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSql, parms);
|
|
|
if (iState != 1)
|
|
|
{
|
|
|
sqlTran.Rollback();
|
|
|
result = -9;
|
|
|
Clearh();
|
|
|
return result;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
//
|
|
|
#endregion
|
|
|
//
|
|
|
this.h_newcust.Value = WmsInEntity.CLIENTNAME;
|
|
|
this.h_IsSetRate.Value = "1"; //货权转移,可以设置费率
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
sqlTran.Commit();
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>reloadParent('" + WmsOutEntity.GID.ToString().Trim() + "','edit','" + WmsEntity.GID.ToString().Trim() + "','" + WmsEntity.ASSOCIATEDNO.ToString().Trim() + "');</script>");
|
|
|
}
|
|
|
catch (Exception execError)
|
|
|
{
|
|
|
result = -1;//有异常,插入失败
|
|
|
sqlTran.Rollback();
|
|
|
result = -2;//插入异常,事务已回滚成功
|
|
|
Clearh();
|
|
|
throw execError;
|
|
|
}
|
|
|
finally
|
|
|
{
|
|
|
SqlHelper.CloseConnection();
|
|
|
}
|
|
|
}
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 生成插入语句参数
|
|
|
/// <summary>
|
|
|
/// 生成插入语句参数
|
|
|
/// </summary>
|
|
|
/// <returns>返回SqlParameter数组</returns>
|
|
|
private SqlParameter[] GetInsertParms()
|
|
|
{
|
|
|
SqlParameter[] parms = new SqlParameter[]{
|
|
|
new SqlParameter("@GID",SqlDbType.VarChar,100),//惟一编号
|
|
|
new SqlParameter("@ASSOCIATEDNO",SqlDbType.VarChar,100),//关联号
|
|
|
new SqlParameter("@BLNO",SqlDbType.VarChar,30),//提单号
|
|
|
new SqlParameter("@CONTRACTNO",SqlDbType.VarChar,100),//合同号
|
|
|
new SqlParameter("@CNTRNO",SqlDbType.VarChar,30),//箱号
|
|
|
new SqlParameter("@SEALNO",SqlDbType.VarChar,12),//封号
|
|
|
new SqlParameter("@BSNO",SqlDbType.VarChar,100),//仓单明细号
|
|
|
new SqlParameter("@CLIENTCODE",SqlDbType.VarChar,20),//客户编码
|
|
|
new SqlParameter("@CLIENTNAME",SqlDbType.VarChar,20),//客户名称
|
|
|
new SqlParameter("@STORAGECODE",SqlDbType.VarChar,50),//仓库编码
|
|
|
new SqlParameter("@STORAGENAME",SqlDbType.VarChar,100),//仓库名称
|
|
|
new SqlParameter("@AREACODE",SqlDbType.VarChar,50),//库位编码
|
|
|
new SqlParameter("@AREANAME",SqlDbType.VarChar,100),//库位名称
|
|
|
new SqlParameter("@GOODSCODE",SqlDbType.VarChar,50),//货物编号
|
|
|
new SqlParameter("@GOODSNAME",SqlDbType.VarChar,100),//货物名称/品名
|
|
|
new SqlParameter("@GOODSTYPE",SqlDbType.VarChar,50),//货物类型
|
|
|
new SqlParameter("@GOODSMODEL",SqlDbType.VarChar,100),//牌号
|
|
|
new SqlParameter("@GOODSSTANDARD",SqlDbType.VarChar,100),//规格
|
|
|
new SqlParameter("@GOODSPACK",SqlDbType.Int),//件数
|
|
|
new SqlParameter("@CHARGEUNIT",SqlDbType.VarChar,10),//计费单位
|
|
|
//new SqlParameter("@CHARGEPRICE",SqlDbType.Decimal),//计费单价
|
|
|
new SqlParameter("@GOODSRKSL",SqlDbType.Decimal),//入库量
|
|
|
new SqlParameter("@GOODSSTOCK",SqlDbType.Decimal) ,//库存量
|
|
|
new SqlParameter("@ISLOCK",SqlDbType.Bit),//是否锁定
|
|
|
new SqlParameter("@LOCKUSER",SqlDbType.VarChar,36),//锁定操作人
|
|
|
new SqlParameter("@ISDELETE",SqlDbType.Bit),//是否废除
|
|
|
new SqlParameter("@DELETEUSER",SqlDbType.VarChar,36),//废除操作人
|
|
|
new SqlParameter("@CREATEUSER",SqlDbType.VarChar,36),//创建人
|
|
|
new SqlParameter("@MODIFIEDUSER",SqlDbType.VarChar,36),//最后一次更新操作人
|
|
|
new SqlParameter("@REMARK",SqlDbType.VarChar,1024),//备注
|
|
|
new SqlParameter("@FREESTORAGEPERIOD",SqlDbType.Int),//件数
|
|
|
new SqlParameter("@CLIENTNAMEOLD",SqlDbType.VarChar,20),//备注
|
|
|
//new SqlParameter("@GOODSKGS",SqlDbType.Decimal)//重量
|
|
|
//new SqlParameter("@DODATE",SqlDbType.Datetime),//操作时间
|
|
|
//new SqlParameter("@LOCKTIME",SqlDbType.Datetime),//锁定时间
|
|
|
//new SqlParameter("@DELETETIME",SqlDbType.Datetime),//废除时间
|
|
|
//new SqlParameter("@CREATETIME",SqlDbType.Datetime),//创建时间
|
|
|
//new SqlParameter("@MODIFIEDTIME",SqlDbType.Datetime),//最后一次更新操作时间
|
|
|
};
|
|
|
return parms;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的出库保存或更新“出库信息表和出库明细表”wms_out,wms_out_detail,并返回操作结果
|
|
|
/// </summary>
|
|
|
private void SaveWoAction()
|
|
|
{
|
|
|
WmsOutEntity WmsOutEntity = new WmsOutEntity();
|
|
|
//IList<WmsOutDetailEntity> WmsOutDetailEntitys = new List<WmsOutDetailEntity>();
|
|
|
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutEntity = ResolveWoJSON(WoJSON.Trim(), WmsOutEntity);
|
|
|
WoContainer.Value = "";
|
|
|
}
|
|
|
|
|
|
WmsOutDA WmsOutDA = new WmsOutDA();
|
|
|
bool State = false;
|
|
|
if (WmsOutEntity != null)
|
|
|
{
|
|
|
State = WmsOutDA.Add(WmsOutEntity, "");
|
|
|
if (State)
|
|
|
{
|
|
|
this.h_wmsoutbsno.Value = WmsOutEntity.BSNO.ToString();
|
|
|
this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL.ToString();
|
|
|
this.h_goodspfsl.Value = WmsOutEntity.GOODSPFSL.ToString();
|
|
|
this.h_totalno.Value = WmsOutEntity.TOTALNO.ToString();
|
|
|
this.h_remark.Value = WmsOutEntity.REMARK.ToString();
|
|
|
SaveWoDetailAction(WmsOutEntity);//保存出库明细
|
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('信息保存成功');window.parent.opener.location.href=window.parent.opener.location.href;</script>");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('信息保存失败');</script>");
|
|
|
}
|
|
|
}
|
|
|
h_post.Value = "";//请求状态清空
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
/// </summary>
|
|
|
/// <param name="tempJSON"></param>
|
|
|
/// <param name="tempFeeEntities"></param>
|
|
|
/// <returns>将页面post获取的费用信息读入到费用实体类ch_fee中</returns>
|
|
|
private WmsOutEntity ResolveWoJSON(string tempJSON, WmsOutEntity tempWoEntity)
|
|
|
{
|
|
|
string OutGid = "";
|
|
|
string OutBsno = "";
|
|
|
DateTime OutDate = new DateTime();
|
|
|
string strFilter = "";
|
|
|
WmsOutEntity WmsOutEntity = new WmsOutEntity();
|
|
|
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)
|
|
|
{
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
{
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
{
|
|
|
case "cust":
|
|
|
WmsOutEntity.CUSTOMERNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
h_customer.Value = WmsOutEntity.CUSTOMERNAME;
|
|
|
break;
|
|
|
case "outcus":
|
|
|
WmsOutEntity.CLIENTNAMEOLD = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
h_outcustomer.Value = WmsOutEntity.CLIENTNAMEOLD;
|
|
|
break;
|
|
|
//case "cusold":
|
|
|
// cusold = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
// break;
|
|
|
case "outdate":
|
|
|
WmsOutEntity.DODATE =DateTime.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
OutDate = WmsOutEntity.DODATE;
|
|
|
h_outdate.Value = WmsOutEntity.DODATE.ToString();
|
|
|
break;
|
|
|
case "goodsname":
|
|
|
WmsOutEntity.GOODSNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
h_goods.Value = WmsOutEntity.GOODSNAME;
|
|
|
break;
|
|
|
case "goodsmodel":
|
|
|
WmsOutEntity.GOODSMODEL = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL;
|
|
|
txt_goodsmodel.Value = h_goodsmodel.Value;
|
|
|
break;
|
|
|
case "outnum":
|
|
|
Decimal tmpoutnum = Decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
WmsOutEntity.GOODSPFSL =decimal.Parse( Round(tmpoutnum, 4).ToString());
|
|
|
this.h_goodspfsl.Value = WmsOutEntity.GOODSPFSL.ToString();
|
|
|
//this.txt_goodspfsl.Value = this.h_goodspfsl.Value;
|
|
|
break;
|
|
|
case "outpacknum":
|
|
|
decimal outpacknum= decimal.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
WmsOutEntity.GOODSPACKPFSL =Convert.ToInt16( Math.Round(outpacknum,0));
|
|
|
this.h_packnum.Value = WmsOutEntity.GOODSPACKPFSL.ToString();
|
|
|
//this.txt_packnum.Value = this.h_packnum.Value;
|
|
|
break;
|
|
|
case "totalno":
|
|
|
//WmsOutEntity.REMARK = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
WmsOutEntity.TOTALNO = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
|
|
|
this.h_totalno.Value = WmsOutEntity.TOTALNO.ToString().Trim();
|
|
|
this.txt_totalno.Value = WmsOutEntity.TOTALNO.ToString().Trim();
|
|
|
break;
|
|
|
case "remark":
|
|
|
//WmsOutEntity.REMARK = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
WmsOutEntity.REMARK = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
|
|
|
this.h_remark.Value = WmsOutEntity.REMARK.ToString().Trim();
|
|
|
this.txt_remark.Value = WmsOutEntity.REMARK.ToString().Trim();
|
|
|
break;
|
|
|
case "inspectionno":
|
|
|
WmsOutEntity.INSPECTIONNO = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
this.txt_inspectionno.Value = WmsOutEntity.INSPECTIONNO;
|
|
|
break;
|
|
|
case "customno":
|
|
|
WmsOutEntity.CUSTOMNO = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
this.txt_customno.Value = WmsOutEntity.CUSTOMNO;
|
|
|
break;
|
|
|
case "truckno":
|
|
|
//WmsOutEntity.TRUCKNO = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
WmsOutEntity.TRUCKNO = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
|
|
|
this.h_truckno.Value = WmsOutEntity.TRUCKNO.ToString().Trim();
|
|
|
break;
|
|
|
case "storage":
|
|
|
WmsOutEntity.STORAGENAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
this.h_storage.Value = WmsOutEntity.STORAGENAME;
|
|
|
break;
|
|
|
case "arclient"://应收
|
|
|
WmsOutEntity.ARCLIENT = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
hd_comboARCLIENT.Value = WmsOutEntity.ARCLIENT;
|
|
|
//if (hd_comboARCLIENT.Value.Trim() == "" && this.h_storage.Value.Trim() != "")
|
|
|
//{
|
|
|
// WmsOutEntity.ARCLIENT = this.h_storage.Value.Trim();
|
|
|
// hd_comboARCLIENT.Value = this.h_storage.Value.Trim();
|
|
|
//}
|
|
|
break;
|
|
|
case "truckname"://应付
|
|
|
WmsOutEntity.TRUCKNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
hd_comboTRUCKNAME.Value = WmsOutEntity.TRUCKNAME;
|
|
|
//if (hd_comboTRUCKNAME.Value.Trim() == "" && this.h_storage.Value.Trim() != "")
|
|
|
//{
|
|
|
// WmsOutEntity.TRUCKNAME = this.h_storage.Value.Trim();
|
|
|
// hd_comboTRUCKNAME.Value = this.h_storage.Value.Trim();
|
|
|
//}
|
|
|
break;
|
|
|
case "opseaibsno":
|
|
|
WmsOutEntity.ASSOCIATEDNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
this.h_opseaibsno.Value = WmsOutEntity.ASSOCIATEDNO;
|
|
|
this.h_bsno.Value = WmsOutEntity.ASSOCIATEDNO;
|
|
|
break;
|
|
|
case "isJsFee":
|
|
|
this.ck_jsfee.Checked = bool.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "oldcustfeedate":
|
|
|
this.txt_oldcustFeeDate.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
WmsOutEntity.OLDCUSTFEEDATE = this.txt_oldcustFeeDate.Value.Trim() == "0001-01-01 00:00:00" ? DateTime.Parse("") : DateTime.Parse(this.txt_oldcustFeeDate.Value.Trim());
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (this.h_storage.Value.Equals(null) || this.h_storage.Value.Trim().Equals(""))
|
|
|
{
|
|
|
WmsOutEntity.STORAGENAME = "";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WmsOutEntity.STORAGENAME = this.h_storage.Value.Trim();
|
|
|
}
|
|
|
WmsOutEntity.CREATEUSER = strShowName;
|
|
|
//if ((this.txt_outbsno.Value.Trim().Equals("") || this.txt_outbsno.Value.Equals(null)) || this.h_addmode.Value.Equals("1"))
|
|
|
if (this.h_Handle.Value.Trim().Equals("edit"))
|
|
|
{
|
|
|
OutBsno = this.txt_outbsno.Value.Trim();
|
|
|
this.h_outbsno.Value = OutBsno;
|
|
|
OutGid = this.h_outgid.Value.Trim();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
OutGid= getBSNO();
|
|
|
OutBsno = getCodeRuleWmsOut("出库单号", "BSNO");
|
|
|
this.h_outgid.Value = OutGid;
|
|
|
this.h_outbsno.Value = OutBsno;
|
|
|
this.txt_outbsno.Value = OutBsno;
|
|
|
}
|
|
|
WmsOutEntity.GID = OutGid;
|
|
|
WmsOutEntity.BSNO = OutBsno;
|
|
|
|
|
|
//WmsOutEntity.STORAGENAME = h_storage.Value;
|
|
|
//WmsOutEntity.TRUCKNO = h_truckno.Value;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return WmsOutEntity;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 将页面post获取的出库保存或更新“出库明细表”wms_out_detail,并返回操作结果
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的出库保存或更新“出库明细表”wms_out_detail,并返回操作结果
|
|
|
/// </summary>
|
|
|
private bool SaveWoDetailAction(WmsOutEntity wmsOutEntity)
|
|
|
{
|
|
|
IList<WmsOutDetailEntity> WmsOutDetailEntitys = new List<WmsOutDetailEntity>();
|
|
|
|
|
|
if (!WoDetailJSON.Trim().Equals(""))
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
WmsOutDetailEntitys = ResolveWoDetailJSON(WoDetailJSON.Trim(), WmsOutDetailEntitys);
|
|
|
this.WoDetailContainer.Value = "";
|
|
|
}
|
|
|
decimal totaloutfee = 0;//出库单的仓储费
|
|
|
bool State = false;
|
|
|
int count = 0;
|
|
|
int success = 0;
|
|
|
int nonum = 0;
|
|
|
int prescale = 0;
|
|
|
int nowscale = 0;
|
|
|
int nowgrade = 0;
|
|
|
decimal price = 0;
|
|
|
decimal gradefee = 0;
|
|
|
decimal sumfee = 0;
|
|
|
string newGID = "";
|
|
|
string bsno = "";
|
|
|
|
|
|
var strSql = "";
|
|
|
WmsOutDetailDA WmsOutDetailDA = new WmsOutDetailDA();
|
|
|
if (this.ck_jsfee.Checked)
|
|
|
{
|
|
|
if (WmsOutDetailEntitys != null)
|
|
|
{
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
{
|
|
|
decimal outnums = WmsOutDetailEntity.GOODSPFSL;
|
|
|
int feedays = WmsOutDetailDA.GetDaysCount("day", WmsOutDetailEntity.DODATE.ToString(), wmsOutEntity.DODATE.ToString());
|
|
|
if (feedays > 0)
|
|
|
{
|
|
|
WmsOutDetailEntity.OUTBSNO = wmsOutEntity.BSNO;
|
|
|
|
|
|
strSql = String.Format("SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT "
|
|
|
+ " FROM wms_rate "
|
|
|
+ " where BSNO='{0}' "
|
|
|
+ " order by BSNO,FEEGRADE ",
|
|
|
WmsOutDetailEntity.INBSNO);//wmsOutEntity.ASSOCIATEDNO);
|
|
|
DataSet dsrate = WmsOutDetailDA.GetRateListByCondition(strSql);
|
|
|
DataTable dtrate = new DataTable();
|
|
|
if (dsrate != null)
|
|
|
{
|
|
|
dtrate = dsrate.Tables[0];
|
|
|
if (dtrate.Rows.Count > 0)
|
|
|
{
|
|
|
prescale = 0;
|
|
|
nowscale = 0;
|
|
|
nowgrade = 0;
|
|
|
price = 0;
|
|
|
gradefee = 0;
|
|
|
sumfee = 0;
|
|
|
foreach (DataRow drow in dtrate.Rows)
|
|
|
{
|
|
|
nowgrade = int.Parse(drow["FEEGRADE"].ToString());
|
|
|
nowscale = int.Parse(drow["FEESCALE"].ToString());
|
|
|
price = decimal.Parse(drow["FEEPRICE"].ToString());
|
|
|
if (nowgrade.Equals(1))
|
|
|
{
|
|
|
if (feedays > nowscale)
|
|
|
{
|
|
|
gradefee = outnums * price * nowscale;
|
|
|
sumfee += gradefee;
|
|
|
prescale = nowscale;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
gradefee = outnums * price * (feedays - prescale);
|
|
|
sumfee += gradefee;
|
|
|
prescale = nowscale;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
else if (nowgrade > 1)
|
|
|
{
|
|
|
if (feedays > nowscale)
|
|
|
{
|
|
|
gradefee = outnums * price * (nowscale - prescale);
|
|
|
sumfee += gradefee;
|
|
|
prescale = nowscale;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
gradefee = outnums * price * (feedays - prescale);
|
|
|
sumfee += gradefee;
|
|
|
prescale = nowscale;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
if (feedays > nowscale)
|
|
|
{
|
|
|
gradefee = outnums * price * (feedays - nowscale);
|
|
|
sumfee += gradefee;
|
|
|
}
|
|
|
totaloutfee += sumfee;
|
|
|
WmsOutDetailEntity.DODATE = wmsOutEntity.DODATE;
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = sumfee;
|
|
|
WmsOutDetailEntity.GOODSOUTFEEAP = 0;
|
|
|
}
|
|
|
else
|
|
|
{//仓储费率没有设定
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{//计费天数错误
|
|
|
|
|
|
}
|
|
|
//保存wms_out_detail
|
|
|
newGID = Guid.NewGuid().ToString();
|
|
|
bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
WmsOutDetailEntity.GID = newGID;
|
|
|
WmsOutDetailEntity.BSNO = bsno;
|
|
|
WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
|
|
|
State = WmsOutDetailDA.Add(WmsOutDetailEntity, "");
|
|
|
count++;
|
|
|
if (State)
|
|
|
{
|
|
|
success++;
|
|
|
WmsInDA wmsinDA = new WmsInDA();
|
|
|
bool inState = wmsinDA.Update(WmsOutDetailEntity.GOODSPFSL,WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO);
|
|
|
}
|
|
|
else
|
|
|
{//保存失败
|
|
|
nonum++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//修改wms_out的仓储费wmsOutEntity.GOODSOUTFEE
|
|
|
h_outfee.Value = totaloutfee.ToString();
|
|
|
wmsOutEntity.GOODSOUTFEE = totaloutfee;
|
|
|
wmsOutEntity.GOODSOUTFEEAP = 0;
|
|
|
WmsOutDA wmsoutDA = new WmsOutDA();
|
|
|
State = wmsoutDA.Update(wmsOutEntity, "");
|
|
|
//页面赋值
|
|
|
txt_outbsno.Value = h_outbsno.Value;
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
string strcustomer = h_customer.Value;
|
|
|
string goods = h_goods.Value;
|
|
|
txt_goodsmodel.Value = h_goodsmodel.Value;
|
|
|
//txt_packnum.Value = wmsOutEntity.GOODSPACKPFSL.ToString();
|
|
|
h_packnum.Value = wmsOutEntity.GOODSPACKPFSL.ToString();
|
|
|
}
|
|
|
}
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('出库单生成成功');</script>");
|
|
|
h_post.Value = "";//请求状态清空
|
|
|
return true;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
/// </summary>
|
|
|
/// <param name="tempJSON"></param>
|
|
|
/// <param name="tempFeeEntities"></param>
|
|
|
/// <returns>将页面post获取的费用信息读入到费用实体类ch_fee中</returns>
|
|
|
private IList<WmsOutDetailEntity> ResolveWoDetailJSON(string tempJSON, IList<WmsOutDetailEntity> tempWoDetailEntities)
|
|
|
{
|
|
|
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)
|
|
|
{
|
|
|
WmsOutDetailEntity WmsOutDetailEntity = new WmsOutDetailEntity();
|
|
|
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
{
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
{
|
|
|
case "cust":
|
|
|
WmsOutDetailEntity.CUSTOMERNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "outcus":
|
|
|
WmsOutDetailEntity.CLIENTNAMEOLD = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "inbsno":
|
|
|
WmsOutDetailEntity.INBSNO =strArg[1].ToString().Replace("\"", "");
|
|
|
break;
|
|
|
case "wmsoutdetailgid":
|
|
|
string wmsoutdetailgid = strArg[1].ToString().Replace("\"", "");
|
|
|
if(wmsoutdetailgid.Trim()!="")
|
|
|
{
|
|
|
WmsOutDetailEntity.GID = wmsoutdetailgid;
|
|
|
WmsOutDetailEntity.BSNO = T_ALL_DA.GetStrSQL("BSNO", "select top 1 BSNO from wms_out_detail where gid='" + wmsoutdetailgid + "'");
|
|
|
}
|
|
|
break;
|
|
|
case "indate":
|
|
|
WmsOutDetailEntity.DODATE =DateTime.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
break;
|
|
|
case "goodsname":
|
|
|
WmsOutDetailEntity.GOODSNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "goodsmodel":
|
|
|
WmsOutDetailEntity.GOODSMODEL = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "truckno":
|
|
|
//WmsOutDetailEntity.TRUCKNO = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
WmsOutDetailEntity.TRUCKNO = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
|
|
|
break;
|
|
|
case "storage":
|
|
|
WmsOutDetailEntity.STORAGENAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "opseaibsno":
|
|
|
WmsOutDetailEntity.ASSOCIATEDNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
case "outnum":
|
|
|
Decimal tmpoutnum = strArg[1].ToString().Replace("\"", "").ToString().Trim() == "" ? 0 : Decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
WmsOutDetailEntity.GOODSPFSL = decimal.Parse( Round(tmpoutnum, 4).ToString());
|
|
|
break;
|
|
|
case "outpacknum":
|
|
|
WmsOutDetailEntity.GOODSPACKPFSL = strArg[1].ToString().Replace("\"", "").ToString().Trim() == "" ? 0 : decimal.Parse(strArg[1].ToString().Replace("\"", "").ToString());
|
|
|
break;
|
|
|
case "remark":
|
|
|
//WmsOutDetailEntity.REMARK = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
WmsOutDetailEntity.REMARK = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
|
|
|
break;
|
|
|
case "custparent":
|
|
|
WmsOutDetailEntity.CUSTOMERNAMEPARENT=strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
//CustParent.Add(WmsOutDetailEntity.CUSTOMERNAMEPARENT);
|
|
|
break;
|
|
|
case "arfee":
|
|
|
WmsOutDetailEntity.ARFEE = strArg[1].ToString().Replace("\"", "").ToString().Trim() == "" ? 0 : decimal.Parse(strArg[1].ToString().Replace("\"", "").ToString());
|
|
|
break;
|
|
|
case "apfee":
|
|
|
WmsOutDetailEntity.APFEE = strArg[1].ToString().Replace("\"", "").ToString().Trim() == "" ? 0 : decimal.Parse(strArg[1].ToString().Replace("\"", "").ToString());
|
|
|
break;
|
|
|
case "startbillingdate":
|
|
|
WmsOutDetailEntity.STARTBILLINGDATE = strArg[1].ToString().Replace("\"", "") == "" ? DateTime.Parse("0001-01-01 00:00:00") : DateTime.Parse(strArg[1].ToString().Replace("\"", ""));//开始计费日期
|
|
|
break;
|
|
|
case "startbillingdateap":
|
|
|
WmsOutDetailEntity.STARTBILLINGDATEAP = strArg[1].ToString().Replace("\"", "") == "" ? DateTime.Parse("0001-01-01 00:00:00") : DateTime.Parse(strArg[1].ToString().Replace("\"", ""));//应付开始计费日期
|
|
|
break;
|
|
|
case "goodsstandard":
|
|
|
WmsOutDetailEntity.GOODSSTANDARD = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
|
|
|
break;
|
|
|
case "goodsgrade":
|
|
|
WmsOutDetailEntity.GOODSGRADE = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
|
|
|
break;
|
|
|
case "goodsslice":
|
|
|
WmsOutDetailEntity.GOODSSLICE = strArg[1].ToString().Replace("\"", "").ToString().Trim() == "" ? 0 : decimal.Parse(strArg[1].ToString().Replace("\"", "").ToString());
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
if (!this.h_storage.Value.ToString().Equals("") && !this.h_storage.Value.Equals(null))
|
|
|
{
|
|
|
WmsOutDetailEntity.STORAGENAME = this.h_storage.Value.ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
WmsOutDetailEntity.STORAGENAME = " ";
|
|
|
}
|
|
|
WmsOutDetailEntity.CREATEUSER =strShowName;
|
|
|
|
|
|
tempWoDetailEntities.Add(WmsOutDetailEntity);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return tempWoDetailEntities;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
/// </summary>
|
|
|
/// <param name="tempJSON"></param>
|
|
|
/// <param name="tempFeeEntities"></param>
|
|
|
/// <returns>将页面post获取的费用信息读入到费用实体类ch_fee中</returns>
|
|
|
private IList<FeeEntity> ResolveFeeJSON(string tempJSON, IList<FeeEntity> tempFeeEntities)
|
|
|
{
|
|
|
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)
|
|
|
{
|
|
|
FeeEntity feeEntity = new FeeEntity();
|
|
|
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
{
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
{
|
|
|
case "id":
|
|
|
feeEntity.GID = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
case "type":
|
|
|
feeEntity.FeeType = int.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "bsno":
|
|
|
feeEntity.BSNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
case "outbsno":
|
|
|
feeEntity.WMSOUTBSNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
case "status":
|
|
|
|
|
|
break;
|
|
|
case "fname":
|
|
|
feeEntity.FeeName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "cust":
|
|
|
feeEntity.CustomerName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "unit":
|
|
|
string tempUnit = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
|
if (tempUnit.Equals("null") || tempUnit.Equals(""))
|
|
|
{
|
|
|
feeEntity.Unit = "";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
feeEntity.Unit = tempUnit;
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
case "price":
|
|
|
feeEntity.UnitPrice = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "quant":
|
|
|
feeEntity.Quantity = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "com":
|
|
|
feeEntity.CommissionRate = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "amount":
|
|
|
feeEntity.Amount = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "cur":
|
|
|
feeEntity.Currency = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
case "rate":
|
|
|
feeEntity.ExchangeRate = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "frt":
|
|
|
feeEntity.FeeFrt = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
break;
|
|
|
case "remark":
|
|
|
feeEntity.Remark = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
break;
|
|
|
case "isadv":
|
|
|
feeEntity.IsAdvancePay = strArg[1].ToString().Replace("\"", "").Trim().Equals("1") ? true : false;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
strSeaBSNO = feeEntity.BSNO;
|
|
|
feeEntity.EnterOperator = this.strUserID;
|
|
|
feeEntity.FeeStatus = 1;
|
|
|
tempFeeEntities.Add(feeEntity);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return tempFeeEntities;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region Unicode-GB Code转换
|
|
|
/// <summary>
|
|
|
/// Unicode-GB Code转换
|
|
|
/// </summary>
|
|
|
/// <param name="text">将Unicode编码字符转换成GB编码字符</param>
|
|
|
/// <returns>GB Code字符串</returns>
|
|
|
public string UnicodeToGB(string text)
|
|
|
{
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
text = unicode.GetString(unicode.GetBytes(Regex.Unescape(text.Trim())));
|
|
|
return text;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// Unicode-GB Code转换
|
|
|
/// </summary>
|
|
|
/// <param name="text">将Unicode编码字符转换成GB编码字符</param>
|
|
|
/// <returns>GB Code字符串</returns>
|
|
|
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
|
|
|
|
|
|
#region 将页面post获取的利润值读入到利润实体类中
|
|
|
/// <summary>
|
|
|
/// 将页面post获取的利润值读入到利润实体类中
|
|
|
/// </summary>
|
|
|
/// <returns>返回利润实体类 FeeProfitEntity</returns>
|
|
|
private FeeProfitEntity GetRequestProfit()
|
|
|
{
|
|
|
FeeProfitEntity tempFeeProfitEntity = new FeeProfitEntity();
|
|
|
|
|
|
#region 保留
|
|
|
//tempFeeProfitEntity.RMBDR = Decimal.Parse(dvRecvRMBVal.InnerText.Trim());
|
|
|
//tempFeeProfitEntity.USDDR = Decimal.Parse(dvUSRecvVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.OTHERDR = Decimal.Parse(dvOtherCurrencyRecvVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.RMBCR = Decimal.Parse(dvPayRMBVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.USDCR = Decimal.Parse(dvUSPayVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.OTHERCR = Decimal.Parse(dvOtherCurrencyPayVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.DRTTL = Decimal.Parse(dvRecvTotalVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.CRTTL = Decimal.Parse(dvPaySumVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.RMBProfit = Decimal.Parse(dvRMBProfitVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.USDProfit = Decimal.Parse(dvUSProfitVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.OTHERProfit = Decimal.Parse(dvOtherCurrencyProfitVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.TTLProfit = Decimal.Parse(dvProfitTotalVal.InnerHtml.Trim());
|
|
|
//tempFeeProfitEntity.ProfitRate = dvProfitRateVal.InnerHtml.Trim();
|
|
|
#endregion
|
|
|
|
|
|
if (!gainContainer.Value.Trim().Equals(""))
|
|
|
{
|
|
|
string[] gainList = gainContainer.Value.Trim().Split(new char[] { ',' });
|
|
|
|
|
|
if (!gainList[0].ToString().Trim().Equals(""))
|
|
|
{
|
|
|
tempFeeProfitEntity.RMBDR = Decimal.Parse(gainList[0].ToString().Trim());
|
|
|
tempFeeProfitEntity.USDDR = Decimal.Parse(gainList[1].ToString().Trim());
|
|
|
tempFeeProfitEntity.OTHERDR = Decimal.Parse(gainList[2].ToString().Trim());
|
|
|
tempFeeProfitEntity.RMBCR = Decimal.Parse(gainList[3].ToString().Trim());
|
|
|
tempFeeProfitEntity.USDCR = Decimal.Parse(gainList[4].ToString().Trim());
|
|
|
tempFeeProfitEntity.OTHERCR = Decimal.Parse(gainList[5].ToString().Trim());
|
|
|
tempFeeProfitEntity.DRTTL = Decimal.Parse(gainList[6].ToString().Trim());
|
|
|
tempFeeProfitEntity.CRTTL = Decimal.Parse(gainList[7].ToString().Trim());
|
|
|
tempFeeProfitEntity.RMBProfit = Decimal.Parse(gainList[8].ToString().Trim());
|
|
|
tempFeeProfitEntity.USDProfit = Decimal.Parse(gainList[9].ToString().Trim());
|
|
|
tempFeeProfitEntity.OTHERProfit = Decimal.Parse(gainList[10].ToString().Trim());
|
|
|
tempFeeProfitEntity.TTLProfit = Decimal.Parse(gainList[11].ToString().Trim());
|
|
|
tempFeeProfitEntity.ProfitRate = gainList[12].ToString().Trim();
|
|
|
tempFeeProfitEntity.CreateUser = strUserID;
|
|
|
tempFeeProfitEntity.ModifiedUser = strUserID;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
tempFeeProfitEntity.RMBDR = 0;
|
|
|
tempFeeProfitEntity.USDDR = 0;
|
|
|
tempFeeProfitEntity.OTHERDR = 0;
|
|
|
tempFeeProfitEntity.RMBCR = 0;
|
|
|
tempFeeProfitEntity.USDCR = 0;
|
|
|
tempFeeProfitEntity.OTHERCR = 0;
|
|
|
tempFeeProfitEntity.DRTTL = 0;
|
|
|
tempFeeProfitEntity.CRTTL = 0;
|
|
|
tempFeeProfitEntity.RMBProfit = 0;
|
|
|
tempFeeProfitEntity.USDProfit = 0;
|
|
|
tempFeeProfitEntity.OTHERProfit = 0;
|
|
|
tempFeeProfitEntity.TTLProfit = 0;
|
|
|
tempFeeProfitEntity.ProfitRate = "0%";
|
|
|
tempFeeProfitEntity.CreateUser = this.strUserID;
|
|
|
tempFeeProfitEntity.ModifiedUser = this.strUserID;
|
|
|
}
|
|
|
}
|
|
|
return tempFeeProfitEntity;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 获取用户应收、应付权限信息
|
|
|
/// <summary>
|
|
|
/// 获取用户应收、应付权限信息
|
|
|
/// </summary>
|
|
|
/// <param name="tempFeeType">费用类型</param>
|
|
|
/// <returns>返回 true 有权限操作数据 false 没有权限操作数据</returns>
|
|
|
private bool ValidateUserFeeAuthority(int tempFeeType)
|
|
|
{
|
|
|
int iResult = 0;
|
|
|
|
|
|
if (tempFeeType == 1)
|
|
|
{
|
|
|
UserAuthorityManage userAuthorityManageOrder = new UserAuthorityManage(strUserID, "modSeaImportList");
|
|
|
UserAuthorityManage userRecvAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiRecvFeeManagement");
|
|
|
|
|
|
if (userRecvAuthorityManage.OperateType != AuthorityType.NULL)
|
|
|
{
|
|
|
iResult = userAuthorityManageOrder.CheckOperateRange(ModuleType.OPSEAILIST, userRecvAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strSeaBSNO, "", strUserID);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
UserAuthorityManage userAuthorityManageOrder = new UserAuthorityManage(strUserID, "modSeaImportList");
|
|
|
UserAuthorityManage userPayAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiPayFeeManagement");
|
|
|
|
|
|
if (userPayAuthorityManage.OperateType != AuthorityType.NULL)
|
|
|
{
|
|
|
iResult = userAuthorityManageOrder.CheckOperateRange(ModuleType.OPSEAILIST, userPayAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strSeaBSNO, "", strUserID);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (iResult > 0)
|
|
|
{
|
|
|
return true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region getBSNO
|
|
|
protected String getBSNO()
|
|
|
{
|
|
|
string strBSNO = Guid.NewGuid().ToString();
|
|
|
strBSNO = strBSNO.Replace("-", "");
|
|
|
strBSNO = "WmsOut" + strBSNO;
|
|
|
return strBSNO;
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 提取规则编号 getCodeRuleWmsOutDetail
|
|
|
/// <summary>
|
|
|
/// 提取规则编号
|
|
|
/// </summary>
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
/// <returns></returns>
|
|
|
protected String getCodeRuleWmsOutDetail(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 *,getdate() DODATE 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 (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().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='" + strUserID + "')");
|
|
|
}
|
|
|
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='" + strUserID + "')");
|
|
|
}
|
|
|
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;
|
|
|
//
|
|
|
//DataSet ds1 = T_ALL_DA.GetAllSQL("select top 1 " + strfield + " from [wms_out_detail] where " + strfield + " like '" + strCONTENT.Trim() + "%' order by " + strfield + " DESC");
|
|
|
//if (ds1 != null)
|
|
|
//{
|
|
|
// if (ds.Tables[0].Rows.Count > 0)
|
|
|
// {
|
|
|
// strRULENOLENGTH = ds1.Tables[0].Rows[0][0].ToString().Trim();
|
|
|
// }
|
|
|
//}
|
|
|
T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [wms_out_detail] where " + strfield + " like '" + strCONTENT.Trim() + "%' order by " + strfield + " DESC");// and isnull(ISDELETE,0)=0
|
|
|
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 "";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 提取规则编号 getCodeRuleWmsOut
|
|
|
/// <summary>
|
|
|
/// 提取规则编号
|
|
|
/// </summary>
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
/// <returns></returns>
|
|
|
protected String getCodeRuleWmsOut(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 *,getdate() DODATE 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 (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().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='" + strUserID + "')");
|
|
|
}
|
|
|
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='" + strUserID + "')");
|
|
|
}
|
|
|
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_out] where " + strfield + " like '" + strCONTENT.Trim() + "%' and isnull(ISDELETE,0)=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 "";
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 提取规则编号 getCodeRuleEnabled
|
|
|
/// <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 == "BSNO")
|
|
|
{
|
|
|
if (ds.Tables[0].Rows[0]["ISALLOWEDITS"].ToString().Trim().Equals("True"))
|
|
|
{
|
|
|
txt_outbsno.Disabled=false;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
txt_outbsno.Disabled=true;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
#region 提取规则编号
|
|
|
/// <summary>
|
|
|
/// 提取规则编号
|
|
|
/// </summary>
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
/// <returns></returns>
|
|
|
protected String getCodeRuleWmsIn(string strRULENAME, string strfield, SqlTransaction trans)
|
|
|
{
|
|
|
//调用编码规则
|
|
|
string strRULEYEAR = "";
|
|
|
string strRULECONTENT = "";
|
|
|
string strCODENAME = "";
|
|
|
string strDEPTNO = "";
|
|
|
string strRULENOLENGTH = "";
|
|
|
int iRULENOLENGTH = 0;
|
|
|
int inum = 0;
|
|
|
string strCONTENT = "";
|
|
|
DataSet ds = new DataSet();
|
|
|
//DataSet ds = T_ALL_DA.GetAllSQL("select *,getdate() DODATE from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3");
|
|
|
SqlParameter parm = new SqlParameter("@RULENAME", SqlDbType.VarChar, 100);
|
|
|
parm.Value=strRULENAME.Trim();
|
|
|
string ststt="select *,getdate() DODATE from code_rule where RULENAME=@RULENAME and RULETYPE=3 ";
|
|
|
ds = SqlHelper.ExecuteQueryDataset(trans, CommandType.Text, ststt, parm);
|
|
|
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 (tbDODATE.Text.Trim() == "")
|
|
|
//{
|
|
|
// return "";
|
|
|
//}
|
|
|
if (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
{
|
|
|
return "";
|
|
|
}
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().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='" + strUserID + "')");
|
|
|
SqlParameter parm1 = new SqlParameter("@USERID", SqlDbType.VarChar, 100);
|
|
|
parm1.Value = strUserID;
|
|
|
ststt = "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID=@USERID)";
|
|
|
ds = SqlHelper.ExecuteQueryDataset(trans, CommandType.Text, ststt, parm1);
|
|
|
strCODENAME = ds.Tables[0].Rows[0]["CODENAME"].ToString().Equals(null) ? "" : ds.Tables[0].Rows[0]["CODENAME"].ToString();
|
|
|
}
|
|
|
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='" + strUserID + "')");
|
|
|
SqlParameter parm2 = new SqlParameter("@USERID", SqlDbType.VarChar, 100);
|
|
|
parm2.Value = strUserID;
|
|
|
ststt = "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID=@USERID";
|
|
|
ds = SqlHelper.ExecuteQueryDataset(trans, CommandType.Text, ststt, parm2);
|
|
|
strDEPTNO = ds.Tables[0].Rows[0]["DEPTNO"].ToString().Equals(null) ? "" : ds.Tables[0].Rows[0]["DEPTNO"].ToString();
|
|
|
}
|
|
|
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_in] where " + strfield + " like '" + strCONTENT.Trim() + "%' and ISDELETE=0 order by " + strfield + " DESC");
|
|
|
SqlParameter parm3 = new SqlParameter("@BSNO", SqlDbType.VarChar, 100);
|
|
|
parm3.Value = strCONTENT.Trim();
|
|
|
ststt = "select top 1 BSNO from [wms_in] where BSNO like '"+strCONTENT.Trim()+ "%' and ISDELETE=0 order by BSNO DESC";
|
|
|
ds = SqlHelper.ExecuteQueryDataset(trans, CommandType.Text, ststt, parm3);
|
|
|
if (!ds.Equals(null) && !ds.Tables[0].Equals(null) && ds.Tables[0].Rows.Count>0 )
|
|
|
{
|
|
|
strRULENOLENGTH = ds.Tables[0].Rows[0]["BSNO"].ToString().Equals(null) ? "" : ds.Tables[0].Rows[0]["BSNO"].ToString();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
strRULENOLENGTH = "";
|
|
|
}
|
|
|
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 "";
|
|
|
}
|
|
|
|
|
|
protected String getBSNOWmsIn()
|
|
|
{
|
|
|
string strBSNO = Guid.NewGuid().ToString();
|
|
|
strBSNO = strBSNO.Replace("-", "");
|
|
|
strBSNO = "WmsIn" + strBSNO;
|
|
|
return strBSNO;
|
|
|
}
|
|
|
|
|
|
protected String getWMSNO()
|
|
|
{
|
|
|
string strWMSNO = Guid.NewGuid().ToString();
|
|
|
strWMSNO = strWMSNO.Replace("-", "");
|
|
|
strWMSNO = "Wms" + strWMSNO;
|
|
|
return strWMSNO;
|
|
|
}
|
|
|
#endregion
|
|
|
}
|
|
|
}
|