You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/SeaiFee/WmsOutEdit.aspx.cs

5601 lines
362 KiB
C#

2 years ago
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 WmsOutEdit : 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_3;
private string payJSON_3;
private string recvJSON_2;
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;
private string payJSON;
protected void Page_Load(object sender, EventArgs e)
{
#region 基本信息
this.h_oplb.Value = "op_Seai";
this.h_wmsoutbsno.Value = "";
this.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())));
}
if (Request.QueryString["bsno"] != null)
{
this.h_opseaibsno.Value = Request.QueryString["bsno"].ToString();
}
else
{
this.h_opseaibsno.Value = "";
this.h_bsno.Value = 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;
}
}
this.h_islock.Value = "false";
if (Request.QueryString["isdisabled"] != null)
{
this.h_isdisabled.Value = Request.QueryString["isdisabled"].ToString().Trim();
bool isdisabled = bool.Parse(this.h_isdisabled.Value.Trim());
if (Request.QueryString["islock"] != null)
{
this.h_islock.Value = Request.QueryString["islock"].ToString().Trim();
}
setIsDisabled(isdisabled, false, bool.Parse(this.h_islock.Value.Trim()));
}
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;
}
#endregion
#region 保存操作
WoJSON = "";
WoDetailJSON = "";
WoJSON=this.WoContainer.Value;
WoDetailJSON = this.WoDetailContainer.Value;
recvJSON_3 = this.recvContainer_3.Value.Trim();
payJSON_3 = this.payContainer_3.Value.Trim();
recvJSON_2 = "";
recvJSON_2 = this.recvContainer_2.Value.Trim();
//
if (this.h_post_2.Value.Trim() != "")
{
//保存操作
if (this.h_post_2.Value.Trim() == "1")
{
if (!recvJSON_3.Trim().Equals("") || !payJSON_3.Trim().Equals(""))
{ // 将页面post获取的费用信息保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain并返回操作结果
SaveFeeAction();
}
}
else if (this.h_post_2.Value.Trim() == "2")
{
if (!WoJSON.Trim().Equals(""))
{
if (this.h_Handle.Value.Trim() == "edit")
{
SaveWoOutActionEdit();
}
else
{
SaveWoOutAction();
}
}
}
else if (this.h_post_2.Value.Trim() == "3")
{
if (!WoJSON.Trim().Equals(""))
{
if (this.h_Handle.Value.Trim() == "edit")
{
CargoRightTransferEdit();
}
else
{
CargoRightTransfer();
}
}
}
else if (this.h_post_2.Value.Trim() == "4")
{
//仓储费率
if (!recvJSON_2.Trim().Equals(""))
{
SaveRateAction();
recvJSON_2 = "";
this.recvContainer_2.Value = "";
this.h_post_2.Value = "";
}
}
}
#endregion
if (this.h_Handle.Value.Trim() == "edit")
{
//获取出库单的信息
h_Mode.Value = "1";
getHJ();
this.divchfee.Visible = true;
//
#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, true, bool.Parse(this.h_islock.Value.Trim()));
}
}
else if (this.hdRangeO.Value.Trim().Equals("2"))//部门
{
alt = RangeDA.GetWmsOutListDEPT(strDeptName, this.h_outgid.Value.Trim(), strCompanyID, strUserID);
if (alt == "")
{
setIsDisabled(true, true, bool.Parse(this.h_islock.Value.Trim()));
}
}
else if (this.hdRangeO.Value.Trim().Equals("3"))//个人
{
alt = RangeDA.GetWmsOutListPerson(strUserID, this.h_outgid.Value.Trim(), strCompanyID);
if (alt == "")
{
setIsDisabled(true, true, bool.Parse(this.h_islock.Value.Trim()));
}
}
else if (this.hdRangeO.Value.Trim().Equals("4"))//无
{
setIsDisabled(true, true, bool.Parse(this.h_islock.Value.Trim()));
}
}
#endregion
}
else
{
this.divchfee.Visible = false;
this.btislock.Visible = false;
this.btnotislock.Visible = false;
this.btOldCustFeeDate.Visible = false;
this.btUpdateGOODSOUTFEE.Visible = false;
}
#region 应收应付费用录入
recvJSON = "";
payJSON = "";
recvJSON = this.recvContainer.Value.Trim();
payJSON = this.payContainer.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();
}
}
}
#endregion
#endregion
//加载下拉框
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initcomboOutCustomer();initComboTRUCKNAME();initComboARCLIENT();initcombomblnonew();initComboARCLIENTWMSOUT()</script>");
}
#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 应收应付费用录入
#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(""))
{ //将应收费用信息从前台页面写入费用实体类feeEntities
feeEntities = ResolveFeeJSON(recvJSON.Trim(), feeEntities);
recvContainer.Value = "";
}
if (!payJSON.Trim().Equals(""))
{ //将应付费用信息从前台页面写入费用实体类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, this.h_bsno.Value.Trim(), strUserID);//strSeaBSNO
if (iRecvState == 1)
{
gainContainer.Value = "";
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
}
}
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 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":
string str = strArg[1].ToString().Replace("\"", "").Trim();
if (str.Trim() == "")
{
feeEntity.BSNO = this.h_outgid.Value.Trim();
}
else
{
feeEntity.BSNO = str;
}
break;
case "status":
//feeEntity.FeeStatus=int.Parse(strArg[1].ToString().Replace("\"", "").ToString());
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":
UnicodeEncoding unicode = new UnicodeEncoding();
string lsremark = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
feeEntity.Remark = lsremark.Trim();
break;
case "isadv":
feeEntity.IsAdvancePay = strArg[1].ToString().Replace("\"", "").Trim().Equals("1") ? true : false;
break;
case "linenum":
feeEntity.LINENUM = strArg[1].ToString().Replace("\"", "").Trim() == "" ? 0 : int.Parse(strArg[1].ToString().Replace("\"", "").Trim());
break;
default:
break;
}
}
feeEntity.WMSOUTBSNO = this.h_outgid.Value.Trim();
feeEntity.EnterOperator = this.strUserID;
feeEntity.FeeStatus = 1;
tempFeeEntities.Add(feeEntity);
}
}
}
}
return tempFeeEntities;
}
#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() == "" ? "0%" : 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, this.h_bsno.Value.Trim(), "", strUserID);//strSeaBSNO
}
}
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, this.h_bsno.Value.Trim(), "", strUserID);//strSeaBSNO
}
}
if (iResult > 0)
{
return true;
}
else
{
return false;
}
}
#endregion
#endregion
#region 出库操作
#region 生成出库单
/// <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");
//
string strVALIDDATE = WmsOutEntity.VALIDDATE.ToString().Trim().IndexOf("0001")>-1 ? "" : ",'" + WmsOutEntity.VALIDDATE.ToString() + "'";
string strVALIDDATE_name = WmsOutEntity.VALIDDATE.ToString().Trim().IndexOf("0001") > -1 ? "" : ",VALIDDATE";
//
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,CLIENTBSNO,TOTALNO,REMARK2{22},CHARGEUNIT,MBLNONEW,CORPID,ARCLIENTWMSOUT,BZTCHNO,ISCOLLECTING)"
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',getdate(),'{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','','{19}','{20}','{21}'{23},'{24}','{25}','{26}','{27}','{28}','{29}')"
, 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.CLIENTBSNO, WmsOutEntity.TOTALNO, WmsOutEntity.REMARK2, strVALIDDATE_name, strVALIDDATE, WmsOutEntity.CHARGEUNIT, WmsOutEntity.MBLNONEW, strCompanyID, WmsOutEntity.ARCLIENTWMSOUT, WmsOutEntity.BZTCHNO, WmsOutEntity.ISCOLLECTING);
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 计算仓储费[已注销]
/*
int feedays = 0;
if (WmsOutDetailEntity.STARTBILLINGDATE.ToString().Trim().IndexOf("0001") < 0)
{
feedays = WmsOutDetailDA.GetDaysCount("day", WmsOutDetailEntity.STARTBILLINGDATE.ToString(), WmsOutEntity.OLDCUSTFEEDATE.ToString().Trim());//WmsOutEntity.DODATE.ToString() 出库-开始计费日期
if (feedays > 0)
{
if (this.ck_jsfee.Checked)
{
SqlParameter parmrate = new SqlParameter("@BSNO", SqlDbType.VarChar, 100);
parmrate.Value = WmsOutDetailEntity.INBSNO;//WmsOutEntity.ASSOCIATEDNO;
Sqlstr = String.Format("SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT FROM wms_rate where BSNO=@BSNO and CUSTOMERNAME like '%{0}%' order by BSNO,FEEGRADE ", WmsOutEntity.CUSTOMERNAME);
DataSet dsrate = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr.ToString(), parmrate);
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;
//计算 开始计费日期和计费天数
//if (price > 0)
//{
// dtime = WmsOutDetailEntity.DODATE.ToString();//开始计费日期 STARTBILLINGDATE
// iFEEDAYS = nowscale;//计费天数 FEEDAYS
//}
//
prescale = nowscale;//本次计费区间
}
else
{
gradefee = outnums * price * (feedays - prescale);//出库量*计费单价*(仓储天数-上一个计费区间(0)
sumfee += gradefee;
//计算 开始计费日期和计费天数
//if (price > 0)
//{
// dtime = WmsOutDetailEntity.DODATE.ToString();//开始计费日期 STARTBILLINGDATE
// iFEEDAYS = feedays - prescale;//计费天数 FEEDAYS
//}
//
prescale = nowscale;//本次计费区间
break;
}
}
else if (nowgrade > 1)//计费等级
{
if (feedays > nowscale)
{
gradefee = outnums * price * (nowscale - prescale);//出库量*计费单价*(计费区间-上一个计费区间(0)
sumfee += gradefee;
//计算 开始计费日期和计费天数
//if (price > 0)
//{
// if (dtime.Trim() == "")
// {
// dtime = (DateTime.Parse(WmsOutDetailEntity.DODATE.ToString()).AddDays(prescale)).ToString().Trim();//开始计费日期 STARTBILLINGDATE
// }
// iFEEDAYS += (nowscale - prescale);//计费天数 FEEDAYS
//}
//
prescale = nowscale;//本次计费区间
}
else
{
gradefee = outnums * price * (feedays - prescale);//出库量*计费单价*(仓储天数-上一个计费区间(0)
sumfee += gradefee;
//计算 开始计费日期和计费天数
//if (price > 0)
//{
// if (dtime.Trim() == "")
// {
// dtime = (DateTime.Parse(WmsOutDetailEntity.DODATE.ToString()).AddDays(prescale)).ToString().Trim();//开始计费日期 STARTBILLINGDATE
// }
// iFEEDAYS += (feedays - prescale);//计费天数 FEEDAYS
//}
//
prescale = nowscale;//本次计费区间
break;
}
}
}
if (feedays > nowscale)
{
gradefee = outnums * price * (feedays - nowscale);//出库量*计费单价*(仓储天数-计费区间(0)
sumfee += gradefee;
//计算 开始计费日期和计费天数
//if (price > 0)
//{
// if (dtime.Trim() == "")
// {
// dtime = (DateTime.Parse(WmsOutDetailEntity.DODATE.ToString()).AddDays(nowscale - 1)).ToString().Trim();//开始计费日期 STARTBILLINGDATE
// }
// iFEEDAYS += (feedays - nowscale);//计费天数 FEEDAYS
//}
}
totaloutfee += sumfee;
}
else
{//仓储费率没有设定
sqlTran.Rollback();
result = -2;
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>alert('仓储费率没有设置');</script>");
Clearh();
return result;
}
}
else
{
sqlTran.Rollback();
result = -3;
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>alert('仓储费率没有设置');</script>");
Clearh();
return result;
}
}
else
{
feedays = 0;
sumfee = 0;
//iFEEDAYS = 0;
//dtime = "";
}
}
else
{
feedays = 0;
sumfee = 0;
//iFEEDAYS = 0;
//dtime = "";
}
}
else
{
feedays = 0;
sumfee = 0;
//iFEEDAYS = 0;
//dtime = "";
}
*/
#endregion
#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
//
#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.CORPID = strCompanyID;
WmsOutDetailEntity.BZTCHNO = WmsOutEntity.BZTCHNO;
//
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,";
string strSTARTBILLINGDATEAP = WmsOutDetailEntity.STARTBILLINGDATEAP.ToString().IndexOf("0001") > -1 ? "" : "'" + WmsOutDetailEntity.STARTBILLINGDATEAP.ToString() + "',";
string strSTARTBILLINGDATEAP_name = strSTARTBILLINGDATEAP.Equals("") ? "" : "STARTBILLINGDATEAP,";
string strENDBILLINGDATEAP = WmsOutDetailEntity.STARTBILLINGDATEAP.ToString().IndexOf("0001") > -1 ? "" : "'" + WmsOutEntity.OLDCUSTFEEDATE.ToString() + "',";//如果开始计费日期为空,则结束计费日期也为空,否则为上家承担仓储期限。
string strENDBILLINGDATEAP_name = strENDBILLINGDATEAP.Equals("") ? "" : "ENDBILLINGDATEAP,";
//
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,CHARGEUNIT,{27}{29}FEEDAYSAP,CORPID,MARKETVALUE,AREANAME,BZTCHNO) "
+ " 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}','{32}',{28}{30}'{31}','{33}',{34},'{35}','{36}')"
, 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, strSTARTBILLINGDATEAP_name, strSTARTBILLINGDATEAP, strENDBILLINGDATEAP_name, strENDBILLINGDATEAP, WmsOutDetailEntity.FEEDAYSAP, WmsOutDetailEntity.CHARGEUNIT, strCompanyID, WmsOutDetailEntity.MARKETVALUE, WmsOutDetailEntity.AREANAME, WmsOutDetailEntity.BZTCHNO);
//
WmsOutEntity.GOODSSTANDARD = WmsOutDetailEntity.GOODSSTANDARD;
//
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 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;
}
}// 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},GOODSSTANDARD='{3}' where GID='{1}'", WmsOutEntity.GOODSOUTFEE, WmsOutEntity.GID, WmsOutEntity.GOODSOUTFEEAP, WmsOutEntity.GOODSSTANDARD);
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
if (iState != 1)
{
sqlTran.Rollback();
result = -7;
Clearh();
return result;
}
#endregion
#region 将仓储费写入ch_fee[已注销]
/*
if (isJsFee == true)
{
FeeDA feeDA = new FeeDA();
IList<FeeEntity> feeEntities = new List<FeeEntity>();
FeeEntity feeEntity = new FeeEntity();
Decimal deprice = 0;
if (WmsOutEntity.GOODSPFSL != 0)
{
deprice = Decimal.Parse((WmsOutEntity.GOODSOUTFEE / WmsOutEntity.GOODSPFSL).ToString());
}
else
{
deprice = 0;
}
deprice = Round(deprice, 2, "");
if (deprice != 0)
{
feeEntity.GID = Guid.NewGuid().ToString();
feeEntity.FeeType = 1;
feeEntity.BSNO = WmsOutEntity.ASSOCIATEDNO;
feeEntity.FeeName = "仓储费";
feeEntity.CustomerName = WmsOutEntity.CUSTOMERNAME;
feeEntity.Unit = "重量";
feeEntity.UnitPrice =decimal.Parse( deprice.ToString());
feeEntity.Quantity = WmsOutEntity.GOODSPFSL;
feeEntity.CommissionRate = 1;
feeEntity.Amount = WmsOutEntity.GOODSOUTFEE;
feeEntity.Currency = "RMB";
feeEntity.ExchangeRate = 1;
feeEntity.FeeFrt = "";
feeEntity.Remark = "";
feeEntity.IsAdvancePay = false;
feeEntity.EnterOperator = WmsOutEntity.CREATEUSER;
feeEntity.FeeStatus = 1;
feeEntity.WMSOUTBSNO = WmsOutEntity.BSNO;
feeEntities.Add(feeEntity);
iState = feeDA.DoFee(feeEntities, WmsOutEntity.BSNO, strUserID);
feeEntities.Remove(feeEntity);
if (iState != 1)
{
sqlTran.Rollback();
result = -8;
Clearh();
return result;
}
}
//出库费写入ch_fee
WmsFeeCodeDA WmsFeeCodeDA = new WmsFeeCodeDA();
string strSql11 = String.Format("SELECT GID,FEETYPE,FEECODE,FEENAME,BSNO,CLIENT,UNIT,CURRENCY,UNITPRICE,EXCHANGERATE,SORT,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,REMARK FROM wms_feeCode "
+ " where BSNO='{0}' ", WmsOutEntity.ASSOCIATEDNO);
DataSet ds = WmsFeeCodeDA.GetRateListByCondition(strSql11);
DataTable dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
foreach (DataRow r in dt.Rows)
{
if (r["FEENAME"].ToString() == "出库费")
{
feeEntity = new FeeEntity();
feeEntity.GID = Guid.NewGuid().ToString();
feeEntity.FeeType = 1;
feeEntity.BSNO = WmsOutEntity.ASSOCIATEDNO;
feeEntity.FeeName = "出库费";
feeEntity.CustomerName = WmsOutEntity.CUSTOMERNAME;
feeEntity.Unit = "重量";
feeEntity.UnitPrice = decimal.Parse(r["UNITPRICE"].ToString());
feeEntity.Quantity = WmsOutEntity.GOODSPFSL;
feeEntity.CommissionRate = 1;
Decimal amount = Decimal.Parse(WmsOutEntity.GOODSPFSL.ToString()) * Decimal.Parse(r["UNITPRICE"].ToString());
feeEntity.Amount = decimal.Parse(Round(amount, 2, "").ToString());
feeEntity.Currency = "RMB";
feeEntity.ExchangeRate = 1;
feeEntity.FeeFrt = "";
feeEntity.Remark = "";
feeEntity.IsAdvancePay = false;
feeEntity.EnterOperator = WmsOutEntity.CREATEUSER;
feeEntity.FeeStatus = 1;
feeEntity.WMSOUTBSNO = WmsOutEntity.BSNO;
feeEntities.Add(feeEntity);
//保存如ch_fee
iState = feeDA.DoFee(feeEntities, WmsOutEntity.BSNO, strUserID);
if (iState != 1)
{
sqlTran.Rollback();
result = -9;
Clearh();
return result;
}
}
}
}
//else
//{//没有设置出库费
//}
}//end 将仓储费和出库费写入ch_fee
*/
#endregion
//页面赋值
this.h_wmsoutbsno.Value = WmsOutEntity.BSNO.ToString();
this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL.ToString();
this.h_goodspfsl.Value = WmsOutEntity.GOODSPFSL.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 更改出库单
/// <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");
//
string strVALIDDATE = WmsOutEntity.VALIDDATE.ToString().Trim().IndexOf("0001") > -1 ? "" : ",VALIDDATE='" + WmsOutEntity.VALIDDATE.ToString() + "'";
//
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}',CLIENTBSNO='{19}',TOTALNO='{20}',REMARK2='{21}'{22},MBLNONEW='{23}',CORPID='{24}',ARCLIENTWMSOUT='{25}',BZTCHNO='{26}',ISCOLLECTING='{27}' 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.CLIENTBSNO, WmsOutEntity.TOTALNO, WmsOutEntity.REMARK2, strVALIDDATE, WmsOutEntity.MBLNONEW, strCompanyID, WmsOutEntity.ARCLIENTWMSOUT, WmsOutEntity.BZTCHNO, WmsOutEntity.ISCOLLECTING);
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;
WmsOutDetailEntity.CORPID = strCompanyID;
WmsOutDetailEntity.BZTCHNO = WmsOutEntity.BZTCHNO;
//
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
ls = ls.Replace("", " ");
ls = ls.Replace("", "\r\n");
//
//修改入库单wms_in
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='{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;
}
//
string strSTARTBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "STARTBILLINGDATE='" + WmsOutDetailEntity.STARTBILLINGDATE.ToString() + "',";
string strENDBILLINGDATE = WmsOutDetailEntity.STARTBILLINGDATE.ToString().IndexOf("0001") > -1 ? "" : "ENDBILLINGDATE='" + WmsOutEntity.OLDCUSTFEEDATE.ToString() + "',";//如果开始计费日期为空,则结束计费日期也为空,否则为上家承担仓储期限。
string strSTARTBILLINGDATEAP = WmsOutDetailEntity.STARTBILLINGDATEAP.ToString().IndexOf("0001") > -1 ? "" : "STARTBILLINGDATEAP='" + WmsOutDetailEntity.STARTBILLINGDATEAP.ToString() + "',";
string strENDBILLINGDATEAP = WmsOutDetailEntity.STARTBILLINGDATEAP.ToString().IndexOf("0001") > -1 ? "" : "ENDBILLINGDATEAP='" + WmsOutDetailEntity.DODATE.ToString() + "',";//如果开始计费日期为空,则结束计费日期也为空,否则为出库日期。
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}',{24}{25}FEEDAYSAP='{26}',CORPID='{27}',MARKETVALUE={28},AREANAME='{29}',BZTCHNO='{30}' 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, strSTARTBILLINGDATEAP, strENDBILLINGDATEAP, WmsOutDetailEntity.FEEDAYSAP, strCompanyID, WmsOutDetailEntity.MARKETVALUE, WmsOutDetailEntity.AREANAME, WmsOutDetailEntity.BZTCHNO);
//
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_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
#region 货权转移
/// <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.CORPID = strCompanyID;
WmsOutEntity.REMARK = "货权转移" + (WmsOutEntity.REMARK.ToString().Trim() == "" ? "" : "" + WmsOutEntity.REMARK.ToString().Trim());
//
string strVALIDDATE = WmsOutEntity.VALIDDATE.ToString().Trim().IndexOf("0001") > -1 ? "" : ",'" + WmsOutEntity.VALIDDATE.ToString() + "'";
string strVALIDDATE_name = WmsOutEntity.VALIDDATE.ToString().Trim().IndexOf("0001") > -1 ? "" : ",VALIDDATE";
//
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,CLIENTBSNO,TOTALNO,REMARK2{23},CHARGEUNIT,MBLNONEW,ISCHANGE,CORPID,ARCLIENTWMSOUT,BZTCHNO,ISCOLLECTING)"
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}',getdate(),'{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}'{24},'{27}','{25}','{26}','{28}','{29}','{30}','{31}')"
, 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.CLIENTBSNO, WmsOutEntity.TOTALNO, WmsOutEntity.REMARK2, strVALIDDATE_name, strVALIDDATE, WmsOutEntity.MBLNONEW, WmsOutEntity.ISCHANGE, WmsOutEntity.CHARGEUNIT, strCompanyID, WmsOutEntity.ARCLIENTWMSOUT, WmsOutEntity.BZTCHNO, WmsOutEntity.ISCOLLECTING);
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
//
#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.CORPID = strCompanyID;
WmsOutDetailEntity.BZTCHNO = WmsOutEntity.BZTCHNO;
//
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
ls = ls.Replace("", " ");
ls = ls.Replace("", "\r\n");
WmsOutDetailEntity.ISCHANGE = true;
//
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,CHARGEUNIT,FEEDAYSAP,ISCHANGE,CORPID,MARKETVALUE,AREANAME,BZTCHNO) "
+ " 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}','{29}','{27}','{28}','{30}',{31},'{32}','{33}')"
, 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.FEEDAYSAP, WmsOutEntity.ISCHANGE, WmsOutDetailEntity.CHARGEUNIT, strCompanyID, WmsOutDetailEntity.MARKETVALUE, WmsOutDetailEntity.AREANAME, WmsOutDetailEntity.BZTCHNO);
//
WmsOutEntity.GOODSSTANDARD = WmsOutDetailEntity.GOODSSTANDARD;
//
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 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;
}
}// 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},GOODSSTANDARD='{3}' where GID='{1}'", WmsOutEntity.GOODSOUTFEE, WmsOutEntity.GID, WmsOutEntity.GOODSOUTFEEAP, WmsOutEntity.GOODSSTANDARD);
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_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,GOODSPACKACTUAL,GOODSRKSLACTUAL,TRUCKNAME,FREESTORAGEPERIODAP,STARTBILLINGDATEAP,CORPID,AREANAME,BANKVALUE,MARKETVALUE,BZTCHNO,CREATEUSER,CREATETIME from wms 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.GOODSPACKACTUAL = sqlRead.GetDecimal(28); }
if (!sqlRead.IsDBNull(29)) { WmsEntity.GOODSRKSLACTUAL = sqlRead.GetDecimal(29); }
if (!sqlRead.IsDBNull(30)) { WmsEntity.TRUCKNAME = sqlRead.GetString(30); }
if (!sqlRead.IsDBNull(31)) { WmsEntity.FREESTORAGEPERIODAP = sqlRead.GetInt32(31); } //
if (!sqlRead.IsDBNull(32)) { WmsEntity.STARTBILLINGDATEAP = sqlRead.GetDateTime(32); }
if (!sqlRead.IsDBNull(33)) { WmsEntity.CORPID = sqlRead.GetString(33); }
if (!sqlRead.IsDBNull(34)) { WmsEntity.AREANAME = sqlRead.GetString(34); }
if (!sqlRead.IsDBNull(35)) { WmsEntity.BANKVALUE = sqlRead.GetDecimal(35); }
if (!sqlRead.IsDBNull(36)) { WmsEntity.MARKETVALUE = sqlRead.GetDecimal(36); }
if (!sqlRead.IsDBNull(37)) { WmsEntity.BZTCHNO = sqlRead.GetString(37); }
if (!sqlRead.IsDBNull(38)) { WmsEntity.CREATEUSER = sqlRead.GetString(38); }
if (!sqlRead.IsDBNull(39)) { WmsEntity.CREATETIME = sqlRead.GetDateTime(39); }
}
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,AssociatedNO,BSNO,CLIENTGID,CLIENTCODE,CUSTOMERNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,GOODSPFSL,GOODSOUTFEE,REMARK,ISDELETE,DELETETIME,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,GOODSPACKPFSL,GOODSOUTFEEAP,TRUCKNAME,ARCLIENT,CUSTOMNO,MBLNONEW,CORPID,ARCLIENTWMSOUT,BZTCHNO 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();
}
if (sqlRead1["ASSOCIATEDNO"] != null && sqlRead1["ASSOCIATEDNO"].ToString() != "")
{
model.ASSOCIATEDNO = sqlRead1["ASSOCIATEDNO"].ToString();
}
if (sqlRead1["BSNO"] != null && sqlRead1["BSNO"].ToString() != "")
{
model.BSNO = sqlRead1["BSNO"].ToString();
}
if (sqlRead1["CLIENTGID"] != null && sqlRead1["CLIENTGID"].ToString() != "")
{
model.CLIENTGID = sqlRead1["CLIENTGID"].ToString();
}
if (sqlRead1["CLIENTCODE"] != null && sqlRead1["CLIENTCODE"].ToString() != "")
{
model.CLIENTCODE = sqlRead1["CLIENTCODE"].ToString();
}
if (sqlRead1["CUSTOMERNAME"] != null && sqlRead1["CUSTOMERNAME"].ToString() != "")
{
model.CUSTOMERNAME = sqlRead1["CUSTOMERNAME"].ToString();
}
if (sqlRead1["DODATE"] != null && sqlRead1["DODATE"].ToString() != "")
{
model.DODATE = DateTime.Parse(sqlRead1["DODATE"].ToString());
}
if (sqlRead1["STORAGECODE"] != null && sqlRead1["STORAGECODE"].ToString() != "")
{
model.STORAGECODE = sqlRead1["STORAGECODE"].ToString();
}
if (sqlRead1["STORAGENAME"] != null && sqlRead1["STORAGENAME"].ToString() != "")
{
model.STORAGENAME = sqlRead1["STORAGENAME"].ToString();
}
if (sqlRead1["AREACODE"] != null && sqlRead1["AREACODE"].ToString() != "")
{
model.AREACODE = sqlRead1["AREACODE"].ToString();
}
if (sqlRead1["AREANAME"] != null && sqlRead1["AREANAME"].ToString() != "")
{
model.AREANAME = sqlRead1["AREANAME"].ToString();
}
if (sqlRead1["GOODSCODE"] != null && sqlRead1["GOODSCODE"].ToString() != "")
{
model.GOODSCODE = sqlRead1["GOODSCODE"].ToString();
}
if (sqlRead1["GOODSNAME"] != null && sqlRead1["GOODSNAME"].ToString() != "")
{
model.GOODSNAME = sqlRead1["GOODSNAME"].ToString();
}
if (sqlRead1["GOODSTYPE"] != null && sqlRead1["GOODSTYPE"].ToString() != "")
{
model.GOODSTYPE = sqlRead1["GOODSTYPE"].ToString();
}
if (sqlRead1["GOODSMODEL"] != null && sqlRead1["GOODSMODEL"].ToString() != "")
{
model.GOODSMODEL = sqlRead1["GOODSMODEL"].ToString();
}
if (sqlRead1["GOODSSTANDARD"] != null && sqlRead1["GOODSSTANDARD"].ToString() != "")
{
model.GOODSSTANDARD = sqlRead1["GOODSSTANDARD"].ToString();
}
if (sqlRead1["GOODSPACK"] != null && sqlRead1["GOODSPACK"].ToString() != "")
{
model.GOODSPACK = sqlRead1["GOODSPACK"].ToString();
}
if (sqlRead1["GOODSPFSL"] != null && sqlRead1["GOODSPFSL"].ToString() != "")
{
model.GOODSPFSL = decimal.Parse(sqlRead1["GOODSPFSL"].ToString());
}
if (sqlRead1["GOODSOUTFEE"] != null && sqlRead1["GOODSOUTFEE"].ToString() != "")
{
model.GOODSOUTFEE = decimal.Parse(sqlRead1["GOODSOUTFEE"].ToString());
}
if (sqlRead1["REMARK"] != null && sqlRead1["REMARK"].ToString() != "")
{
model.REMARK = sqlRead1["REMARK"].ToString();
}
if (sqlRead1["ISDELETE"] != null && sqlRead1["ISDELETE"].ToString() != "")
{
if ((sqlRead1["ISDELETE"].ToString() == "1") || (sqlRead1["ISDELETE"].ToString().ToLower() == "true"))
{
model.ISDELETE = true;
}
else
{
model.ISDELETE = false;
}
}
if (sqlRead1["DELETETIME"] != null && sqlRead1["DELETETIME"].ToString() != "")
{
model.DELETETIME = DateTime.Parse(sqlRead1["DELETETIME"].ToString());
}
if (sqlRead1["DELETEUSER"] != null && sqlRead1["DELETEUSER"].ToString() != "")
{
model.DELETEUSER = sqlRead1["DELETEUSER"].ToString();
}
if (sqlRead1["CREATEUSER"] != null && sqlRead1["CREATEUSER"].ToString() != "")
{
model.CREATEUSER = sqlRead1["CREATEUSER"].ToString();
}
if (sqlRead1["CREATETIME"] != null && sqlRead1["CREATETIME"].ToString() != "")
{
model.CREATETIME = DateTime.Parse(sqlRead1["CREATETIME"].ToString());
}
if (sqlRead1["MODIFIEDUSER"] != null && sqlRead1["MODIFIEDUSER"].ToString() != "")
{
model.MODIFIEDUSER = sqlRead1["MODIFIEDUSER"].ToString();
}
if (sqlRead1["MODIFIEDTIME"] != null && sqlRead1["MODIFIEDTIME"].ToString() != "")
{
model.MODIFIEDTIME = DateTime.Parse(sqlRead1["MODIFIEDTIME"].ToString());
}
if (sqlRead1["GOODSPACKPFSL"] != null && sqlRead1["GOODSPACKPFSL"].ToString() != "")
{
model.GOODSPACKPFSL = decimal.Parse(sqlRead1["GOODSPACKPFSL"].ToString());
}
if (sqlRead1["GOODSOUTFEEAP"] != null && sqlRead1["GOODSOUTFEEAP"].ToString() != "")
{
model.GOODSOUTFEEAP = decimal.Parse(sqlRead1["GOODSOUTFEEAP"].ToString());
}
if (sqlRead1["TRUCKNAME"] != null && sqlRead1["TRUCKNAME"].ToString() != "")
{
model.TRUCKNAME = sqlRead1["TRUCKNAME"].ToString();
}
if (sqlRead1["ARCLIENT"] != null && sqlRead1["ARCLIENT"].ToString() != "")
{
model.ARCLIENT = sqlRead1["ARCLIENT"].ToString();
}
if (sqlRead1["CUSTOMNO"] != null && sqlRead1["CUSTOMNO"].ToString() != "")
{
model.CUSTOMNO = sqlRead1["CUSTOMNO"].ToString();
}
if (sqlRead1["MBLNONEW"] != null && sqlRead1["MBLNONEW"].ToString() != "")
{
model.MBLNONEW = sqlRead1["MBLNONEW"].ToString();
}
if (sqlRead1["CORPID"] != null && sqlRead1["CORPID"].ToString() != "")
{
model.CORPID = sqlRead1["CORPID"].ToString();
}
if (sqlRead1["ARCLIENTWMSOUT"] != null && sqlRead1["ARCLIENTWMSOUT"].ToString() != "")
{
model.ARCLIENTWMSOUT = sqlRead1["ARCLIENTWMSOUT"].ToString();
}
if (sqlRead1["BZTCHNO"] != null && sqlRead1["BZTCHNO"].ToString() != "")
{
model.BZTCHNO = sqlRead1["BZTCHNO"].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.CREATEUSER = strUserID;
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.CORPID = strCompanyID;
WmsEntity.BZTCHNO = model.BZTCHNO;
//
string sMBLNONEW = this.h_mblnonew.Value.Trim() == "" ? model.MBLNONEW.ToString().Trim() : this.h_mblnonew.Value.Trim();
WmsEntity.BLNO = sMBLNONEW;
WmsEntity.ASSOCIATEDNO = T_ALL_DA.GetStrSQL("bsno", "select top 1 bsno from op_seai where mblno='" + sMBLNONEW + "'");
WmsEntity.CUSTNO = T_ALL_DA.GetStrSQL("CUSTNO", "select top 1 CUSTNO from op_seai where mblno='" + sMBLNONEW + "'");
WmsEntity.ISCHANGE = true;
//
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) ,
new SqlParameter("@GOODSPACKSTOCK", SqlDbType.Decimal) ,
new SqlParameter("@GOODSRKSL", SqlDbType.Decimal) ,
new SqlParameter("@GOODSSTOCK", SqlDbType.Decimal) ,
new SqlParameter("@ARFEE", SqlDbType.Decimal) ,
new SqlParameter("@APFEE", SqlDbType.Decimal) ,
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("@GOODSPACKACTUAL",SqlDbType.Decimal) ,
new SqlParameter("@GOODSRKSLACTUAL",SqlDbType.Decimal) ,
new SqlParameter("@CUSTNO", SqlDbType.VarChar,30) ,
new SqlParameter("@ARCLIENT", SqlDbType.VarChar,20) ,
new SqlParameter("@FREESTORAGEPERIODAP", SqlDbType.Int,4) ,
new SqlParameter("@STARTBILLINGDATEAP", SqlDbType.DateTime) ,
new SqlParameter("@ISCHANGE", SqlDbType.Bit) ,
new SqlParameter("@CORPID", SqlDbType.VarChar,36) ,
new SqlParameter("@AREANAME",SqlDbType.VarChar,100) ,
new SqlParameter("@BANKVALUE", SqlDbType.Decimal) ,
new SqlParameter("@MARKETVALUE", SqlDbType.Decimal) ,
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.GOODSPACKACTUAL;//
parameters[29].Value = WmsEntity.GOODSRKSLACTUAL;//
parameters[30].Value = WmsEntity.CUSTNO;//
parameters[31].Value = WmsEntity.ARCLIENT;//
parameters[32].Value = WmsEntity.FREESTORAGEPERIODAP;
parameters[33].Value = WmsEntity.STARTBILLINGDATEAP;
parameters[34].Value = WmsEntity.ISCHANGE;
parameters[35].Value = WmsEntity.CORPID;
parameters[36].Value = WmsEntity.AREANAME;
parameters[37].Value = WmsEntity.BANKVALUE;
parameters[38].Value = WmsEntity.MARKETVALUE;
parameters[39].Value = WmsEntity.BZTCHNO;
parameters[40].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,GOODSPACKACTUAL,GOODSRKSLACTUAL,CUSTNO,ARCLIENT,FREESTORAGEPERIODAP,STARTBILLINGDATEAP,ISCHANGE,CORPID,AREANAME,BANKVALUE,MARKETVALUE,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,@GOODSPACKACTUAL,@GOODSRKSLACTUAL,@CUSTNO,@ARCLIENT,@FREESTORAGEPERIODAP,@STARTBILLINGDATEAP,@ISCHANGE,@CORPID,@AREANAME,@BANKVALUE,@MARKETVALUE,@BZTCHNO,@CREATEUSER,getdate())";
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSql, parameters);
if (iState != 1)
{
sqlTran.Rollback();
result = -9;
Clearh();
return result;
}
#endregion
//
#region 插入入库明细表
//
//插入入库明细表
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,CORPID,MARKETVALUE,BANKVALUE,LINENUM from wms_in where ASSOCIATEDNO in (select gid from wms 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.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.CORPID = sqlRead.GetString(42); }//
if (!sqlRead.IsDBNull(43)) { WmsInEntity.MARKETVALUE = sqlRead.GetDecimal(43); }//
if (!sqlRead.IsDBNull(44)) { WmsInEntity.BANKVALUE = sqlRead.GetDecimal(44); }//
if (!sqlRead.IsDBNull(45)) { WmsInEntity.LINENUM = sqlRead.GetInt32(45); }//
}
sqlRead.Close();
sqlRead.Dispose();
#endregion
WmsInEntity.GID = Guid.NewGuid().ToString();
WmsInEntity.ASSOCIATEDNO = WmsEntity.GID;
WmsInEntity.BLNO = model.MBLNONEW;
//
#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.GOODSRKSLACTUAL = WmsOutDetailEntity.GOODSPFSL;//入库数量
WmsInEntity.GOODSPACK = WmsOutDetailEntity.GOODSPACKPFSL;//件数
WmsInEntity.GOODSPACKSTOCK = WmsOutDetailEntity.GOODSPACKPFSL;//件数
WmsInEntity.GOODSPACKACTUAL = 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("@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("@GOODSPACKACTUAL",SqlDbType.Decimal),
new SqlParameter("@GOODSRKSLACTUAL",SqlDbType.Decimal),
new SqlParameter("@ISCHANGE",SqlDbType.Bit),//
new SqlParameter("@CORPID",SqlDbType.VarChar,36) ,
new SqlParameter("@MARKETVALUE", SqlDbType.Decimal) ,
new SqlParameter("@BANKVALUE", SqlDbType.Decimal)
};
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.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.GOODSPACKACTUAL;//
parms[38].Value = WmsInEntity.GOODSRKSLACTUAL;//
parms[39].Value = WmsInEntity.ISCHANGE;//
parms[40].Value = WmsInEntity.CORPID;//
parms[41].Value = WmsInEntity.MARKETVALUE;
parms[42].Value = WmsInEntity.BANKVALUE;
//
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,LOCKTIME,GOODSPACKACTUAL,GOODSRKSLACTUAL,ISCHANGE,CORPID,MARKETVALUE,BANKVALUE,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,getdate(),@GOODSPACKACTUAL,@GOODSRKSLACTUAL,@ISCHANGE,@CORPID,@MARKETVALUE,@BANKVALUE," + 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='" + 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() + "','0');</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");
//
string strVALIDDATE = WmsOutEntity.VALIDDATE.ToString().Trim().IndexOf("0001") > -1 ? "" : ",VALIDDATE='" + WmsOutEntity.VALIDDATE.ToString() + "'";
//
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}',CLIENTBSNO='{19}',TOTALNO='{20}',REMARK2='{21}'{22},MBLNONEW='{23}',CORPID='{24}',ARCLIENTWMSOUT='{25}',BZTCHNO='{26}',ISCOLLECTING='{27}' 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.CLIENTBSNO, WmsOutEntity.TOTALNO, WmsOutEntity.REMARK2, strVALIDDATE, WmsOutEntity.MBLNONEW, strCompanyID, WmsOutEntity.ARCLIENTWMSOUT, WmsOutEntity.BZTCHNO, WmsOutEntity.ISCOLLECTING);
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;
WmsOutDetailEntity.CORPID = strCompanyID;
//
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='" + WmsOutEntity.OLDCUSTFEEDATE.ToString() + "',";//如果开始计费日期为空,则结束计费日期也为空,否则为上家承担仓储期限。
//
//修改入库单wms_in
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='{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}',FEEDAYSAP='{24}',CORPID='{25}',MARKETVALUE={26},AREANAME='{27}',BZTCHNO='{28}' 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.FEEDAYSAP, strCompanyID, WmsOutDetailEntity.MARKETVALUE, WmsOutDetailEntity.AREANAME, WmsOutDetailEntity.BZTCHNO);
//
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 GID='" + WmsOutEntity.GID.ToString().Trim() + "'";// ISLOCK=0 and
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_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 时,判断是否是更改结束计费日期的操作
//更改结束计费日期
if (this.h_isOldCustFeeDateEnter.Value == "1")
{
#region 提取货权转移的wms_out的数据
WmsOutEntity model = new WmsOutEntity();
StringBuilder strSql = new StringBuilder();
string SQL_SELECT_WMS_OUT_GID = "select top 1 GID,AssociatedNO,BSNO,CLIENTGID,CLIENTCODE,CUSTOMERNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,GOODSPFSL,GOODSOUTFEE,REMARK,ISDELETE,DELETETIME,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,GOODSPACKPFSL,GOODSOUTFEEAP,TRUCKNAME,ARCLIENT,INGIDNEW,CUSTOMNO,MBLNONEW,CORPID,ARCLIENTWMSOUT,BZTCHNO 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();
}
if (sqlRead1["ASSOCIATEDNO"] != null && sqlRead1["ASSOCIATEDNO"].ToString() != "")
{
model.ASSOCIATEDNO = sqlRead1["ASSOCIATEDNO"].ToString();
}
if (sqlRead1["BSNO"] != null && sqlRead1["BSNO"].ToString() != "")
{
model.BSNO = sqlRead1["BSNO"].ToString();
}
if (sqlRead1["CLIENTGID"] != null && sqlRead1["CLIENTGID"].ToString() != "")
{
model.CLIENTGID = sqlRead1["CLIENTGID"].ToString();
}
if (sqlRead1["CLIENTCODE"] != null && sqlRead1["CLIENTCODE"].ToString() != "")
{
model.CLIENTCODE = sqlRead1["CLIENTCODE"].ToString();
}
if (sqlRead1["CUSTOMERNAME"] != null && sqlRead1["CUSTOMERNAME"].ToString() != "")
{
model.CUSTOMERNAME = sqlRead1["CUSTOMERNAME"].ToString();
}
if (sqlRead1["DODATE"] != null && sqlRead1["DODATE"].ToString() != "")
{
model.DODATE = DateTime.Parse(sqlRead1["DODATE"].ToString());
}
if (sqlRead1["STORAGECODE"] != null && sqlRead1["STORAGECODE"].ToString() != "")
{
model.STORAGECODE = sqlRead1["STORAGECODE"].ToString();
}
if (sqlRead1["STORAGENAME"] != null && sqlRead1["STORAGENAME"].ToString() != "")
{
model.STORAGENAME = sqlRead1["STORAGENAME"].ToString();
}
if (sqlRead1["AREACODE"] != null && sqlRead1["AREACODE"].ToString() != "")
{
model.AREACODE = sqlRead1["AREACODE"].ToString();
}
if (sqlRead1["AREANAME"] != null && sqlRead1["AREANAME"].ToString() != "")
{
model.AREANAME = sqlRead1["AREANAME"].ToString();
}
if (sqlRead1["GOODSCODE"] != null && sqlRead1["GOODSCODE"].ToString() != "")
{
model.GOODSCODE = sqlRead1["GOODSCODE"].ToString();
}
if (sqlRead1["GOODSNAME"] != null && sqlRead1["GOODSNAME"].ToString() != "")
{
model.GOODSNAME = sqlRead1["GOODSNAME"].ToString();
}
if (sqlRead1["GOODSTYPE"] != null && sqlRead1["GOODSTYPE"].ToString() != "")
{
model.GOODSTYPE = sqlRead1["GOODSTYPE"].ToString();
}
if (sqlRead1["GOODSMODEL"] != null && sqlRead1["GOODSMODEL"].ToString() != "")
{
model.GOODSMODEL = sqlRead1["GOODSMODEL"].ToString();
}
if (sqlRead1["GOODSSTANDARD"] != null && sqlRead1["GOODSSTANDARD"].ToString() != "")
{
model.GOODSSTANDARD = sqlRead1["GOODSSTANDARD"].ToString();
}
if (sqlRead1["GOODSPACK"] != null && sqlRead1["GOODSPACK"].ToString() != "")
{
model.GOODSPACK = sqlRead1["GOODSPACK"].ToString();
}
if (sqlRead1["GOODSPFSL"] != null && sqlRead1["GOODSPFSL"].ToString() != "")
{
model.GOODSPFSL = decimal.Parse(sqlRead1["GOODSPFSL"].ToString());
}
if (sqlRead1["GOODSOUTFEE"] != null && sqlRead1["GOODSOUTFEE"].ToString() != "")
{
model.GOODSOUTFEE = decimal.Parse(sqlRead1["GOODSOUTFEE"].ToString());
}
if (sqlRead1["REMARK"] != null && sqlRead1["REMARK"].ToString() != "")
{
model.REMARK = sqlRead1["REMARK"].ToString();
}
if (sqlRead1["ISDELETE"] != null && sqlRead1["ISDELETE"].ToString() != "")
{
if ((sqlRead1["ISDELETE"].ToString() == "1") || (sqlRead1["ISDELETE"].ToString().ToLower() == "true"))
{
model.ISDELETE = true;
}
else
{
model.ISDELETE = false;
}
}
if (sqlRead1["DELETETIME"] != null && sqlRead1["DELETETIME"].ToString() != "")
{
model.DELETETIME = DateTime.Parse(sqlRead1["DELETETIME"].ToString());
}
if (sqlRead1["DELETEUSER"] != null && sqlRead1["DELETEUSER"].ToString() != "")
{
model.DELETEUSER = sqlRead1["DELETEUSER"].ToString();
}
if (sqlRead1["CREATEUSER"] != null && sqlRead1["CREATEUSER"].ToString() != "")
{
model.CREATEUSER = sqlRead1["CREATEUSER"].ToString();
}
if (sqlRead1["CREATETIME"] != null && sqlRead1["CREATETIME"].ToString() != "")
{
model.CREATETIME = DateTime.Parse(sqlRead1["CREATETIME"].ToString());
}
if (sqlRead1["MODIFIEDUSER"] != null && sqlRead1["MODIFIEDUSER"].ToString() != "")
{
model.MODIFIEDUSER = sqlRead1["MODIFIEDUSER"].ToString();
}
if (sqlRead1["MODIFIEDTIME"] != null && sqlRead1["MODIFIEDTIME"].ToString() != "")
{
model.MODIFIEDTIME = DateTime.Parse(sqlRead1["MODIFIEDTIME"].ToString());
}
if (sqlRead1["GOODSPACKPFSL"] != null && sqlRead1["GOODSPACKPFSL"].ToString() != "")
{
model.GOODSPACKPFSL = decimal.Parse(sqlRead1["GOODSPACKPFSL"].ToString());
}
if (sqlRead1["GOODSOUTFEEAP"] != null && sqlRead1["GOODSOUTFEEAP"].ToString() != "")
{
model.GOODSOUTFEEAP = decimal.Parse(sqlRead1["GOODSOUTFEEAP"].ToString());
}
if (sqlRead1["TRUCKNAME"] != null && sqlRead1["TRUCKNAME"].ToString() != "")
{
model.TRUCKNAME = sqlRead1["TRUCKNAME"].ToString();
}
if (sqlRead1["ARCLIENT"] != null && sqlRead1["ARCLIENT"].ToString() != "")
{
model.ARCLIENT = sqlRead1["ARCLIENT"].ToString();
}
if (sqlRead1["INGIDNEW"] != null && sqlRead1["INGIDNEW"].ToString() != "")
{
model.INGIDNEW = sqlRead1["INGIDNEW"].ToString();
}
if (sqlRead1["CUSTOMNO"] != null && sqlRead1["CUSTOMNO"].ToString() != "")
{
model.CUSTOMNO = sqlRead1["CUSTOMNO"].ToString();
}
if (sqlRead1["MBLNONEW"] != null && sqlRead1["MBLNONEW"].ToString() != "")
{
model.MBLNONEW = sqlRead1["MBLNONEW"].ToString();
}
if (sqlRead1["CORPID"] != null && sqlRead1["CORPID"].ToString() != "")
{
model.CORPID = sqlRead1["CORPID"].ToString();
}
if (sqlRead1["ARCLIENTWMSOUT"] != null && sqlRead1["ARCLIENTWMSOUT"].ToString() != "")
{
model.ARCLIENTWMSOUT = sqlRead1["ARCLIENTWMSOUT"].ToString();
}
if (sqlRead1["BZTCHNO"] != null && sqlRead1["BZTCHNO"].ToString() != "")
{
model.BZTCHNO = sqlRead1["BZTCHNO"].ToString();
}
}
sqlRead1.Close();
sqlRead1.Dispose();
#endregion
//
#region 提取原入库wms数据
WmsEntity WmsEntity = new WmsEntity();
string strINGIDNEW = model.INGIDNEW.ToString().Trim();//货权转移后的入库wmsgid
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,ARCLIENT,FREESTORAGEPERIODAP,STARTBILLINGDATEAP,CORPID,AREANAME,BANKVALUE,MARKETVALUE,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.ARCLIENT = sqlRead.GetString(28); }//
if (!sqlRead.IsDBNull(29)) { WmsEntity.FREESTORAGEPERIODAP = sqlRead.GetInt32(29); } //
if (!sqlRead.IsDBNull(30)) { WmsEntity.STARTBILLINGDATEAP = sqlRead.GetDateTime(30); } //
if (!sqlRead.IsDBNull(31)) { WmsEntity.CORPID = sqlRead.GetString(31); }//
if (!sqlRead.IsDBNull(32)) { WmsEntity.AREANAME = sqlRead.GetString(32); }
if (!sqlRead.IsDBNull(33)) { WmsEntity.BANKVALUE = sqlRead.GetDecimal(33); }
if (!sqlRead.IsDBNull(34)) { WmsEntity.MARKETVALUE = sqlRead.GetDecimal(34); }
if (!sqlRead.IsDBNull(35)) { WmsEntity.BZTCHNO = sqlRead.GetString(35); }
if (!sqlRead.IsDBNull(36)) { WmsEntity.CREATEUSER = sqlRead.GetString(36); }
if (!sqlRead.IsDBNull(37)) { WmsEntity.CREATETIME = sqlRead.GetDateTime(37); }
}
sqlRead.Close();
sqlRead.Dispose();
#endregion
//
this.h_newcust.Value = WmsEntity.CUSTOMERNAME;
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() + "','" + this.h_isOldCustFeeDateEnter.Value.Trim() + "');</script>");
}
else
{
#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,AssociatedNO,BSNO,CLIENTGID,CLIENTCODE,CUSTOMERNAME,DODATE,STORAGECODE,STORAGENAME,AREACODE,AREANAME,GOODSCODE,GOODSNAME,GOODSTYPE,GOODSMODEL,GOODSSTANDARD,GOODSPACK,GOODSPFSL,GOODSOUTFEE,REMARK,ISDELETE,DELETETIME,DELETEUSER,CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME,GOODSPACKPFSL,GOODSOUTFEEAP,TRUCKNAME,ARCLIENT,INGIDNEW,CUSTOMNO,MBLNONEW,CORPID,ARCLIENTWMSOUT,BZTCHNO 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();
}
if (sqlRead1["ASSOCIATEDNO"] != null && sqlRead1["ASSOCIATEDNO"].ToString() != "")
{
model.ASSOCIATEDNO = sqlRead1["ASSOCIATEDNO"].ToString();
}
if (sqlRead1["BSNO"] != null && sqlRead1["BSNO"].ToString() != "")
{
model.BSNO = sqlRead1["BSNO"].ToString();
}
if (sqlRead1["CLIENTGID"] != null && sqlRead1["CLIENTGID"].ToString() != "")
{
model.CLIENTGID = sqlRead1["CLIENTGID"].ToString();
}
if (sqlRead1["CLIENTCODE"] != null && sqlRead1["CLIENTCODE"].ToString() != "")
{
model.CLIENTCODE = sqlRead1["CLIENTCODE"].ToString();
}
if (sqlRead1["CUSTOMERNAME"] != null && sqlRead1["CUSTOMERNAME"].ToString() != "")
{
model.CUSTOMERNAME = sqlRead1["CUSTOMERNAME"].ToString();
}
if (sqlRead1["DODATE"] != null && sqlRead1["DODATE"].ToString() != "")
{
model.DODATE = DateTime.Parse(sqlRead1["DODATE"].ToString());
}
if (sqlRead1["STORAGECODE"] != null && sqlRead1["STORAGECODE"].ToString() != "")
{
model.STORAGECODE = sqlRead1["STORAGECODE"].ToString();
}
if (sqlRead1["STORAGENAME"] != null && sqlRead1["STORAGENAME"].ToString() != "")
{
model.STORAGENAME = sqlRead1["STORAGENAME"].ToString();
}
if (sqlRead1["AREACODE"] != null && sqlRead1["AREACODE"].ToString() != "")
{
model.AREACODE = sqlRead1["AREACODE"].ToString();
}
if (sqlRead1["AREANAME"] != null && sqlRead1["AREANAME"].ToString() != "")
{
model.AREANAME = sqlRead1["AREANAME"].ToString();
}
if (sqlRead1["GOODSCODE"] != null && sqlRead1["GOODSCODE"].ToString() != "")
{
model.GOODSCODE = sqlRead1["GOODSCODE"].ToString();
}
if (sqlRead1["GOODSNAME"] != null && sqlRead1["GOODSNAME"].ToString() != "")
{
model.GOODSNAME = sqlRead1["GOODSNAME"].ToString();
}
if (sqlRead1["GOODSTYPE"] != null && sqlRead1["GOODSTYPE"].ToString() != "")
{
model.GOODSTYPE = sqlRead1["GOODSTYPE"].ToString();
}
if (sqlRead1["GOODSMODEL"] != null && sqlRead1["GOODSMODEL"].ToString() != "")
{
model.GOODSMODEL = sqlRead1["GOODSMODEL"].ToString();
}
if (sqlRead1["GOODSSTANDARD"] != null && sqlRead1["GOODSSTANDARD"].ToString() != "")
{
model.GOODSSTANDARD = sqlRead1["GOODSSTANDARD"].ToString();
}
if (sqlRead1["GOODSPACK"] != null && sqlRead1["GOODSPACK"].ToString() != "")
{
model.GOODSPACK = sqlRead1["GOODSPACK"].ToString();
}
if (sqlRead1["GOODSPFSL"] != null && sqlRead1["GOODSPFSL"].ToString() != "")
{
model.GOODSPFSL = decimal.Parse(sqlRead1["GOODSPFSL"].ToString());
}
if (sqlRead1["GOODSOUTFEE"] != null && sqlRead1["GOODSOUTFEE"].ToString() != "")
{
model.GOODSOUTFEE = decimal.Parse(sqlRead1["GOODSOUTFEE"].ToString());
}
if (sqlRead1["REMARK"] != null && sqlRead1["REMARK"].ToString() != "")
{
model.REMARK = sqlRead1["REMARK"].ToString();
}
if (sqlRead1["ISDELETE"] != null && sqlRead1["ISDELETE"].ToString() != "")
{
if ((sqlRead1["ISDELETE"].ToString() == "1") || (sqlRead1["ISDELETE"].ToString().ToLower() == "true"))
{
model.ISDELETE = true;
}
else
{
model.ISDELETE = false;
}
}
if (sqlRead1["DELETETIME"] != null && sqlRead1["DELETETIME"].ToString() != "")
{
model.DELETETIME = DateTime.Parse(sqlRead1["DELETETIME"].ToString());
}
if (sqlRead1["DELETEUSER"] != null && sqlRead1["DELETEUSER"].ToString() != "")
{
model.DELETEUSER = sqlRead1["DELETEUSER"].ToString();
}
if (sqlRead1["CREATEUSER"] != null && sqlRead1["CREATEUSER"].ToString() != "")
{
model.CREATEUSER = sqlRead1["CREATEUSER"].ToString();
}
if (sqlRead1["CREATETIME"] != null && sqlRead1["CREATETIME"].ToString() != "")
{
model.CREATETIME = DateTime.Parse(sqlRead1["CREATETIME"].ToString());
}
if (sqlRead1["MODIFIEDUSER"] != null && sqlRead1["MODIFIEDUSER"].ToString() != "")
{
model.MODIFIEDUSER = sqlRead1["MODIFIEDUSER"].ToString();
}
if (sqlRead1["MODIFIEDTIME"] != null && sqlRead1["MODIFIEDTIME"].ToString() != "")
{
model.MODIFIEDTIME = DateTime.Parse(sqlRead1["MODIFIEDTIME"].ToString());
}
if (sqlRead1["GOODSPACKPFSL"] != null && sqlRead1["GOODSPACKPFSL"].ToString() != "")
{
model.GOODSPACKPFSL = decimal.Parse(sqlRead1["GOODSPACKPFSL"].ToString());
}
if (sqlRead1["GOODSOUTFEEAP"] != null && sqlRead1["GOODSOUTFEEAP"].ToString() != "")
{
model.GOODSOUTFEEAP = decimal.Parse(sqlRead1["GOODSOUTFEEAP"].ToString());
}
if (sqlRead1["TRUCKNAME"] != null && sqlRead1["TRUCKNAME"].ToString() != "")
{
model.TRUCKNAME = sqlRead1["TRUCKNAME"].ToString();
}
if (sqlRead1["ARCLIENT"] != null && sqlRead1["ARCLIENT"].ToString() != "")
{
model.ARCLIENT = sqlRead1["ARCLIENT"].ToString();
}
if (sqlRead1["INGIDNEW"] != null && sqlRead1["INGIDNEW"].ToString() != "")
{
model.INGIDNEW = sqlRead1["INGIDNEW"].ToString();
}
if (sqlRead1["CUSTOMNO"] != null && sqlRead1["CUSTOMNO"].ToString() != "")
{
model.CUSTOMNO = sqlRead1["CUSTOMNO"].ToString();
}
if (sqlRead1["MBLNONEW"] != null && sqlRead1["MBLNONEW"].ToString() != "")
{
model.MBLNONEW = sqlRead1["MBLNONEW"].ToString();
}
if (sqlRead1["CORPID"] != null && sqlRead1["CORPID"].ToString() != "")
{
model.CORPID = sqlRead1["CORPID"].ToString();
}
if (sqlRead1["ARCLIENTWMSOUT"] != null && sqlRead1["ARCLIENTWMSOUT"].ToString() != "")
{
model.ARCLIENTWMSOUT = sqlRead1["ARCLIENTWMSOUT"].ToString();
}
if (sqlRead1["BZTCHNO"] != null && sqlRead1["BZTCHNO"].ToString() != "")
{
model.BZTCHNO = sqlRead1["BZTCHNO"].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,ARCLIENT,FREESTORAGEPERIODAP,STARTBILLINGDATEAP,CORPID,AREANAME,BANKVALUE,MARKETVALUE,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.ARCLIENT = sqlRead.GetString(28); }//
if (!sqlRead.IsDBNull(29)) { WmsEntity.FREESTORAGEPERIODAP = sqlRead.GetInt32(29); } //
if (!sqlRead.IsDBNull(30)) { WmsEntity.STARTBILLINGDATEAP = sqlRead.GetDateTime(30); } //
if (!sqlRead.IsDBNull(31)) { WmsEntity.CORPID = sqlRead.GetString(31); }//
if (!sqlRead.IsDBNull(32)) { WmsEntity.AREANAME = sqlRead.GetString(32); }
if (!sqlRead.IsDBNull(33)) { WmsEntity.BANKVALUE = sqlRead.GetDecimal(33); }
if (!sqlRead.IsDBNull(34)) { WmsEntity.MARKETVALUE = sqlRead.GetDecimal(34); }
if (!sqlRead.IsDBNull(35)) { WmsEntity.BZTCHNO = sqlRead.GetString(35); }
if (!sqlRead.IsDBNull(36)) { WmsEntity.CREATEUSER = sqlRead.GetString(36); }
if (!sqlRead.IsDBNull(37)) { WmsEntity.CREATETIME = sqlRead.GetDateTime(37); }
}
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;
WmsEntity.CUSTOMNO = model.CUSTOMNO;
WmsEntity.BZTCHNO = model.BZTCHNO;
//
string sMBLNONEW = this.h_mblnonew.Value.Trim() == "" ? model.MBLNONEW.ToString().Trim() : this.h_mblnonew.Value.Trim();
WmsEntity.BLNO = sMBLNONEW;
WmsEntity.ASSOCIATEDNO = T_ALL_DA.GetStrSQL("bsno", "select top 1 bsno from op_seai where mblno='" + sMBLNONEW + "'");
WmsEntity.CUSTNO = T_ALL_DA.GetStrSQL("CUSTNO", "select top 1 CUSTNO from op_seai where mblno='" + sMBLNONEW + "'");
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("@GOODSPACK", SqlDbType.Decimal) ,
new SqlParameter("@GOODSPACKSTOCK", SqlDbType.Decimal) ,
new SqlParameter("@GOODSRKSL", SqlDbType.Decimal) ,
new SqlParameter("@GOODSSTOCK", SqlDbType.Decimal) ,
new SqlParameter("@ARFEE", SqlDbType.Decimal) ,
new SqlParameter("@APFEE", SqlDbType.Decimal) ,
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("@CORPID", SqlDbType.VarChar,36) ,
new SqlParameter("@AREANAME",SqlDbType.VarChar,100) ,
new SqlParameter("@BANKVALUE", SqlDbType.Decimal) ,
new SqlParameter("@MARKETVALUE", SqlDbType.Decimal),
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.ISLOCK;
//parameters[24].Value = WmsEntity.LOCKUSER;
parameters[23].Value = WmsEntity.STARTBILLINGDATE;
parameters[24].Value = WmsEntity.CUSTOMNO;
parameters[25].Value = WmsEntity.CUSTNO;
parameters[26].Value = WmsEntity.CORPID;
parameters[27].Value = WmsEntity.AREANAME;
parameters[28].Value = WmsEntity.BANKVALUE;
parameters[29].Value = WmsEntity.MARKETVALUE;
parameters[30].Value = WmsEntity.BZTCHNO;
//parameters[28].Value = WmsEntity.FREESTORAGEPERIODAP;
//parameters[29].Value = WmsEntity.STARTBILLINGDATEAP;
string lsSql = "update wms set WMSNO=@WMSNO,WMSDATE=@WMSDATE,CUSTOMERNAME=@CUSTOMERNAME,WMSOP=@WMSOP,STOREMAN=@STOREMAN,MODIFIEDUSER=@MODIFIEDUSER,MODIFIEDTIME=getdate(),ISDELETE=0,DELETEUSER='',DELETETIME=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,CORPID=@CORPID,AREANAME = @AREANAME,BANKVALUE = @BANKVALUE,MARKETVALUE = @MARKETVALUE,BZTCHNO = @BZTCHNO where GID=@GID ";//,ISLOCK=@ISLOCK,LOCKUSER=@LOCKUSER,LOCKTIME=getdate(),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;
}
//插入入库明细表
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,CORPID,MARKETVALUE,BANKVALUE,LINENUM from wms_in where ASSOCIATEDNO in (select gid from wms 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.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.CORPID = sqlRead.GetString(42); }//
if (!sqlRead.IsDBNull(43)) { WmsInEntity.MARKETVALUE = sqlRead.GetDecimal(43); }//
if (!sqlRead.IsDBNull(44)) { WmsInEntity.BANKVALUE = sqlRead.GetDecimal(44); }//
if (!sqlRead.IsDBNull(45)) { WmsInEntity.LINENUM = sqlRead.GetInt32(45); }//
}
sqlRead.Close();
sqlRead.Dispose();
#endregion
WmsInEntity.GID = Guid.NewGuid().ToString();
WmsInEntity.ASSOCIATEDNO = WmsEntity.GID;
WmsInEntity.BLNO = model.MBLNONEW;
//
#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 = "";
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 = WmsEntity.ISLOCK;// true;
WmsInEntity.LOCKUSER = WmsEntity.LOCKUSER;
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("@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("@CORPID",SqlDbType.VarChar,36),
new SqlParameter("@MARKETVALUE", SqlDbType.Decimal) ,
new SqlParameter("@BANKVALUE", SqlDbType.Decimal)
};
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.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.CORPID;//
parms[38].Value = WmsInEntity.MARKETVALUE;
parms[39].Value = WmsInEntity.BANKVALUE;
//
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,LOCKTIME,CORPID,MARKETVALUE,BANKVALUE,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,getdate(),@CORPID,@MARKETVALUE,@BANKVALUE," + 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() + "','0');</script>");
}
#endregion
}
catch (Exception execError)
{
result = -1;//有异常,插入失败
sqlTran.Rollback();
result = -2;//插入异常,事务已回滚成功
Clearh();
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return result;
}
#endregion
#region 将页面post获取的出库信息读入到实体类中
/// <summary>
/// 将页面post获取的出库信息读入到实体类中
/// </summary>
/// <param name="tempJSON"></param>
/// <param name="tempFeeEntities"></param>
/// <returns>将页面post获取的出库信息读入到实体类中</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("\"", ""));
WmsOutEntity.CUSTOMERNAME = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
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());
WmsOutEntity.GOODSNAME = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
h_goods.Value = WmsOutEntity.GOODSNAME;
break;
case "goodsmodel":
//WmsOutEntity.GOODSMODEL = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
WmsOutEntity.GOODSMODEL = unicode.GetString(unicode.GetBytes(Regex.Unescape(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 "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 "validdate":
WmsOutEntity.VALIDDATE = DateTime.Parse(strArg[1].ToString().Replace("\"", "").Trim() == "" ? "0001-01-01 00:00:00" : strArg[1].ToString().Replace("\"", "").Trim());
this.txt_inspectionno.Value = strArg[1].ToString().Replace("\"", "").Trim();
break;
case "remark2":
//WmsOutEntity.REMARK2 = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
WmsOutEntity.REMARK2 = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
this.txt_inspectionno.Value = WmsOutEntity.REMARK2;
break;
case "totalno":
//WmsOutEntity.TOTALNO = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
WmsOutEntity.TOTALNO = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
this.txt_totalno.Value = WmsOutEntity.TOTALNO;
break;
case "clientbsno":
WmsOutEntity.CLIENTBSNO = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
this.txt_clientbsno.Value = WmsOutEntity.CLIENTBSNO;
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());
WmsOutEntity.STORAGENAME = unicode.GetString(unicode.GetBytes(Regex.Unescape(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 "arclientwmsout"://应收
WmsOutEntity.ARCLIENTWMSOUT = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
hd_comboARCLIENTWMSOUT.Value = WmsOutEntity.ARCLIENTWMSOUT;
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_associatedno.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;
case "mblnonew":
//string ls = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
string ls = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", ""))));
ls = ls.Replace("·","/");
this.h_mblnonew.Value = ls;
WmsOutEntity.MBLNONEW = this.h_mblnonew.Value.Trim();
break;
case "chargeunit":
WmsOutEntity.CHARGEUNIT = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", ""))));
break;
case "bztchno":
WmsOutEntity.BZTCHNO = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", ""))));
break;
case "iscollecting":
WmsOutEntity.ISCOLLECTING = Boolean.Parse(strArg[1].ToString().Replace("\"", ""));
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获取的出库明细信息读入到实体类中
/// <summary>
/// 将页面post获取的出库明细信息读入到实体类中
/// </summary>
/// <param name="tempJSON"></param>
/// <param name="tempFeeEntities"></param>
/// <returns>将页面post获取的出库信息读入到实体类中</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("\"", ""));
WmsOutDetailEntity.CUSTOMERNAME = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
break;
case "outcus":
WmsOutDetailEntity.CLIENTNAMEOLD = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
break;
case "inbsno":
WmsOutDetailEntity.INBSNO =strArg[1].ToString().Replace("\"", "");
WmsOutDetailEntity.GOODSSTANDARD = T_ALL_DA.GetStrSQL("GOODSSTANDARD", "select top 1 GOODSSTANDARD from wms where gid='" + WmsOutDetailEntity.INBSNO.ToString() + "'");
WmsOutDetailEntity.BZTCHNO = T_ALL_DA.GetStrSQL("BZTCHNO", "select top 1 BZTCHNO from wms where gid='" + WmsOutDetailEntity.INBSNO.ToString() + "'");
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());
WmsOutDetailEntity.GOODSNAME = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
break;
case "goodsmodel":
//WmsOutDetailEntity.GOODSMODEL = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
WmsOutDetailEntity.GOODSMODEL = unicode.GetString(unicode.GetBytes(Regex.Unescape(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("\"", ""));//应收开始计费日期
if (this.h_isUpdateSTARTBILLINGDATE.Value.Trim() == "1" && WmsOutDetailEntity.INBSNO.ToString().Trim() != "")
{
WmsOutDetailEntity.STARTBILLINGDATE = DateTime.Parse(T_ALL_DA.GetStrSQL("STARTBILLINGDATE", "select top 1 convert(char(10),STARTBILLINGDATE,120) as STARTBILLINGDATE from wms where gid='" + WmsOutDetailEntity.INBSNO.ToString().Trim() + "'"));
}
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 "chargeunit":
WmsOutDetailEntity.CHARGEUNIT = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", ""))));
break;
case "marketvalue":
WmsOutDetailEntity.MARKETVALUE = strArg[1].ToString().Replace("\"", "").ToString().Trim() == "" ? 0 : decimal.Parse(strArg[1].ToString().Replace("\"", "").ToString());
break;
case "areaname":
//WmsOutDetailEntity.AREANAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
WmsOutDetailEntity.AREANAME = unicode.GetString(unicode.GetBytes(Regex.Unescape(strArg[1].ToString().Replace("\"", "").Trim())));
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 统计合计数
/// <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,(case when isnull(VALIDDATE,'')='' then '' else convert(char(10),VALIDDATE,20) end) as VALIDDATE2 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 = ds.Tables[0].Rows[0]["DODATE2"].ToString().Trim();
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_remark.Value = ds.Tables[0].Rows[0]["REMARK"].ToString().Trim();
this.txt_remark.Value = this.h_remark.Value.Trim();
this.h_associatedno.Value = ds.Tables[0].Rows[0]["ASSOCIATEDNO"].ToString().Trim();
this.h_opseaibsno.Value = h_associatedno.Value;
this.h_bsno.Value = h_associatedno.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_outcustomer.Value;
this.h_mblnonew.Value = ds.Tables[0].Rows[0]["MBLNONEW"].ToString().Trim();
this.hd_comboARCLIENT.Value = ds.Tables[0].Rows[0]["ARCLIENT"].ToString().Trim();
this.hd_comboARCLIENTWMSOUT.Value = ds.Tables[0].Rows[0]["ARCLIENTWMSOUT"].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_validdate.Value = ds.Tables[0].Rows[0]["VALIDDATE2"].ToString().Trim();
this.txt_remark2.Value = ds.Tables[0].Rows[0]["REMARK2"].ToString().Trim();
this.txt_totalno.Value = ds.Tables[0].Rows[0]["TOTALNO"].ToString().Trim();
this.txt_clientbsno.Value = ds.Tables[0].Rows[0]["CLIENTBSNO"].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();
this.txt_bztchno.Value = ds.Tables[0].Rows[0]["BZTCHNO"].ToString().Trim();
this.cbISCOLLECTING.Checked = Boolean.Parse(ds.Tables[0].Rows[0]["ISCOLLECTING"].ToString().Trim());
}
}
}
#endregion
#region 是否允许改
/// <summary>
/// 是否允许改
/// </summary>
/// <param name="strSearch"></param>
public void setIsDisabled(bool isdisabled, bool ishdRangeO, bool islock)
{
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;
//
//应收仓储客户
ddlARCLIENTWMSOUT.Disabled = isdisabled;
//应收出库客户
ddlARCLIENT.Disabled = isdisabled;
//应付客户
ddlTRUCKNAME.Disabled = isdisabled;
//出库日期
txt_outdate.Disabled = isdisabled;
//结束计费日期
txt_oldcustFeeDate.Disabled = isdisabled;
//转移对象
sel_outcustomer.Disabled = isdisabled;
//转移单号
sel_mblnonew.Disabled = isdisabled;
//备案清单号
txt_customno.Disabled = isdisabled;
//重量
//txt_goodspfsl.Disabled = isdisabled;
//件数
//txt_packnum.Disabled = isdisabled;
//审批单号
txt_inspectionno.Disabled = isdisabled;
//有效期
txt_validdate.Disabled = isdisabled;
//备注2
txt_remark2.Disabled = isdisabled;
//重量大写
txt_totalno.Disabled = isdisabled;
//客户仓单号
txt_clientbsno.Disabled = isdisabled;
//备注
txt_remark.Disabled = isdisabled;
//批次号
txt_bztchno.Disabled = isdisabled;
//是否代收费
this.cbISCOLLECTING.Disabled = isdisabled;
//
if (this.h_Handle.Value.Trim() == "edit")
{
//刷新
divrefresh2.Disabled = isdisabled;
//列表
mygrid_recv_2.Disabled = isdisabled;
//更改结束计费日期
btOldCustFeeDate.Disabled = (!isdisabled);
if (islock == true)
{
btOldCustFeeDate.Disabled = islock;
btUpdateGOODSOUTFEE.Disabled = islock;
}
if (ishdRangeO == true)
{
btOldCustFeeDate.Disabled = isdisabled;
btUpdateGOODSOUTFEE.Disabled = isdisabled;
}
}
}
#endregion
#endregion
#region 仓储操作
#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
#endregion
#region 基本信息
/// <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;
}
private void Clearh()
{
this.h_post_2.Value = "";
this.h_associatedno.Value = "";
this.h_opseaibsno.Value = "";
this.h_bsno.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 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 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 "";
}
#endregion
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
}
}