|
|
|
|
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.WMS_ZX
|
|
|
|
|
{
|
|
|
|
|
public partial class WmsZXOutEdit : System.Web.UI.Page
|
|
|
|
|
{
|
|
|
|
|
private string strUserID;
|
|
|
|
|
private string strCompanyID;//公司GID
|
|
|
|
|
private string strShowName;//用户显示名
|
|
|
|
|
private string strDeptName;//部门名称
|
|
|
|
|
private string strSearch;//仓储费率的客户、合同号、货物名称
|
|
|
|
|
private string WoJSON;//出库明细信息
|
|
|
|
|
private string WoDetailJSON;//出库明细信息
|
|
|
|
|
private string recvJSON;
|
|
|
|
|
private string payJSON;
|
|
|
|
|
private string strSeaBSNO;
|
|
|
|
|
private int iImportTemplateDetailType;
|
|
|
|
|
private string strCacheName;
|
|
|
|
|
private string strImportHistoryCacheName;
|
|
|
|
|
private int iHistoryType;//1-应收 2-应付
|
|
|
|
|
private string strHandle;
|
|
|
|
|
private bool isJsFee = false;
|
|
|
|
|
private IList<string> CustParent=new List<string>();
|
|
|
|
|
T_ALL_DA T_ALL_DA = new T_ALL_DA();
|
|
|
|
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
this.h_wmsoutbsno.Value = "";
|
|
|
|
|
this.h_IsFeeGain.Value = "0";
|
|
|
|
|
//h_Mode.Value = "0";
|
|
|
|
|
this.txt_outdate.Value = DateTime.Today.ToString("yyyy-MM-dd");
|
|
|
|
|
//addwmsout
|
|
|
|
|
if (Session["USERID"] != null)
|
|
|
|
|
{
|
|
|
|
|
strUserID = Session["USERID"].ToString();
|
|
|
|
|
this.hdUserID.Value = strUserID;
|
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
strHandle = Request.QueryString["handle"].ToString();
|
|
|
|
|
if (strHandle.Trim() == "addwmsout")
|
|
|
|
|
{
|
|
|
|
|
btShifting.Disabled = false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
btShifting.Disabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Request.QueryString["search"] != null)
|
|
|
|
|
{
|
|
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
|
|
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
|
|
|
|
|
this.h_EditJson.Value = strSearch;
|
|
|
|
|
}
|
|
|
|
|
if (Request.QueryString["outgid"] != null)
|
|
|
|
|
{
|
|
|
|
|
this.h_outgid.Value = Request.QueryString["outgid"].ToString();
|
|
|
|
|
ViewState["h_outgid"] = this.h_outgid.Value;
|
|
|
|
|
}
|
|
|
|
|
if (Request.QueryString["isenabled"] != null)
|
|
|
|
|
{
|
|
|
|
|
this.hdEnabled.Value = Request.QueryString["isenabled"].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WoJSON = "";
|
|
|
|
|
WoDetailJSON = "";
|
|
|
|
|
WoJSON=this.WoContainer.Value;
|
|
|
|
|
WoDetailJSON = this.WoDetailContainer.Value;
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (this.h_post.Value.Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
if (this.hdShifting.Value.Trim() == "1")//库间移位
|
|
|
|
|
{
|
|
|
|
|
SaveWoOutActionShifting();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SaveWoOutAction();
|
|
|
|
|
}
|
|
|
|
|
//return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (this.h_post.Value.Trim() == "3")
|
|
|
|
|
{
|
|
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
SaveWoOutActionedit();
|
|
|
|
|
//return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (this.h_post.Value.Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
SaveWoOutActioneditadd();
|
|
|
|
|
//return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (strHandle == "edit")
|
|
|
|
|
{//获取出库单的信息
|
|
|
|
|
DoWmsOutEdit(strSearch);
|
|
|
|
|
this.h_Mode.Value = "1";
|
|
|
|
|
ViewState["h_Mode"] = this.h_Mode.Value;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
hd_comboWMSOP.Value = strShowName;
|
|
|
|
|
hd_comboSTOREMAN.Value = strShowName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ViewState["h_Mode"] != null && ViewState["h_outgid"] != null)
|
|
|
|
|
{
|
|
|
|
|
this.h_Mode.Value = ViewState["h_Mode"].ToString().Trim();
|
|
|
|
|
this.h_outgid.Value = ViewState["h_outgid"].ToString().Trim();
|
|
|
|
|
if (ViewState["h_Mode"].ToString().Trim() == "1" || ViewState["h_Mode"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL("select top 1 *,ARFEE1=(select sum(ARFEE) from wms_out_detail where outbsno=wms_out.bsno),APFEE1=(select sum(APFEE) from wms_out_detail where outbsno=wms_out.bsno) from wms_out where gid='" + ViewState["h_outgid"].ToString().Trim() + "'");
|
|
|
|
|
if (ds != null)
|
|
|
|
|
{
|
|
|
|
|
h_customer.Value = ds.Tables[0].Rows[0]["CUSTOMERNAME"].ToString().Trim();
|
|
|
|
|
h_truck.Value = ds.Tables[0].Rows[0]["TRUCKNAME"].ToString().Trim();
|
|
|
|
|
txt_outbsno.Value = ds.Tables[0].Rows[0]["BSNO"].ToString().Trim();
|
|
|
|
|
txt_clientbsno.Value = ds.Tables[0].Rows[0]["CLIENTBSNO"].ToString().Trim();
|
|
|
|
|
txt_outdate.Value = DateTime.Parse(ds.Tables[0].Rows[0]["DODATE"].ToString().Trim()).ToString("yyyy-MM-dd");
|
|
|
|
|
txt_remark.Value = ds.Tables[0].Rows[0]["REMARK"].ToString().Trim();
|
|
|
|
|
hd_comboWMSOP.Value = ds.Tables[0].Rows[0]["WMSOP"].ToString().Trim();
|
|
|
|
|
hd_comboSTOREMAN.Value = ds.Tables[0].Rows[0]["STOREMAN"].ToString().Trim();
|
|
|
|
|
//
|
|
|
|
|
h_customer.Disabled = true;
|
|
|
|
|
h_truck.Disabled = true;
|
|
|
|
|
txt_outbsno.Disabled = true;
|
|
|
|
|
txt_clientbsno.Disabled = true;
|
|
|
|
|
txt_outdate.Disabled = true;
|
|
|
|
|
txt_remark.Disabled = true;
|
|
|
|
|
|
|
|
|
|
//出库件数:</div></td>
|
|
|
|
|
this.dvProfitTotalVal.InnerText = ds.Tables[0].Rows[0]["GOODSPFSL"].ToString().Trim();
|
|
|
|
|
//出库应收:</div></td>
|
|
|
|
|
this.dvRecvTotalVal.InnerText = ds.Tables[0].Rows[0]["ARFEE1"].ToString().Trim();
|
|
|
|
|
//出库应付:</div></td>
|
|
|
|
|
this.dvPaySumVal.InnerText = ds.Tables[0].Rows[0]["APFEE1"].ToString().Trim();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
h_customer.Disabled = false;
|
|
|
|
|
h_truck.Disabled = false;
|
|
|
|
|
txt_outbsno.Disabled = true;
|
|
|
|
|
txt_clientbsno.Disabled = false;
|
|
|
|
|
txt_outdate.Disabled = false;
|
|
|
|
|
txt_remark.Disabled = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (this.hdEnabled.Value.Trim() == "false")
|
|
|
|
|
{
|
|
|
|
|
getEnabled();
|
|
|
|
|
}
|
|
|
|
|
txt_outbsno.Disabled = true;
|
|
|
|
|
//
|
|
|
|
|
//加载下拉框
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>initcomboGoods();initComboWMSOP();initComboSTOREMAN();</script>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void getEnabled()
|
|
|
|
|
{
|
|
|
|
|
divadd.Disabled=true;
|
|
|
|
|
btn_Out.Disabled=true;
|
|
|
|
|
divdel.Disabled=true;
|
|
|
|
|
ibPrint.Disabled=true;
|
|
|
|
|
//txt_outbsno
|
|
|
|
|
//sel_customer
|
|
|
|
|
//sel_truck
|
|
|
|
|
//txt_outdate
|
|
|
|
|
//ddlWMSOP
|
|
|
|
|
//ddlSTOREMAN
|
|
|
|
|
//txt_remark
|
|
|
|
|
//sel_storage
|
|
|
|
|
//sel_goods
|
|
|
|
|
//sel_goodsmodel
|
|
|
|
|
//txt_bsno
|
|
|
|
|
Div2.Disabled=true;
|
|
|
|
|
Div3.Disabled=true;
|
|
|
|
|
mygrid_container_wmsin.Disabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 导出Excel
|
|
|
|
|
protected void btExcel1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
setExcelReport();
|
|
|
|
|
}
|
|
|
|
|
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());
|
|
|
|
|
DataSet DS = T_ALL_DA.GetAllSQL(this.hdSQL.Value.Trim());
|
|
|
|
|
if (DS != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataTable myTable in DS.Tables)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow myRow in myTable.Rows)//遍历表
|
|
|
|
|
{
|
|
|
|
|
sSQL = "";
|
|
|
|
|
for (int i = 0; i < myTable.Columns.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (sSQL.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
sSQL += "\t";
|
|
|
|
|
}
|
|
|
|
|
if (myRow[i].ToString() == null || myRow[i].ToString() == "")
|
|
|
|
|
{
|
|
|
|
|
sSQL += "";
|
|
|
|
|
if (sSQL.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
sSQL += "\t";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string ls = myRow[i].ToString().Trim();
|
|
|
|
|
if (i == 17)
|
|
|
|
|
{
|
|
|
|
|
ls = ls.Replace(" ", ",");
|
|
|
|
|
ls = ls.Replace("\r\n", "。");
|
|
|
|
|
}
|
|
|
|
|
sSQL += ls.Trim();
|
|
|
|
|
//sSQL += myRow[i].ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
sw.WriteLine(sSQL);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
sw.Close();
|
|
|
|
|
switch ("MUEXCEL")
|
|
|
|
|
{
|
|
|
|
|
case "MUEXCEL":
|
|
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xls");
|
|
|
|
|
Response.ContentType = "application/ms-excel";
|
|
|
|
|
break;
|
|
|
|
|
case "MUTEXT":
|
|
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.txt");
|
|
|
|
|
Response.ContentType = "application/txt";
|
|
|
|
|
break;
|
|
|
|
|
case "MUWORD":
|
|
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.doc");
|
|
|
|
|
Response.ContentType = "application/ms-word";
|
|
|
|
|
break;
|
|
|
|
|
case "MUPDF":
|
|
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.pdf");
|
|
|
|
|
Response.ContentType = "application/pdf";
|
|
|
|
|
break;
|
|
|
|
|
case "MUXML":
|
|
|
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=report.xml");
|
|
|
|
|
Response.ContentType = "application/xml";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
|
|
|
|
|
Response.Write(sw);
|
|
|
|
|
Response.End();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 读取出库单的信息 WmsOutEdit
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strSearch"></param>
|
|
|
|
|
private void DoWmsOutEdit(string strSearch)
|
|
|
|
|
{
|
|
|
|
|
if (strSearch != null)
|
|
|
|
|
{
|
|
|
|
|
if (!strSearch.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
string tempSearch = strSearch;
|
|
|
|
|
tempSearch = tempSearch.Replace("{", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("}", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("[", "");
|
|
|
|
|
tempSearch = tempSearch.Replace("]", "");
|
|
|
|
|
|
|
|
|
|
string[] searchArg = tempSearch.Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < searchArg.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
string[] strArg = searchArg[i].Split(new char[] { ':' });
|
|
|
|
|
|
|
|
|
|
if (!strArg[1].Replace("\"", "").Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "id":
|
|
|
|
|
h_outgid.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
break;
|
|
|
|
|
case "bsno":
|
|
|
|
|
this.h_outbsno.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
txt_outbsno.Value = this.h_outbsno.Value;
|
|
|
|
|
this.h_wmsoutbsno.Value = this.h_outbsno.Value;
|
|
|
|
|
break;
|
|
|
|
|
case "txtclientbsno":
|
|
|
|
|
this.h_clientbsno.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
txt_clientbsno.Value = this.h_clientbsno.Value;
|
|
|
|
|
break;
|
|
|
|
|
case "cust":
|
|
|
|
|
h_customer.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
break;
|
|
|
|
|
case "outdate":
|
|
|
|
|
string dt =strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
//h_outdate.Value = dt.Substring(0,dt.IndexOf(" "));
|
|
|
|
|
h_outdate.Value = dt;
|
|
|
|
|
txt_outdate.Value = dt;
|
|
|
|
|
break;
|
|
|
|
|
case "storage":
|
|
|
|
|
h_storage.Value = strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
break;
|
|
|
|
|
case "goodsname":
|
|
|
|
|
h_goods.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "goodsmodel":
|
|
|
|
|
h_goodsmodel.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "outfee":
|
|
|
|
|
h_outfee.Value =strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
break;
|
|
|
|
|
case "truckno":
|
|
|
|
|
//
|
|
|
|
|
string ls = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
//ls = ls.Replace(" ", " ");
|
|
|
|
|
//ls = ls.Replace("\r\n", " ");
|
|
|
|
|
//
|
|
|
|
|
h_truckno.Value = ls;
|
|
|
|
|
break;
|
|
|
|
|
case "remark":
|
|
|
|
|
h_remark.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
txt_remark.Value = h_remark.Value;
|
|
|
|
|
break;
|
|
|
|
|
case "wmsgid":
|
|
|
|
|
h_bsno.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
//hd_wmsgid.Value = h_bsno.Value;
|
|
|
|
|
break;
|
|
|
|
|
case "packnum":
|
|
|
|
|
h_packnum.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
//txt_packnum.Value = h_packnum.Value;
|
|
|
|
|
break;
|
|
|
|
|
case "newcust":
|
|
|
|
|
this.h_newcust.Value = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 将页面post获取的费用信息保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain,并返回操作结果
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将页面post获取的费用信息保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain,并返回操作结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void SaveFeeAction()
|
|
|
|
|
{
|
|
|
|
|
IList<FeeEntity> feeEntities = new List<FeeEntity>();
|
|
|
|
|
|
|
|
|
|
if (!recvJSON.Trim().Equals("") && !recvJSON.Trim().Equals("null") )
|
|
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
|
|
feeEntities = ResolveFeeJSON(recvJSON.Trim(), feeEntities);
|
|
|
|
|
recvContainer.Value = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!payJSON.Trim().Equals("") && !payJSON.Trim().Equals("null"))
|
|
|
|
|
{ //将应付费用信息从前台页面写入费用实体类feeEntities
|
|
|
|
|
feeEntities = ResolveFeeJSON(payJSON.Trim(), feeEntities);
|
|
|
|
|
payContainer.Value = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FeeDA feeDA = new FeeDA();
|
|
|
|
|
//如果是当前操作人权限范围只能查看应收或者应付时,单独更新费用利润
|
|
|
|
|
if (!ValidateUserFeeAuthority(1) || !ValidateUserFeeAuthority(2))
|
|
|
|
|
{ //将页面post获取的费用信息保存或更新“费用信息表”ch_fee,并保存或更新“利润信息”fee_gain,并返回操作结果
|
|
|
|
|
int iRecvState = feeDA.DoFee(feeEntities, strSeaBSNO, strUserID);
|
|
|
|
|
|
|
|
|
|
if (iRecvState == 1)
|
|
|
|
|
{
|
|
|
|
|
gainContainer.Value = "";
|
|
|
|
|
if (Session[strCacheName] != null)
|
|
|
|
|
{
|
|
|
|
|
Session.Remove(strCacheName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
FeeProfitEntity feeProfitEntity = new FeeProfitEntity();
|
|
|
|
|
//将页面post获取的利润值读入到利润实体类中
|
|
|
|
|
feeProfitEntity = GetRequestProfit();
|
|
|
|
|
|
|
|
|
|
int iRecvState = feeDA.DoFee(feeEntities, feeProfitEntity, strSeaBSNO);
|
|
|
|
|
|
|
|
|
|
if (iRecvState == 1)
|
|
|
|
|
{
|
|
|
|
|
gainContainer.Value = "";
|
|
|
|
|
if (Session[strCacheName] != null)
|
|
|
|
|
{
|
|
|
|
|
Session.Remove(strCacheName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
h_post.Value = "";//请求状态清空
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 正数四舍五入,负数是五舍六入。(个人以为第一种方法合适处置货泉盘算)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">四舍五入的数</param>
|
|
|
|
|
/// <param name="decimals">表示要保存的小数点后为数</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private double Round(double value, int decimals,string money)
|
|
|
|
|
{
|
|
|
|
|
if (value < 0)
|
|
|
|
|
{
|
|
|
|
|
return Math.Round(value + 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 double Round(double d, int i)
|
|
|
|
|
{
|
|
|
|
|
if (d >= 0)
|
|
|
|
|
{
|
|
|
|
|
d += 5 * Math.Pow(10, -(i + 1));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
d += -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 = Double.Parse(strd);
|
|
|
|
|
return d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 库间移位 SaveWoOutActionShifting
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 库间移位
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int SaveWoOutActionShifting()
|
|
|
|
|
{
|
|
|
|
|
int iState = 0;
|
|
|
|
|
int result = 0;
|
|
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
|
|
|
|
//double totaloutfee = 0;//出库单的仓储费
|
|
|
|
|
//int prescale = 0;
|
|
|
|
|
//int nowscale = 0;
|
|
|
|
|
//int nowgrade = 0;
|
|
|
|
|
//double price = 0;
|
|
|
|
|
//double gradefee = 0;
|
|
|
|
|
//double 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 = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 生成出库单并计算费用
|
|
|
|
|
//
|
|
|
|
|
string strWMSNO = T_ALL_DA.GetStrSQL("BSNO", "select BSNO from wms_out where BSNO='" + WmsOutEntity.BSNO.ToString().Trim() + "'");
|
|
|
|
|
if (strWMSNO.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert(出库单'" + strWMSNO + "'已经生成,不允许重复生成!);</script>");
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
//保存出库单wms_out
|
|
|
|
|
string ls = WmsOutEntity.TRUCKNO.ToString().Trim();
|
|
|
|
|
ls = ls.Replace("??"," ");
|
|
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
|
|
//
|
|
|
|
|
Sqlstr = String.Format("insert into wms_out(GID,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,REMARK,CREATEUSER,CREATETIME,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,TRUCKNAME,GOODSPFSL,WMSOP,STOREMAN,CLIENTBSNO,CORPID)"
|
|
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',getdate(),'{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}')"
|
|
|
|
|
, WmsOutEntity.GID, WmsOutEntity.BSNO, WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.REMARK, strUserID, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL, WmsOutEntity.TRUCKNAME, WmsOutEntity.GOODSPFSL, hd_comboWMSOP.Value.Trim(), hd_comboSTOREMAN.Value.Trim(), this.h_clientbsno.Value.Trim(), strCompanyID);
|
|
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
this.h_outgid.Value = WmsOutEntity.GID.ToString().Trim();
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -1;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//保存出库单明细wms_out_detail
|
|
|
|
|
#region 保存出库单wms_out 出库单明细wms_out_detail
|
|
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
|
|
{
|
|
|
|
|
WmsOutDetailEntity.OUTBSNO = WmsOutEntity.BSNO;
|
|
|
|
|
//保存wms_out_detail
|
|
|
|
|
newGID = Guid.NewGuid().ToString();
|
|
|
|
|
WmsOutDetailEntity.GID = newGID;
|
|
|
|
|
//
|
|
|
|
|
#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 CREATETIME 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
|
|
|
|
|
//bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
|
|
WmsOutDetailEntity.BSNO = bsno;
|
|
|
|
|
//
|
|
|
|
|
WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
|
|
WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = 0;
|
|
|
|
|
WmsOutDetailEntity.CORPID = strCompanyID;
|
|
|
|
|
//
|
|
|
|
|
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
|
|
|
|
|
ls = ls.Replace("??", " ");
|
|
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
|
|
//
|
|
|
|
|
Sqlstr = String.Format("insert into wms_out_detail(GID,INBSNO,OUTBSNO,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSPFSL,CREATEUSER,CREATETIME,REMARK,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,ARFEE,APFEE,areaname,CHARGEUNIT,CORPID) "
|
|
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
|
|
|
|
|
, WmsOutDetailEntity.GID, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.OUTBSNO, WmsOutDetailEntity.BSNO, WmsOutDetailEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutDetailEntity.STORAGENAME, WmsOutDetailEntity.GOODSNAME, WmsOutDetailEntity.GOODSMODEL, WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.CREATEUSER, WmsOutDetailEntity.REMARK, ls, WmsOutDetailEntity.ASSOCIATEDNO, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.ARFEE, WmsOutDetailEntity.APFEE, WmsOutDetailEntity.AREANAME, WmsOutDetailEntity.CHARGEUNIT, WmsOutDetailEntity.CORPID);
|
|
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -5;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//修改入库单wms_in
|
|
|
|
|
Sqlstr = String.Format("update wms_in set GOODSPACKSTOCK=GOODSPACKSTOCK-{0},GOODSSTOCK=GOODSSTOCK-{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;
|
|
|
|
|
}
|
|
|
|
|
}// end 保存出库明细wms_out_detail
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//修改wms_out的出库量、出库件数、应收应付装卸费
|
|
|
|
|
string lsSQL = String.Format("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='{0}'", WmsOutEntity.GID.ToString().Trim());
|
|
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSQL, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -7;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 将仓储费写入ch_fee
|
|
|
|
|
//if (isJsFee == true)
|
|
|
|
|
//{
|
|
|
|
|
// FeeDA feeDA = new FeeDA();
|
|
|
|
|
// IList<FeeEntity> feeEntities = new List<FeeEntity>();
|
|
|
|
|
// FeeEntity feeEntity = new FeeEntity();
|
|
|
|
|
// double deprice = 0;
|
|
|
|
|
// if (WmsOutEntity.GOODSPFSL != 0)
|
|
|
|
|
// {
|
|
|
|
|
// deprice = double.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;
|
|
|
|
|
// double amount = double.Parse(WmsOutEntity.GOODSPFSL.ToString()) * double.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
|
|
|
|
|
|
|
|
|
|
#region 保存入库单wms
|
|
|
|
|
StringBuilder strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("insert into wms(");
|
|
|
|
|
strSql.Append("GID,WMSNO,WMSDATE,CUSTOMERNAME,WMSOP,STOREMAN,MODIFIEDUSER,MODIFIEDTIME,ISDELETE,DELETEUSER,DELETETIME,TRUCKNAME,CORPID");
|
|
|
|
|
strSql.Append(") values (");
|
|
|
|
|
strSql.Append("@GID,@WMSNO,@WMSDATE,@CUSTOMERNAME,@WMSOP,@STOREMAN,@MODIFIEDUSER,getdate(),0,'',getdate(),@TRUCKNAME,@CORPID");
|
|
|
|
|
strSql.Append(") ");
|
|
|
|
|
|
|
|
|
|
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("@CORPID", SqlDbType.VarChar,36)
|
|
|
|
|
};
|
|
|
|
|
this.hdWMSGID.Value = getWMSNO();
|
|
|
|
|
parameters[0].Value = this.hdWMSGID.Value.Trim();
|
|
|
|
|
string srq = T_ALL_DA.GetStrSQL("rq", "select convert(char(10),getdate(),20) rq");
|
|
|
|
|
string swmsno = getCodeRuleWmsIn("入库单号", "WMSNO", srq);//调用编码规则
|
|
|
|
|
parameters[1].Value = swmsno;
|
|
|
|
|
parameters[2].Value = DateTime.Parse(srq.Trim());
|
|
|
|
|
parameters[3].Value = WmsOutEntity.CUSTOMERNAME;
|
|
|
|
|
parameters[4].Value = hd_comboWMSOP.Value.Trim();
|
|
|
|
|
parameters[5].Value = hd_comboSTOREMAN.Value.Trim();
|
|
|
|
|
parameters[6].Value = strUserID;
|
|
|
|
|
parameters[7].Value = WmsOutEntity.TRUCKNAME;
|
|
|
|
|
parameters[8].Value = strCompanyID;
|
|
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql.ToString(), parameters);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -1;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存入库单明细wms_in
|
|
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
|
|
{
|
|
|
|
|
string strSql2 = "insert into wms_in(KINDPKGS,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,ARFEE,APFEE,CORPID) "
|
|
|
|
|
+ " values(@KINDPKGS,@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,@ARFEE,@APFEE,@CORPID)";//,CHARGEPRICE,@CHARGEPRICE
|
|
|
|
|
|
|
|
|
|
SqlParameter[] parms = {
|
|
|
|
|
new SqlParameter("@KINDPKGS",SqlDbType.VarChar,20),//
|
|
|
|
|
new SqlParameter("@ASSOCIATEDNO",SqlDbType.VarChar,100),//关联号
|
|
|
|
|
new SqlParameter("@BLNO",SqlDbType.VarChar,30),//提单号
|
|
|
|
|
new SqlParameter("@CONTRACTNO",SqlDbType.VarChar,100),//合同号
|
|
|
|
|
new SqlParameter("@CNTRNO",SqlDbType.VarChar,30),//箱号
|
|
|
|
|
new SqlParameter("@SEALNO",SqlDbType.VarChar,12),//封号
|
|
|
|
|
new SqlParameter("@BSNO",SqlDbType.VarChar,100),//仓单明细号
|
|
|
|
|
new SqlParameter("@CLIENTCODE",SqlDbType.VarChar,20),//客户编码
|
|
|
|
|
new SqlParameter("@CLIENTNAME",SqlDbType.VarChar,20),//客户名称
|
|
|
|
|
new SqlParameter("@STORAGECODE",SqlDbType.VarChar,50),//仓库编码
|
|
|
|
|
new SqlParameter("@STORAGENAME",SqlDbType.VarChar,100),//仓库名称
|
|
|
|
|
new SqlParameter("@AREACODE",SqlDbType.VarChar,50),//库位编码
|
|
|
|
|
new SqlParameter("@AREANAME",SqlDbType.VarChar,100),//库位名称
|
|
|
|
|
new SqlParameter("@GOODSCODE",SqlDbType.VarChar,50),//货物编号
|
|
|
|
|
new SqlParameter("@GOODSNAME",SqlDbType.VarChar,100),//货物名称/品名
|
|
|
|
|
new SqlParameter("@GOODSTYPE",SqlDbType.VarChar,50),//货物类型
|
|
|
|
|
new SqlParameter("@GOODSMODEL",SqlDbType.VarChar,100),//型号
|
|
|
|
|
new SqlParameter("@GOODSSTANDARD",SqlDbType.VarChar,100),//规格
|
|
|
|
|
new SqlParameter("@GOODSPACK",SqlDbType.Decimal),//件数
|
|
|
|
|
new SqlParameter("@CHARGEUNIT",SqlDbType.VarChar,10),//计费单位
|
|
|
|
|
//new SqlParameter("@CHARGEPRICE",SqlDbType.Decimal),//计费单价
|
|
|
|
|
new SqlParameter("@GOODSRKSL",SqlDbType.Decimal),//入库量
|
|
|
|
|
new SqlParameter("@GOODSSTOCK",SqlDbType.Decimal) ,//库存量
|
|
|
|
|
new SqlParameter("@ISLOCK",SqlDbType.Bit),//是否锁定
|
|
|
|
|
new SqlParameter("@LOCKUSER",SqlDbType.VarChar,36),//锁定操作人
|
|
|
|
|
new SqlParameter("@ISDELETE",SqlDbType.Bit),//是否废除
|
|
|
|
|
new SqlParameter("@DELETEUSER",SqlDbType.VarChar,36),//废除操作人
|
|
|
|
|
new SqlParameter("@CREATEUSER",SqlDbType.VarChar,36),//创建人
|
|
|
|
|
new SqlParameter("@MODIFIEDUSER",SqlDbType.VarChar,36),//最后一次更新操作人
|
|
|
|
|
new SqlParameter("@REMARK",SqlDbType.VarChar,1024),//备注
|
|
|
|
|
new SqlParameter("@FREESTORAGEPERIOD",SqlDbType.Int),//
|
|
|
|
|
new SqlParameter("@GOODSPACKSTOCK",SqlDbType.Decimal),//
|
|
|
|
|
new SqlParameter("@GOODSKGS",SqlDbType.Decimal),//重量
|
|
|
|
|
new SqlParameter("@CLIENTCODEOLD",SqlDbType.VarChar,20),//原客户编码
|
|
|
|
|
new SqlParameter("@CLIENTNAMEOLD",SqlDbType.VarChar,20),//原客户名称
|
|
|
|
|
new SqlParameter("@ARFEE",SqlDbType.Decimal),//
|
|
|
|
|
new SqlParameter("@APFEE",SqlDbType.Decimal),//
|
|
|
|
|
new SqlParameter("@CORPID",SqlDbType.VarChar,36)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
parms[0].Value = "";//
|
|
|
|
|
parms[1].Value = this.hdWMSGID.Value.Trim();// 关联号
|
|
|
|
|
parms[2].Value = "";// 提单号
|
|
|
|
|
parms[3].Value = "";// 合同号
|
|
|
|
|
parms[4].Value = "";// 箱号
|
|
|
|
|
parms[5].Value = "";// 封号
|
|
|
|
|
parms[6].Value = swmsno;// 仓单明细号
|
|
|
|
|
parms[7].Value = "";// 客户编码
|
|
|
|
|
parms[8].Value = WmsOutDetailEntity.CUSTOMERNAME;// 客户名称
|
|
|
|
|
parms[9].Value = "";// 仓库编码
|
|
|
|
|
parms[10].Value = WmsOutDetailEntity.STORAGENAME;// 仓库名称
|
|
|
|
|
parms[11].Value = "";// 库位编码
|
|
|
|
|
parms[12].Value = WmsOutDetailEntity.AREANAME;// 库位名称
|
|
|
|
|
parms[13].Value = "";// 货物编号
|
|
|
|
|
parms[14].Value = WmsOutDetailEntity.GOODSNAME;// 货物名称
|
|
|
|
|
parms[15].Value = "";// 货物类型
|
|
|
|
|
parms[16].Value = WmsOutDetailEntity.GOODSMODEL;// 型号
|
|
|
|
|
parms[17].Value = "";// 规格
|
|
|
|
|
parms[18].Value = WmsOutDetailEntity.GOODSPACKPFSL;// 件数
|
|
|
|
|
parms[19].Value = WmsOutDetailEntity.CHARGEUNIT;// 计费单位
|
|
|
|
|
//parms[20].Value = infoEntity.CHARGEPRICE;// 计费单价
|
|
|
|
|
parms[20].Value = WmsOutDetailEntity.GOODSPFSL;// 入库量
|
|
|
|
|
parms[21].Value = WmsOutDetailEntity.GOODSPFSL;// 库存量
|
|
|
|
|
parms[22].Value = false;// 是否锁定
|
|
|
|
|
parms[23].Value = "";// 锁定操作人
|
|
|
|
|
parms[24].Value = false;// 是否废除
|
|
|
|
|
parms[25].Value = "";// 废除操作人
|
|
|
|
|
parms[26].Value = strUserID;// 创建人
|
|
|
|
|
parms[27].Value = strUserID;// 最后一次更新操作人
|
|
|
|
|
parms[28].Value = "库间移位";// 备注
|
|
|
|
|
parms[29].Value = 0;//
|
|
|
|
|
parms[30].Value = WmsOutDetailEntity.GOODSPACKPFSL;//
|
|
|
|
|
parms[31].Value = 0;// 重量
|
|
|
|
|
parms[32].Value = "";// 客户编码
|
|
|
|
|
parms[33].Value = "";// 客户名称
|
|
|
|
|
parms[34].Value = 0;// WmsOutDetailEntity.ARFEE;
|
|
|
|
|
parms[35].Value = 0;// WmsOutDetailEntity.APFEE;
|
|
|
|
|
parms[36].Value = strCompanyID;//
|
|
|
|
|
|
|
|
|
|
//操作时间
|
|
|
|
|
string strDODATE = WmsOutEntity.DODATE.ToString().IndexOf("0001") > -1 ? "" : "'" + WmsOutEntity.DODATE.ToString() + "',";
|
|
|
|
|
string strDODATE_name = strDODATE.Equals("") ? "" : "DODATE,";
|
|
|
|
|
strSql2 = String.Format(strSql2, strDODATE_name, strDODATE);
|
|
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql2, parms);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -5;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
|
|
sqlTran.Commit();
|
|
|
|
|
|
|
|
|
|
//页面赋值
|
|
|
|
|
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_clientbsno.Value = this.h_clientbsno.Value;
|
|
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
|
|
string strcustomer = h_customer.Value;
|
|
|
|
|
//string goods = h_goods.Value;
|
|
|
|
|
#endregion
|
|
|
|
|
this.h_newcust.Value = "";
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
this.h_addmode.Value = "0";
|
|
|
|
|
this.h_Mode.Value = "1";
|
|
|
|
|
this.h_outbsno.Value = "0";
|
|
|
|
|
ViewState["h_Mode"] = this.h_Mode.Value;
|
|
|
|
|
this.h_outgid.Value = T_ALL_DA.GetStrSQL("gid", "select gid from wms_out where bsno='" + this.h_outbsno.Value.Trim() + "'");
|
|
|
|
|
ViewState["h_outgid"] = this.h_outgid.Value;
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>ShowShifting('" + this.hdWMSGID.Value.Trim() + "')</script>");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception execError)
|
|
|
|
|
{
|
|
|
|
|
result = -10;//有异常,插入失败
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -11;//插入异常,事务已回滚成功
|
|
|
|
|
Clearh();
|
|
|
|
|
throw execError;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
SqlHelper.CloseConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 生成出库单 SaveWoOutAction
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成出库单
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int SaveWoOutAction()
|
|
|
|
|
{
|
|
|
|
|
int iState = 0;
|
|
|
|
|
int result = 0;
|
|
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
|
|
|
|
//double totaloutfee = 0;//出库单的仓储费
|
|
|
|
|
//int prescale = 0;
|
|
|
|
|
//int nowscale = 0;
|
|
|
|
|
//int nowgrade = 0;
|
|
|
|
|
//double price = 0;
|
|
|
|
|
//double gradefee = 0;
|
|
|
|
|
//double 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 = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 生成出库单并计算费用
|
|
|
|
|
#region 保存出库单wms_out 出库单明细wms_out_detail
|
|
|
|
|
//
|
|
|
|
|
string strWMSNO = T_ALL_DA.GetStrSQL("BSNO", "select BSNO from wms_out where BSNO='" + WmsOutEntity.BSNO.ToString().Trim() + "'");
|
|
|
|
|
if (strWMSNO.Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert(出库单'" + strWMSNO + "'已经生成,不允许重复生成!);</script>");
|
|
|
|
|
return -3;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
//保存出库单wms_out
|
|
|
|
|
string ls = WmsOutEntity.TRUCKNO.ToString().Trim();
|
|
|
|
|
ls = ls.Replace("??"," ");
|
|
|
|
|
ls = ls.Replace("!!","\r\n");
|
|
|
|
|
//
|
|
|
|
|
Sqlstr = String.Format("insert into wms_out(GID,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,REMARK,CREATEUSER,CREATETIME,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,TRUCKNAME,GOODSPFSL,WMSOP,STOREMAN,CLIENTBSNO,CORPID)"
|
|
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}',getdate(),'{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}')"
|
|
|
|
|
, WmsOutEntity.GID, WmsOutEntity.BSNO, WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.REMARK, strUserID, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL, WmsOutEntity.TRUCKNAME, WmsOutEntity.GOODSPFSL, hd_comboWMSOP.Value.Trim(), hd_comboSTOREMAN.Value.Trim(), this.h_clientbsno.Value.Trim(),strCompanyID);
|
|
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
this.h_outgid.Value = WmsOutEntity.GID.ToString().Trim();
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -1;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//保存出库单明细wms_out_detail
|
|
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
|
|
{
|
|
|
|
|
//double outnums =double.Parse( WmsOutDetailEntity.GOODSPFSL.ToString());
|
|
|
|
|
//int feedays = WmsOutDetailDA.GetDaysCount(WmsOutDetailEntity.DODATE.ToString(), WmsOutEntity.DODATE.ToString());
|
|
|
|
|
//if (feedays > 0)
|
|
|
|
|
//{
|
|
|
|
|
WmsOutDetailEntity.OUTBSNO = WmsOutEntity.BSNO;
|
|
|
|
|
//SqlParameter parmrate = new SqlParameter("@BSNO", SqlDbType.VarChar, 100);
|
|
|
|
|
//parmrate.Value = 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 = double.Parse(drow["FEEPRICE"].ToString());
|
|
|
|
|
// if (nowgrade.Equals(1))
|
|
|
|
|
// {
|
|
|
|
|
// if (feedays > nowscale)
|
|
|
|
|
// {
|
|
|
|
|
// gradefee = outnums * price * nowscale;
|
|
|
|
|
// sumfee += gradefee;
|
|
|
|
|
// prescale = nowscale;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// gradefee = outnums * price * (feedays - prescale);
|
|
|
|
|
// sumfee += gradefee;
|
|
|
|
|
// prescale = nowscale;
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// else if (nowgrade > 1)
|
|
|
|
|
// {
|
|
|
|
|
// if (feedays > nowscale)
|
|
|
|
|
// {
|
|
|
|
|
// gradefee = outnums * price * (nowscale - prescale);
|
|
|
|
|
// sumfee += gradefee;
|
|
|
|
|
// prescale = nowscale;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// gradefee = outnums * price * (feedays - prescale);
|
|
|
|
|
// sumfee += gradefee;
|
|
|
|
|
// prescale = nowscale;
|
|
|
|
|
// break;
|
|
|
|
|
// WmsOutDetailEntity.DODATE
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// if (feedays > nowscale)
|
|
|
|
|
// {
|
|
|
|
|
// gradefee = outnums * price * (feedays - nowscale);
|
|
|
|
|
// sumfee += gradefee;
|
|
|
|
|
// }
|
|
|
|
|
// totaloutfee += sumfee;
|
|
|
|
|
// WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
|
|
// WmsOutDetailEntity.GOODSOUTFEE =decimal.Parse(Round( sumfee,2,"").ToString());
|
|
|
|
|
// }
|
|
|
|
|
// 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;
|
|
|
|
|
//}
|
|
|
|
|
//保存wms_out_detail
|
|
|
|
|
newGID = Guid.NewGuid().ToString();
|
|
|
|
|
WmsOutDetailEntity.GID = newGID;
|
|
|
|
|
//
|
|
|
|
|
#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
|
|
|
|
|
//bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
|
|
WmsOutDetailEntity.BSNO = bsno;
|
|
|
|
|
//
|
|
|
|
|
WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
|
|
WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = 0;
|
|
|
|
|
|
|
|
|
|
//WmsOutDetailEntity.INBSNO
|
|
|
|
|
//WmsOutDetailEntity.CUSTOMERNAME
|
|
|
|
|
//WmsOutDetailEntity.STORAGENAME
|
|
|
|
|
//WmsOutDetailEntity.GOODSNAME
|
|
|
|
|
//WmsOutDetailEntity.GOODSMODEL
|
|
|
|
|
//WmsOutDetailEntity.GOODSPFSL
|
|
|
|
|
//WmsOutDetailEntity.CREATEUSER
|
|
|
|
|
//WmsOutDetailEntity.REMARK
|
|
|
|
|
//ls
|
|
|
|
|
//WmsOutDetailEntity.ASSOCIATEDNO
|
|
|
|
|
//WmsOutDetailEntity.GOODSPACKPFSL
|
|
|
|
|
//WmsOutDetailEntity.ARFEE
|
|
|
|
|
//WmsOutDetailEntity.APFEE
|
|
|
|
|
//WmsOutDetailEntity.STORAGENAME
|
|
|
|
|
//
|
|
|
|
|
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
|
|
|
|
|
ls = ls.Replace("??", " ");
|
|
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
|
|
//
|
|
|
|
|
Sqlstr = String.Format("insert into wms_out_detail(GID,INBSNO,OUTBSNO,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSPFSL,CREATEUSER,CREATETIME,REMARK,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,ARFEE,APFEE,areaname,CHARGEUNIT,GOODSGRADE,GOODSSTANDARD,GOODSSLICE,CORPID) "
|
|
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}')"
|
|
|
|
|
, WmsOutDetailEntity.GID, WmsOutDetailEntity.INBSNO, WmsOutDetailEntity.OUTBSNO, WmsOutDetailEntity.BSNO, WmsOutDetailEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutDetailEntity.STORAGENAME, WmsOutDetailEntity.GOODSNAME, WmsOutDetailEntity.GOODSMODEL, WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.CREATEUSER, WmsOutDetailEntity.REMARK, ls, WmsOutDetailEntity.ASSOCIATEDNO, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.ARFEE, WmsOutDetailEntity.APFEE, WmsOutDetailEntity.AREANAME, WmsOutDetailEntity.CHARGEUNIT, WmsOutDetailEntity.GOODSGRADE, WmsOutDetailEntity.GOODSSTANDARD, WmsOutDetailEntity.GOODSSLICE, strCompanyID);
|
|
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -5;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//修改入库单wms_in
|
|
|
|
|
Sqlstr = String.Format("update wms_in set GOODSPACKSTOCK=GOODSPACKSTOCK-{0},GOODSSTOCK=GOODSSTOCK-{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;
|
|
|
|
|
}
|
|
|
|
|
//}
|
|
|
|
|
//else if (feedays < 0 && !WmsOutDetailEntity.CUSTOMERNAMEPARENT.Equals(null) && !WmsOutDetailEntity.CUSTOMERNAMEPARENT.Equals("") && WmsOutDetailEntity.CUSTOMERNAMEPARENT != WmsOutDetailEntity.CUSTOMERNAME)
|
|
|
|
|
//{
|
|
|
|
|
// //重算原货主仓储费
|
|
|
|
|
// SetOutPWmsFee(WmsOutEntity.DODATE.ToString(), WmsOutDetailEntity.CUSTOMERNAME, WmsOutDetailEntity.ASSOCIATEDNO, sqlTran);
|
|
|
|
|
//}
|
|
|
|
|
}// end 保存出库明细wms_out_detail
|
|
|
|
|
|
|
|
|
|
//修改wms_out的出库量、出库件数、应收应付装卸费
|
|
|
|
|
string lsSQL = String.Format("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='{0}'", 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());
|
|
|
|
|
|
|
|
|
|
//Sqlstr = String.Format("update wms_out set GOODSOUTFEE={0} where GID='{1}'", WmsOutEntity.GOODSOUTFEE, WmsOutEntity.GID);
|
|
|
|
|
//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();
|
|
|
|
|
// double deprice = 0;
|
|
|
|
|
// if (WmsOutEntity.GOODSPFSL != 0)
|
|
|
|
|
// {
|
|
|
|
|
// deprice = double.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;
|
|
|
|
|
// double amount = double.Parse(WmsOutEntity.GOODSPFSL.ToString()) * double.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_clientbsno.Value = h_clientbsno.Value;
|
|
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
|
|
string strcustomer = h_customer.Value;
|
|
|
|
|
//string goods = h_goods.Value;
|
|
|
|
|
#endregion
|
|
|
|
|
this.h_newcust.Value = "";
|
|
|
|
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
|
|
sqlTran.Commit();
|
|
|
|
|
this.h_addmode.Value = "0";
|
|
|
|
|
this.h_Mode.Value = "1";
|
|
|
|
|
ViewState["h_Mode"] = this.h_Mode.Value;
|
|
|
|
|
this.h_outgid.Value = T_ALL_DA.GetStrSQL("gid", "select gid from wms_out where bsno='" + this.h_outbsno.Value.Trim() + "'");
|
|
|
|
|
ViewState["h_outgid"] = this.h_outgid.Value;
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('操作成功');window.parent.opener.location.href=window.parent.opener.location.href;</script>");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception execError)
|
|
|
|
|
{
|
|
|
|
|
result = -10;//有异常,插入失败
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -11;//插入异常,事务已回滚成功
|
|
|
|
|
Clearh();
|
|
|
|
|
throw execError;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
SqlHelper.CloseConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 当前出库单中再添加一条 SaveWoOutActioneditadd
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成出库单
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int SaveWoOutActioneditadd()
|
|
|
|
|
{
|
|
|
|
|
int iState = 0;
|
|
|
|
|
int result = 0;
|
|
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
//
|
|
|
|
|
this.h_outgid.Value = ViewState["h_outgid"].ToString().Trim();
|
|
|
|
|
string stroutbsno = T_ALL_DA.GetStrSQL("BSNO", "select BSNO from wms_out where gid='" + this.h_outgid.Value.Trim() + "'");
|
|
|
|
|
//
|
|
|
|
|
//Sqlstr = String.Format("insert into wms_out(GID,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,REMARK,CREATEUSER,CREATETIME,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',getdate(),'{9}','{10}','{11}')", WmsOutEntity.GID, WmsOutEntity.BSNO, WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.GOODSNAME, WmsOutEntity.GOODSMODEL, WmsOutEntity.REMARK, WmsOutEntity.CREATEUSER, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL);
|
|
|
|
|
Sqlstr = String.Format("update wms_out set CUSTOMERNAME='{1}',DODATE='{2}',STORAGENAME='{3}',REMARK='{4}',MODIFIEDUSER='{5}',MODIFIEDTIME=getdate(),TRUCKNO='{6}',ASSOCIATEDNO='{7}',GOODSPACKPFSL=GOODSPACKPFSL+'{8}',TRUCKNAME='{9}',GOODSPFSL=GOODSPFSL+{10},CORPID='{11}' where GID='{0}'"
|
|
|
|
|
, this.h_outgid.Value.Trim(), WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.REMARK, strUserID, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL, WmsOutEntity.TRUCKNAME, WmsOutEntity.GOODSPFSL, strCompanyID);
|
|
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
//this.h_outgid.Value = WmsOutEntity.GID.ToString().Trim();
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -1;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//保存出库单明细wms_out_detail
|
|
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
|
|
{
|
|
|
|
|
//WmsOutDetailEntity.OUTBSNO = WmsOutEntity.BSNO;
|
|
|
|
|
|
|
|
|
|
//保存wms_out_detail
|
|
|
|
|
newGID = Guid.NewGuid().ToString();
|
|
|
|
|
WmsOutDetailEntity.GID = newGID;
|
|
|
|
|
//bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
|
|
//WmsOutDetailEntity.BSNO = bsno;
|
|
|
|
|
//WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
|
|
WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = 0;
|
|
|
|
|
//
|
|
|
|
|
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
|
|
|
|
|
ls = ls.Replace("??", " ");
|
|
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
|
|
//
|
|
|
|
|
Sqlstr = String.Format("insert into wms_out_detail(GID,INBSNO,OUTBSNO,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSPFSL,CREATEUSER,CREATETIME,REMARK,TRUCKNO,ASSOCIATEDNO,GOODSPACKPFSL,ARFEE,APFEE,areaname,CHARGEUNIT,CORPID) "
|
|
|
|
|
+ " values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}',getdate(),'{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')"
|
|
|
|
|
, WmsOutDetailEntity.GID, WmsOutDetailEntity.INBSNO, stroutbsno, stroutbsno, WmsOutDetailEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutDetailEntity.STORAGENAME, WmsOutDetailEntity.GOODSNAME, WmsOutDetailEntity.GOODSMODEL, WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.CREATEUSER, WmsOutDetailEntity.REMARK, ls, WmsOutDetailEntity.ASSOCIATEDNO, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.ARFEE, WmsOutDetailEntity.APFEE, WmsOutDetailEntity.AREANAME, WmsOutDetailEntity.CHARGEUNIT, strCompanyID);
|
|
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -5;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//修改入库单wms_in
|
|
|
|
|
Sqlstr = String.Format("update wms_in set GOODSPACKSTOCK=GOODSPACKSTOCK-{0},GOODSSTOCK=GOODSSTOCK-{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;
|
|
|
|
|
}
|
|
|
|
|
}// end 保存出库明细wms_out_detail
|
|
|
|
|
|
|
|
|
|
#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_clientbsno.Value = h_clientbsno.Value;
|
|
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
|
|
string strcustomer = h_customer.Value;
|
|
|
|
|
//string goods = h_goods.Value;
|
|
|
|
|
#endregion
|
|
|
|
|
this.h_newcust.Value = "";
|
|
|
|
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
|
|
sqlTran.Commit();
|
|
|
|
|
this.h_addmode.Value = "0";
|
|
|
|
|
this.h_Mode.Value = "1";
|
|
|
|
|
ViewState["h_Mode"] = this.h_Mode.Value;
|
|
|
|
|
ViewState["h_outgid"] = this.h_outgid.Value;
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('操作成功');window.parent.opener.location.href=window.parent.opener.location.href;</script>");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception execError)
|
|
|
|
|
{
|
|
|
|
|
result = -10;//有异常,插入失败
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -11;//插入异常,事务已回滚成功
|
|
|
|
|
Clearh();
|
|
|
|
|
throw execError;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
SqlHelper.CloseConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 编辑出库单 SaveWoOutActionedit
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑出库单
|
|
|
|
|
/// </summary>
|
|
|
|
|
private int SaveWoOutActionedit()
|
|
|
|
|
{
|
|
|
|
|
int iState = 0;
|
|
|
|
|
int result = 0;
|
|
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
|
|
|
|
//出库单信息
|
|
|
|
|
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");
|
|
|
|
|
//取出库明细修改前的值
|
|
|
|
|
this.h_outgid.Value = ViewState["h_outgid"].ToString().Trim();
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
Sqlstr = String.Format("update wms_out set CUSTOMERNAME='{1}',DODATE='{2}',STORAGENAME='{3}',REMARK='{4}',MODIFIEDUSER='{5}',MODIFIEDTIME=getdate(),TRUCKNO='{6}',ASSOCIATEDNO='{7}',GOODSPACKPFSL='{8}',TRUCKNAME='{9}',GOODSPFSL='{10}',CORPID='{11}' where GID='{0}'"
|
|
|
|
|
, this.h_outgid.Value.Trim(), WmsOutEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutEntity.STORAGENAME, WmsOutEntity.REMARK, strUserID, ls, WmsOutEntity.ASSOCIATEDNO, WmsOutEntity.GOODSPACKPFSL, WmsOutEntity.TRUCKNAME, WmsOutEntity.GOODSPFSL, strCompanyID);
|
|
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
//this.h_outgid.Value = WmsOutEntity.GID.ToString().Trim();
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -1;
|
|
|
|
|
Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
//保存出库单明细wms_out_detail
|
|
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
|
|
{
|
|
|
|
|
//WmsOutDetailEntity.OUTBSNO = WmsOutEntity.BSNO;
|
|
|
|
|
////保存wms_out_detail
|
|
|
|
|
//newGID = Guid.NewGuid().ToString();
|
|
|
|
|
//bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
|
|
//WmsOutDetailEntity.GID = WmsOutDetailEntity.INBSNO;
|
|
|
|
|
//WmsOutDetailEntity.BSNO = bsno;
|
|
|
|
|
//WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
|
|
//WmsOutDetailEntity.DODATE = WmsOutEntity.DODATE;
|
|
|
|
|
//WmsOutDetailEntity.GOODSOUTFEE = 0;
|
|
|
|
|
//
|
|
|
|
|
ls = WmsOutDetailEntity.TRUCKNO.ToString().Trim();
|
|
|
|
|
ls = ls.Replace("??", " ");
|
|
|
|
|
ls = ls.Replace("!!", "\r\n");
|
|
|
|
|
//修改入库单wms_in
|
|
|
|
|
Sqlstr = String.Format("update wms_in set GOODSPACKSTOCK=GOODSPACKSTOCK+(select GOODSPACKPFSL from wms_out_detail where gid='" + WmsOutDetailEntity.GID.ToString().Trim() + "')-{0},GOODSSTOCK=GOODSSTOCK+(select 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 CUSTOMERNAME='{1}',DODATE='{2}',STORAGENAME='{3}',GOODSNAME='{4}',GOODSMODEL='{5}',GOODSPFSL='{6}',CREATEUSER='{7}',CREATETIME=getdate(),REMARK='{8}',TRUCKNO='{9}',ASSOCIATEDNO='{10}',GOODSPACKPFSL='{11}',ARFEE='{12}',APFEE='{13}',areaname='{14}',CHARGEUNIT='{15}',CORPID='{16}' where GID='{0}'"
|
|
|
|
|
, WmsOutDetailEntity.GID, WmsOutDetailEntity.CUSTOMERNAME, WmsOutEntity.DODATE, WmsOutDetailEntity.STORAGENAME, WmsOutDetailEntity.GOODSNAME, WmsOutDetailEntity.GOODSMODEL, WmsOutDetailEntity.GOODSPFSL, WmsOutDetailEntity.CREATEUSER, WmsOutDetailEntity.REMARK, ls, WmsOutDetailEntity.ASSOCIATEDNO, WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.ARFEE, WmsOutDetailEntity.APFEE, WmsOutDetailEntity.AREANAME, WmsOutDetailEntity.CHARGEUNIT, strCompanyID);
|
|
|
|
|
iState=SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
|
|
|
|
|
if (iState != 1)
|
|
|
|
|
{
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -5;
|
|
|
|
|
//Clearh();
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}// end 保存出库明细wms_out_detail
|
|
|
|
|
//修改wms_out的出库量、出库件数、应收应付装卸费
|
|
|
|
|
string lsSQL = String.Format("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='{0}'", WmsOutEntity.GID.ToString().Trim());
|
|
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, lsSQL, 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_clientbsno.Value = h_clientbsno.Value;
|
|
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
|
|
string strcustomer = h_customer.Value;
|
|
|
|
|
//string goods = h_goods.Value;
|
|
|
|
|
#endregion
|
|
|
|
|
this.h_newcust.Value = "";
|
|
|
|
|
|
|
|
|
|
result = 1;//状态为1表示删除成功
|
|
|
|
|
sqlTran.Commit();
|
|
|
|
|
this.h_addmode.Value = "0";
|
|
|
|
|
this.h_Mode.Value = "1";
|
|
|
|
|
ViewState["h_Mode"] = this.h_Mode.Value;
|
|
|
|
|
ViewState["h_outgid"] = this.h_outgid.Value;
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key1", "<script>alert('操作成功');window.parent.opener.location.href=window.parent.opener.location.href;</script>");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception execError)
|
|
|
|
|
{
|
|
|
|
|
result = -10;//有异常,插入失败
|
|
|
|
|
sqlTran.Rollback();
|
|
|
|
|
result = -11;//插入异常,事务已回滚成功
|
|
|
|
|
//Clearh();
|
|
|
|
|
throw execError;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
SqlHelper.CloseConnection();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void SetOutPWmsFee(string OutDate, string CustName, string Associatedno, SqlTransaction sqlTran)
|
|
|
|
|
{
|
|
|
|
|
#region
|
|
|
|
|
int iState = 0;
|
|
|
|
|
string Sqlstr = "";
|
|
|
|
|
|
|
|
|
|
double totaloutfee = 0;//出库单的仓储费
|
|
|
|
|
int prescale = 0;
|
|
|
|
|
int nowscale = 0;
|
|
|
|
|
int nowgrade = 0;
|
|
|
|
|
double price = 0;
|
|
|
|
|
double gradefee = 0;
|
|
|
|
|
double sumfee = 0;
|
|
|
|
|
WmsOutDetailDA WmsOutDetailDA = new WmsOutDetailDA();
|
|
|
|
|
|
|
|
|
|
DataSet DsDetail;
|
|
|
|
|
DataTable TbDetail;
|
|
|
|
|
|
|
|
|
|
DataSet dsrate;
|
|
|
|
|
DataTable dtrate;
|
|
|
|
|
double outnums = 0;
|
|
|
|
|
int feedays = 0;
|
|
|
|
|
string OUTBSNO = "";//wms_out.BSNO
|
|
|
|
|
|
|
|
|
|
//查找对应的wms_out_detail记录
|
|
|
|
|
Sqlstr = String.Format("select a.GID,a.DODATE,a.GOODSPACKPFSL,a.GOODSPFSL,a.OUTBSNO,c.CLIENTNAMEOLD,c.CLIENTNAME,a.ASSOCIATEDNO from wms_out_detail a inner join wms_out b on a.OUTBSNO=b.BSNO inner join wms_in c on c.ASSOCIATEDNO=b.ASSOCIATEDNO and c.CLIENTNAMEOLD=b.CUSTOMERNAME and c.GOODSSTOCK=b.GOODSPFSL "
|
|
|
|
|
+ " where c.CLIENTNAME='{0}' and c.ASSOCIATEDNO='{1}' and a.DODATE>'{2}' ", CustName, Associatedno,OutDate);
|
|
|
|
|
DsDetail = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr.ToString(), null);
|
|
|
|
|
TbDetail = DsDetail.Tables[0];
|
|
|
|
|
foreach (DataRow r in TbDetail.Rows)
|
|
|
|
|
{
|
|
|
|
|
OUTBSNO = r["OUTBSNO"].ToString();
|
|
|
|
|
outnums = double.Parse(r["GOODSPFSL"].ToString());
|
|
|
|
|
feedays = WmsOutDetailDA.GetDaysCount("day", r["DODATE"].ToString(), OutDate);
|
|
|
|
|
if (feedays > 0)
|
|
|
|
|
{
|
|
|
|
|
Sqlstr = String.Format("SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT FROM wms_rate where BSNO='{1}' and CUSTOMERNAME like '%{0}%' order by BSNO,FEEGRADE ", CustName, r["ASSOCIATEDNO"].ToString());
|
|
|
|
|
dsrate = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr.ToString(), null);
|
|
|
|
|
dtrate = dsrate.Tables[0];
|
|
|
|
|
|
|
|
|
|
prescale = 0;
|
|
|
|
|
nowscale = 0;
|
|
|
|
|
nowgrade = 0;
|
|
|
|
|
price = 0;
|
|
|
|
|
|
|
|
|
|
gradefee = 0;
|
|
|
|
|
sumfee = 0;
|
|
|
|
|
foreach (DataRow drow in dtrate.Rows)
|
|
|
|
|
{
|
|
|
|
|
nowgrade = int.Parse(drow["FEEGRADE"].ToString());
|
|
|
|
|
nowscale = int.Parse(drow["FEESCALE"].ToString());
|
|
|
|
|
price = double.Parse(drow["FEEPRICE"].ToString());
|
|
|
|
|
if (nowgrade.Equals(1))
|
|
|
|
|
{
|
|
|
|
|
if (feedays > nowscale)
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * nowscale;
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
prescale = nowscale;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * (feedays - prescale);
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
prescale = nowscale;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (nowgrade > 1)
|
|
|
|
|
{
|
|
|
|
|
if (feedays > nowscale)
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * (nowscale - prescale);
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
prescale = nowscale;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * (feedays - prescale);
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
prescale = nowscale;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (feedays > nowscale)
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * (feedays - nowscale);
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
}
|
|
|
|
|
totaloutfee += sumfee;
|
|
|
|
|
//更新wms_out_detail
|
|
|
|
|
Sqlstr = String.Format("update wms_out_detail set DODATE='{0}',GOODSOUTFEE={1} where GID='{2}' "
|
|
|
|
|
, OutDate, decimal.Parse(Round(sumfee, 2, "").ToString()),r["GID"]);
|
|
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr.ToString(), null);
|
|
|
|
|
}
|
|
|
|
|
else if (feedays < 0 && r["CLIENTNAME"].ToString().Trim()!=r["CLIENTNAMEOLD"].ToString().Trim())
|
|
|
|
|
{
|
|
|
|
|
SetOutPWmsFee(OutDate, r["CLIENTNAMEOLD"].ToString(), r["ASSOCIATEDNO"].ToString(), sqlTran);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//查找到对应的wms_out记录,并更新wms_out OUTBSNO
|
|
|
|
|
Sqlstr = String.Format("update wms_out set DODATE='{0}',GOODSOUTFEE={1} where BSNO='{2}' "
|
|
|
|
|
, OutDate, decimal.Parse(Round(totaloutfee, 2, "").ToString()), OUTBSNO);
|
|
|
|
|
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr.ToString(), null);
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
private void Clearh()
|
|
|
|
|
{
|
|
|
|
|
this.h_post.Value = "";
|
|
|
|
|
|
|
|
|
|
//this.h_bsno.Value = "";
|
|
|
|
|
//this.hd_wmsgid.Value = "";
|
|
|
|
|
|
|
|
|
|
//this.h_wmsoutbsno.Value = "";
|
|
|
|
|
//this.h_outgid.Value = "";
|
|
|
|
|
//this.h_outbsno.Value = "";
|
|
|
|
|
//txt_outbsno.Value = "";
|
|
|
|
|
//txt_packnum.Value = "";
|
|
|
|
|
//h_packnum.Value = "";
|
|
|
|
|
//h_goodspfsl.Value = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 生成插入语句参数
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成插入语句参数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回SqlParameter数组</returns>
|
|
|
|
|
private SqlParameter[] GetInsertParms()
|
|
|
|
|
{
|
|
|
|
|
SqlParameter[] parms = new SqlParameter[]{
|
|
|
|
|
new SqlParameter("@GID",SqlDbType.VarChar,100),//惟一编号
|
|
|
|
|
new SqlParameter("@ASSOCIATEDNO",SqlDbType.VarChar,100),//关联号
|
|
|
|
|
new SqlParameter("@BLNO",SqlDbType.VarChar,30),//提单号
|
|
|
|
|
new SqlParameter("@CONTRACTNO",SqlDbType.VarChar,100),//合同号
|
|
|
|
|
new SqlParameter("@CNTRNO",SqlDbType.VarChar,30),//箱号
|
|
|
|
|
new SqlParameter("@SEALNO",SqlDbType.VarChar,12),//封号
|
|
|
|
|
new SqlParameter("@BSNO",SqlDbType.VarChar,100),//仓单明细号
|
|
|
|
|
new SqlParameter("@CLIENTCODE",SqlDbType.VarChar,20),//客户编码
|
|
|
|
|
new SqlParameter("@CLIENTNAME",SqlDbType.VarChar,20),//客户名称
|
|
|
|
|
new SqlParameter("@STORAGECODE",SqlDbType.VarChar,50),//仓库编码
|
|
|
|
|
new SqlParameter("@STORAGENAME",SqlDbType.VarChar,100),//仓库名称
|
|
|
|
|
new SqlParameter("@AREACODE",SqlDbType.VarChar,50),//库位编码
|
|
|
|
|
new SqlParameter("@AREANAME",SqlDbType.VarChar,100),//库位名称
|
|
|
|
|
new SqlParameter("@GOODSCODE",SqlDbType.VarChar,50),//货物编号
|
|
|
|
|
new SqlParameter("@GOODSNAME",SqlDbType.VarChar,100),//货物名称/品名
|
|
|
|
|
new SqlParameter("@GOODSTYPE",SqlDbType.VarChar,50),//货物类型
|
|
|
|
|
new SqlParameter("@GOODSMODEL",SqlDbType.VarChar,100),//型号
|
|
|
|
|
new SqlParameter("@GOODSSTANDARD",SqlDbType.VarChar,100),//规格
|
|
|
|
|
new SqlParameter("@GOODSPACK",SqlDbType.Int),//件数
|
|
|
|
|
new SqlParameter("@CHARGEUNIT",SqlDbType.VarChar,10),//计费单位
|
|
|
|
|
//new SqlParameter("@CHARGEPRICE",SqlDbType.Decimal),//计费单价
|
|
|
|
|
new SqlParameter("@GOODSRKSL",SqlDbType.Decimal),//入库量
|
|
|
|
|
new SqlParameter("@GOODSSTOCK",SqlDbType.Decimal) ,//库存量
|
|
|
|
|
new SqlParameter("@ISLOCK",SqlDbType.Bit),//是否锁定
|
|
|
|
|
new SqlParameter("@LOCKUSER",SqlDbType.VarChar,36),//锁定操作人
|
|
|
|
|
new SqlParameter("@ISDELETE",SqlDbType.Bit),//是否废除
|
|
|
|
|
new SqlParameter("@DELETEUSER",SqlDbType.VarChar,36),//废除操作人
|
|
|
|
|
new SqlParameter("@CREATEUSER",SqlDbType.VarChar,36),//创建人
|
|
|
|
|
new SqlParameter("@MODIFIEDUSER",SqlDbType.VarChar,36),//最后一次更新操作人
|
|
|
|
|
new SqlParameter("@REMARK",SqlDbType.VarChar,1024),//备注
|
|
|
|
|
new SqlParameter("@FREESTORAGEPERIOD",SqlDbType.Int),//件数
|
|
|
|
|
new SqlParameter("@CLIENTNAMEOLD",SqlDbType.VarChar,20),//备注
|
|
|
|
|
//new SqlParameter("@GOODSKGS",SqlDbType.Decimal)//重量
|
|
|
|
|
//new SqlParameter("@DODATE",SqlDbType.Datetime),//操作时间
|
|
|
|
|
//new SqlParameter("@LOCKTIME",SqlDbType.Datetime),//锁定时间
|
|
|
|
|
//new SqlParameter("@DELETETIME",SqlDbType.Datetime),//废除时间
|
|
|
|
|
//new SqlParameter("@CREATETIME",SqlDbType.Datetime),//创建时间
|
|
|
|
|
//new SqlParameter("@MODIFIEDTIME",SqlDbType.Datetime),//最后一次更新操作时间
|
|
|
|
|
};
|
|
|
|
|
return parms;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将页面post获取的出库保存或更新“出库信息表和出库明细表”wms_out,wms_out_detail,并返回操作结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void SaveWoAction()
|
|
|
|
|
{
|
|
|
|
|
WmsOutEntity WmsOutEntity = new WmsOutEntity();
|
|
|
|
|
//IList<WmsOutDetailEntity> WmsOutDetailEntitys = new List<WmsOutDetailEntity>();
|
|
|
|
|
|
|
|
|
|
if (!WoJSON.Trim().Equals(""))
|
|
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
|
|
WmsOutEntity = ResolveWoJSON(WoJSON.Trim(), WmsOutEntity);
|
|
|
|
|
WoContainer.Value = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WmsOutDA WmsOutDA = new WmsOutDA();
|
|
|
|
|
bool State = false;
|
|
|
|
|
if (WmsOutEntity != null)
|
|
|
|
|
{
|
|
|
|
|
State = WmsOutDA.Add(WmsOutEntity, "");
|
|
|
|
|
if (State)
|
|
|
|
|
{
|
|
|
|
|
this.h_wmsoutbsno.Value = WmsOutEntity.BSNO.ToString();
|
|
|
|
|
this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL.ToString();
|
|
|
|
|
this.h_goodspfsl.Value = WmsOutEntity.GOODSPFSL.ToString();
|
|
|
|
|
this.h_remark.Value = WmsOutEntity.REMARK.ToString();
|
|
|
|
|
SaveWoDetailAction(WmsOutEntity);//保存出库明细
|
|
|
|
|
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key2", "<script>alert('信息保存成功');window.parent.opener.location.href=window.parent.opener.location.href;</script>");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('信息保存失败');</script>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
h_post.Value = "";//请求状态清空
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempJSON"></param>
|
|
|
|
|
/// <param name="tempFeeEntities"></param>
|
|
|
|
|
/// <returns>将页面post获取的费用信息读入到费用实体类ch_fee中</returns>
|
|
|
|
|
private WmsOutEntity ResolveWoJSON(string tempJSON, WmsOutEntity tempWoEntity)
|
|
|
|
|
{
|
|
|
|
|
string OutGid = "";
|
|
|
|
|
string OutBsno = "";
|
|
|
|
|
DateTime OutDate = new DateTime();
|
|
|
|
|
string strFilter = "";
|
|
|
|
|
WmsOutEntity WmsOutEntity = new WmsOutEntity();
|
|
|
|
|
if (tempJSON.IndexOf("[") >= 0 && tempJSON.IndexOf("]") > 0)
|
|
|
|
|
{
|
|
|
|
|
strFilter = tempJSON.Substring(tempJSON.IndexOf("[") + 1, tempJSON.IndexOf("]") - tempJSON.IndexOf("[") - 1);
|
|
|
|
|
|
|
|
|
|
string[] strFees = strFilter.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
if (strFees.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < strFees.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
strFees[i] = strFees[i].ToString().Replace("{", "");
|
|
|
|
|
strFees[i] = strFees[i].ToString().Replace("}", "");
|
|
|
|
|
string[] strCell = strFees[i].Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
if (strCell.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
|
|
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "txtoutbsno":
|
|
|
|
|
WmsOutEntity.CUSTOMERNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
h_outbsno.Value = WmsOutEntity.CUSTOMERNAME;
|
|
|
|
|
break;
|
|
|
|
|
case "txtclientbsno":
|
|
|
|
|
this.h_clientbsno.Value = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
txt_clientbsno.Value = this.h_clientbsno.Value;
|
|
|
|
|
WmsOutEntity.CLIENTBSNO = this.h_clientbsno.Value;
|
|
|
|
|
break;
|
|
|
|
|
case "cust":
|
|
|
|
|
WmsOutEntity.CUSTOMERNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
h_customer.Value = WmsOutEntity.CUSTOMERNAME;
|
|
|
|
|
break;
|
|
|
|
|
case "truck":
|
|
|
|
|
WmsOutEntity.TRUCKNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
h_truck.Value = WmsOutEntity.TRUCKNAME;
|
|
|
|
|
break;
|
|
|
|
|
case "outdate":
|
|
|
|
|
WmsOutEntity.DODATE =DateTime.Parse( strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
OutDate = WmsOutEntity.DODATE;
|
|
|
|
|
h_outdate.Value = WmsOutEntity.DODATE.ToString("yyyy-MM-dd");
|
|
|
|
|
break;
|
|
|
|
|
//case "goodsname":
|
|
|
|
|
// WmsOutEntity.GOODSNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
// h_goods.Value = WmsOutEntity.GOODSNAME;
|
|
|
|
|
// break;
|
|
|
|
|
//case "goodsmodel":
|
|
|
|
|
// WmsOutEntity.GOODSMODEL = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
// this.h_goodsmodel.Value = WmsOutEntity.GOODSMODEL;
|
|
|
|
|
// 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 "goodspfsl":
|
|
|
|
|
decimal outgoodspfsl = Decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
WmsOutEntity.GOODSPFSL = outgoodspfsl;
|
|
|
|
|
//WmsOutEntity.GOODSPFSL = Convert.ToInt16(Math.Round(outgoodspfsl, 0));
|
|
|
|
|
break;
|
|
|
|
|
case "remark":
|
|
|
|
|
WmsOutEntity.REMARK = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
this.h_remark.Value = WmsOutEntity.REMARK;
|
|
|
|
|
this.txt_remark.Value = WmsOutEntity.REMARK;
|
|
|
|
|
break;
|
|
|
|
|
case "truckno":
|
|
|
|
|
WmsOutEntity.TRUCKNO = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
this.h_truckno.Value = WmsOutEntity.TRUCKNO;
|
|
|
|
|
break;
|
|
|
|
|
case "storage":
|
|
|
|
|
WmsOutEntity.STORAGENAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
this.h_storage.Value = WmsOutEntity.STORAGENAME;
|
|
|
|
|
break;
|
|
|
|
|
case "wmsgid":
|
|
|
|
|
WmsOutEntity.ASSOCIATEDNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
//this.hd_wmsgid.Value = WmsOutEntity.ASSOCIATEDNO;
|
|
|
|
|
this.h_bsno.Value = WmsOutEntity.ASSOCIATEDNO;
|
|
|
|
|
break;
|
|
|
|
|
case "wmsop":
|
|
|
|
|
WmsOutEntity.WMSOP = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
this.hd_comboWMSOP.Value = WmsOutEntity.WMSOP;
|
|
|
|
|
break;
|
|
|
|
|
case "storeman":
|
|
|
|
|
WmsOutEntity.STOREMAN = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
this.hd_comboSTOREMAN.Value = WmsOutEntity.STOREMAN;
|
|
|
|
|
break;
|
|
|
|
|
case "isJsFee":
|
|
|
|
|
isJsFee =bool.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")) && this.h_outgid.Value.ToString().Trim()=="")
|
|
|
|
|
{
|
|
|
|
|
OutGid= getBSNO();
|
|
|
|
|
if (h_outbsno.Value.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
OutBsno = getCodeRuleWmsOut("出库单号", "BSNO");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OutBsno = this.h_outbsno.Value.Trim();
|
|
|
|
|
}
|
|
|
|
|
this.h_outgid.Value = OutGid;
|
|
|
|
|
this.h_outbsno.Value = OutBsno;
|
|
|
|
|
this.txt_outbsno.Value = OutBsno;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
OutGid = this.h_outgid.Value.ToString();
|
|
|
|
|
OutBsno = this.txt_outbsno.Value.ToString().Trim();
|
|
|
|
|
this.h_outbsno.Value = OutBsno;
|
|
|
|
|
}
|
|
|
|
|
WmsOutEntity.GID = OutGid;
|
|
|
|
|
WmsOutEntity.BSNO = OutBsno;
|
|
|
|
|
|
|
|
|
|
//WmsOutEntity.STORAGENAME = h_storage.Value;
|
|
|
|
|
//WmsOutEntity.TRUCKNO = h_truckno.Value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return WmsOutEntity;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 将页面post获取的出库保存或更新“出库明细表”wms_out_detail,并返回操作结果
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将页面post获取的出库保存或更新“出库明细表”wms_out_detail,并返回操作结果
|
|
|
|
|
/// </summary>
|
|
|
|
|
private bool SaveWoDetailAction(WmsOutEntity wmsOutEntity)
|
|
|
|
|
{
|
|
|
|
|
IList<WmsOutDetailEntity> WmsOutDetailEntitys = new List<WmsOutDetailEntity>();
|
|
|
|
|
|
|
|
|
|
if (!WoDetailJSON.Trim().Equals(""))
|
|
|
|
|
{ //将应收费用信息从前台页面写入费用实体类feeEntities
|
|
|
|
|
WmsOutDetailEntitys = ResolveWoDetailJSON(WoDetailJSON.Trim(), WmsOutDetailEntitys);
|
|
|
|
|
this.WoDetailContainer.Value = "";
|
|
|
|
|
}
|
|
|
|
|
decimal totaloutfee = 0;//出库单的仓储费
|
|
|
|
|
bool State = false;
|
|
|
|
|
int count = 0;
|
|
|
|
|
int success = 0;
|
|
|
|
|
int nonum = 0;
|
|
|
|
|
int prescale = 0;
|
|
|
|
|
int nowscale = 0;
|
|
|
|
|
int nowgrade = 0;
|
|
|
|
|
decimal price = 0;
|
|
|
|
|
decimal gradefee = 0;
|
|
|
|
|
decimal sumfee = 0;
|
|
|
|
|
string newGID = "";
|
|
|
|
|
string bsno = "";
|
|
|
|
|
|
|
|
|
|
var strSql = "";
|
|
|
|
|
WmsOutDetailDA WmsOutDetailDA = new WmsOutDetailDA();
|
|
|
|
|
if (isJsFee==true)
|
|
|
|
|
{
|
|
|
|
|
if (WmsOutDetailEntitys != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (WmsOutDetailEntity WmsOutDetailEntity in WmsOutDetailEntitys)
|
|
|
|
|
{
|
|
|
|
|
decimal outnums = WmsOutDetailEntity.GOODSPFSL;
|
|
|
|
|
int feedays = WmsOutDetailDA.GetDaysCount("day", WmsOutDetailEntity.DODATE.ToString(), wmsOutEntity.DODATE.ToString());
|
|
|
|
|
if (feedays > 0)
|
|
|
|
|
{
|
|
|
|
|
WmsOutDetailEntity.OUTBSNO = wmsOutEntity.BSNO;
|
|
|
|
|
|
|
|
|
|
strSql = String.Format("SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT "
|
|
|
|
|
+ " FROM wms_rate "
|
|
|
|
|
+ " where BSNO='{0}' "
|
|
|
|
|
+ " order by BSNO,FEEGRADE ",
|
|
|
|
|
wmsOutEntity.ASSOCIATEDNO);
|
|
|
|
|
DataSet dsrate = WmsOutDetailDA.GetRateListByCondition(strSql);
|
|
|
|
|
DataTable dtrate = new DataTable();
|
|
|
|
|
if (dsrate != null)
|
|
|
|
|
{
|
|
|
|
|
dtrate = dsrate.Tables[0];
|
|
|
|
|
if (dtrate.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
prescale = 0;
|
|
|
|
|
nowscale = 0;
|
|
|
|
|
nowgrade = 0;
|
|
|
|
|
price = 0;
|
|
|
|
|
gradefee = 0;
|
|
|
|
|
sumfee = 0;
|
|
|
|
|
foreach (DataRow drow in dtrate.Rows)
|
|
|
|
|
{
|
|
|
|
|
nowgrade = int.Parse(drow["FEEGRADE"].ToString());
|
|
|
|
|
nowscale = int.Parse(drow["FEESCALE"].ToString());
|
|
|
|
|
price = decimal.Parse(drow["FEEPRICE"].ToString());
|
|
|
|
|
if (nowgrade.Equals(1))
|
|
|
|
|
{
|
|
|
|
|
if (feedays > nowscale)
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * nowscale;
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
prescale = nowscale;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * (feedays - prescale);
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
prescale = nowscale;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (nowgrade > 1)
|
|
|
|
|
{
|
|
|
|
|
if (feedays > nowscale)
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * (nowscale - prescale);
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
prescale = nowscale;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * (feedays - prescale);
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
prescale = nowscale;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if (feedays > nowscale)
|
|
|
|
|
{
|
|
|
|
|
gradefee = outnums * price * (feedays - nowscale);
|
|
|
|
|
sumfee += gradefee;
|
|
|
|
|
}
|
|
|
|
|
totaloutfee += sumfee;
|
|
|
|
|
WmsOutDetailEntity.DODATE = wmsOutEntity.DODATE;
|
|
|
|
|
WmsOutDetailEntity.GOODSOUTFEE = sumfee;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{//仓储费率没有设定
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{//计费天数错误
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//保存wms_out_detail
|
|
|
|
|
newGID = Guid.NewGuid().ToString();
|
|
|
|
|
bsno = getCodeRuleWmsOutDetail("出库明细单号", "BSNO");
|
|
|
|
|
WmsOutDetailEntity.GID = newGID;
|
|
|
|
|
WmsOutDetailEntity.BSNO = bsno;
|
|
|
|
|
WmsOutDetailEntity.OUTBSNO = this.h_outbsno.Value;
|
|
|
|
|
|
|
|
|
|
State = WmsOutDetailDA.Add(WmsOutDetailEntity, "");
|
|
|
|
|
count++;
|
|
|
|
|
if (State)
|
|
|
|
|
{
|
|
|
|
|
success++;
|
|
|
|
|
WmsInDA wmsinDA = new WmsInDA();
|
|
|
|
|
bool inState = wmsinDA.Update(WmsOutDetailEntity.GOODSPFSL,WmsOutDetailEntity.GOODSPACKPFSL, WmsOutDetailEntity.INBSNO);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{//保存失败
|
|
|
|
|
nonum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//修改wms_out的仓储费wmsOutEntity.GOODSOUTFEE
|
|
|
|
|
h_outfee.Value = totaloutfee.ToString();
|
|
|
|
|
wmsOutEntity.GOODSOUTFEE = totaloutfee;
|
|
|
|
|
WmsOutDA wmsoutDA = new WmsOutDA();
|
|
|
|
|
State = wmsoutDA.Update(wmsOutEntity, "");
|
|
|
|
|
//页面赋值
|
|
|
|
|
txt_outbsno.Value = h_outbsno.Value;
|
|
|
|
|
txt_clientbsno.Value = h_clientbsno.Value;
|
|
|
|
|
txt_outdate.Value = h_outdate.Value;
|
|
|
|
|
string strcustomer = h_customer.Value;
|
|
|
|
|
string goods = h_goods.Value;
|
|
|
|
|
h_packnum.Value = wmsOutEntity.GOODSPACKPFSL.ToString();
|
|
|
|
|
//txt_packnum.Value = wmsOutEntity.GOODSPACKPFSL.ToString();
|
|
|
|
|
|
|
|
|
|
//将仓储费和出库费写入ch_fee
|
|
|
|
|
|
|
|
|
|
FeeDA feeDA = new FeeDA();
|
|
|
|
|
IList<FeeEntity> feeEntities = new List<FeeEntity>();
|
|
|
|
|
FeeEntity feeEntity = new FeeEntity();
|
|
|
|
|
int iState = 0;
|
|
|
|
|
decimal deprice = 0;
|
|
|
|
|
deprice = wmsOutEntity.GOODSOUTFEE / wmsOutEntity.GOODSPFSL;
|
|
|
|
|
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 = deprice;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
feeEntity = new FeeEntity();
|
|
|
|
|
}
|
|
|
|
|
//出库费
|
|
|
|
|
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().Trim() == "出库费")
|
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
feeEntity.Amount = wmsOutEntity.GOODSPFSL * decimal.Parse(r["UNITPRICE"].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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{//提示出库费用没有维护
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key3", "<script>alert('出库单生成成功');</script>");
|
|
|
|
|
h_post.Value = "";//请求状态清空
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempJSON"></param>
|
|
|
|
|
/// <param name="tempFeeEntities"></param>
|
|
|
|
|
/// <returns>将页面post获取的费用信息读入到费用实体类ch_fee中</returns>
|
|
|
|
|
private IList<WmsOutDetailEntity> ResolveWoDetailJSON(string tempJSON, IList<WmsOutDetailEntity> tempWoDetailEntities)
|
|
|
|
|
{
|
|
|
|
|
string strFilter = "";
|
|
|
|
|
if (tempJSON.IndexOf("[") >= 0 && tempJSON.IndexOf("]") > 0)
|
|
|
|
|
{
|
|
|
|
|
strFilter = tempJSON.Substring(tempJSON.IndexOf("[") + 1, tempJSON.IndexOf("]") - tempJSON.IndexOf("[") - 1);
|
|
|
|
|
|
|
|
|
|
string[] strFees = strFilter.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
if (strFees.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < strFees.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
strFees[i] = strFees[i].ToString().Replace("{", "");
|
|
|
|
|
strFees[i] = strFees[i].ToString().Replace("}", "");
|
|
|
|
|
string[] strCell = strFees[i].Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
if (strCell.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
WmsOutDetailEntity WmsOutDetailEntity = new WmsOutDetailEntity();
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
|
|
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "gid":
|
|
|
|
|
WmsOutDetailEntity.GID = strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
break;
|
|
|
|
|
case "cust":
|
|
|
|
|
WmsOutDetailEntity.CUSTOMERNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
break;
|
|
|
|
|
case "areaname":
|
|
|
|
|
WmsOutDetailEntity.AREANAME = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
break;
|
|
|
|
|
case "inbsno":
|
|
|
|
|
WmsOutDetailEntity.INBSNO =strArg[1].ToString().Replace("\"", "");
|
|
|
|
|
break;
|
|
|
|
|
case "indate":
|
|
|
|
|
WmsOutDetailEntity.DODATE =DateTime.Parse(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
break;
|
|
|
|
|
case "goodsname":
|
|
|
|
|
WmsOutDetailEntity.GOODSNAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "goodsmodel":
|
|
|
|
|
WmsOutDetailEntity.GOODSMODEL = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "truckno":
|
|
|
|
|
WmsOutDetailEntity.TRUCKNO = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
break;
|
|
|
|
|
case "storage":
|
|
|
|
|
WmsOutDetailEntity.STORAGENAME = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "wmsgid":
|
|
|
|
|
WmsOutDetailEntity.ASSOCIATEDNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "outnum":
|
|
|
|
|
double tmpoutnum = double.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
//WmsOutDetailEntity.GOODSPFSL = decimal.Parse( Round(tmpoutnum, 4).ToString());
|
|
|
|
|
break;
|
|
|
|
|
case "outpacknum":
|
|
|
|
|
WmsOutDetailEntity.GOODSPACKPFSL = Decimal.Parse(strArg[1].ToString().Replace("\"", "").ToString());
|
|
|
|
|
break;
|
|
|
|
|
case "remark":
|
|
|
|
|
WmsOutDetailEntity.REMARK = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "custparent":
|
|
|
|
|
WmsOutDetailEntity.CUSTOMERNAMEPARENT=strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "arfee":
|
|
|
|
|
string strarfee = "0.00";
|
|
|
|
|
if(strArg[1].ToString().Replace("\"", "").Trim()!="")
|
|
|
|
|
{
|
|
|
|
|
strarfee = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
}
|
|
|
|
|
WmsOutDetailEntity.ARFEE = Decimal.Parse(strarfee);
|
|
|
|
|
break;
|
|
|
|
|
case "apfee":
|
|
|
|
|
string strapfee = "0.00";
|
|
|
|
|
if (strArg[1].ToString().Replace("\"", "").Trim() != "")
|
|
|
|
|
{
|
|
|
|
|
strapfee = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
}
|
|
|
|
|
WmsOutDetailEntity.APFEE = Decimal.Parse(strapfee);
|
|
|
|
|
break;
|
|
|
|
|
case "goodspfsl":
|
|
|
|
|
string strGOODSPFSL = "0.0000";
|
|
|
|
|
if(strArg[1].ToString().Replace("\"", "").Trim()!="")
|
|
|
|
|
{
|
|
|
|
|
strGOODSPFSL = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
}
|
|
|
|
|
WmsOutDetailEntity.GOODSPFSL = Decimal.Parse(strGOODSPFSL);
|
|
|
|
|
break;
|
|
|
|
|
case "chargeunit":
|
|
|
|
|
WmsOutDetailEntity.CHARGEUNIT = UnicodeToGB(strArg[1].ToString().Replace("\"", ""));
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//if (!this.h_storage.Value.ToString().Equals("") && !this.h_storage.Value.Equals(null))
|
|
|
|
|
//{
|
|
|
|
|
// WmsOutDetailEntity.STORAGENAME = this.h_storage.Value.ToString();
|
|
|
|
|
//}
|
|
|
|
|
//else
|
|
|
|
|
//{
|
|
|
|
|
// WmsOutDetailEntity.STORAGENAME = " ";
|
|
|
|
|
//}
|
|
|
|
|
WmsOutDetailEntity.CREATEUSER =strShowName;
|
|
|
|
|
|
|
|
|
|
tempWoDetailEntities.Add(WmsOutDetailEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tempWoDetailEntities;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将页面post获取的费用信息读入到费用实体类ch_fee中
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempJSON"></param>
|
|
|
|
|
/// <param name="tempFeeEntities"></param>
|
|
|
|
|
/// <returns>将页面post获取的费用信息读入到费用实体类ch_fee中</returns>
|
|
|
|
|
private IList<FeeEntity> ResolveFeeJSON(string tempJSON, IList<FeeEntity> tempFeeEntities)
|
|
|
|
|
{
|
|
|
|
|
string strFilter = "";
|
|
|
|
|
if (tempJSON.IndexOf("[") >= 0 && tempJSON.IndexOf("]") > 0)
|
|
|
|
|
{
|
|
|
|
|
strFilter = tempJSON.Substring(tempJSON.IndexOf("[") + 1, tempJSON.IndexOf("]") - tempJSON.IndexOf("[") - 1);
|
|
|
|
|
|
|
|
|
|
string[] strFees = strFilter.Split(new string[] { "},{" }, System.StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
|
if (strFees.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < strFees.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
strFees[i] = strFees[i].ToString().Replace("{", "");
|
|
|
|
|
strFees[i] = strFees[i].ToString().Replace("}", "");
|
|
|
|
|
string[] strCell = strFees[i].Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
if (strCell.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
FeeEntity feeEntity = new FeeEntity();
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < strCell.Length; j++)
|
|
|
|
|
{
|
|
|
|
|
string[] strArg = strCell[j].Split(new char[] { ':' });
|
|
|
|
|
|
|
|
|
|
switch (strArg[0].Replace("\"", ""))
|
|
|
|
|
{
|
|
|
|
|
case "id":
|
|
|
|
|
feeEntity.GID = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "type":
|
|
|
|
|
feeEntity.FeeType = int.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "bsno":
|
|
|
|
|
feeEntity.BSNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "outbsno":
|
|
|
|
|
feeEntity.WMSOUTBSNO = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "status":
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "fname":
|
|
|
|
|
feeEntity.FeeName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "cust":
|
|
|
|
|
feeEntity.CustomerName = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "unit":
|
|
|
|
|
string tempUnit = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
|
|
|
|
|
if (tempUnit.Equals("null") || tempUnit.Equals(""))
|
|
|
|
|
{
|
|
|
|
|
feeEntity.Unit = "";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
feeEntity.Unit = tempUnit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case "price":
|
|
|
|
|
feeEntity.UnitPrice = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "quant":
|
|
|
|
|
feeEntity.Quantity = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "com":
|
|
|
|
|
feeEntity.CommissionRate = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "amount":
|
|
|
|
|
feeEntity.Amount = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "cur":
|
|
|
|
|
feeEntity.Currency = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "rate":
|
|
|
|
|
feeEntity.ExchangeRate = decimal.Parse(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "frt":
|
|
|
|
|
feeEntity.FeeFrt = strArg[1].ToString().Replace("\"", "").Trim();
|
|
|
|
|
break;
|
|
|
|
|
case "remark":
|
|
|
|
|
feeEntity.Remark = UnicodeToGB(strArg[1].ToString().Replace("\"", "").Trim());
|
|
|
|
|
break;
|
|
|
|
|
case "isadv":
|
|
|
|
|
feeEntity.IsAdvancePay = strArg[1].ToString().Replace("\"", "").Trim().Equals("1") ? true : false;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
strSeaBSNO = feeEntity.BSNO;
|
|
|
|
|
feeEntity.EnterOperator = this.strUserID;
|
|
|
|
|
feeEntity.FeeStatus = 1;
|
|
|
|
|
tempFeeEntities.Add(feeEntity);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tempFeeEntities;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Unicode-GB Code转换
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unicode-GB Code转换
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="text">将Unicode编码字符转换成GB编码字符</param>
|
|
|
|
|
/// <returns>GB Code字符串</returns>
|
|
|
|
|
public string UnicodeToGB(string text)
|
|
|
|
|
{
|
|
|
|
|
UnicodeEncoding unicode = new UnicodeEncoding();
|
|
|
|
|
text = unicode.GetString(unicode.GetBytes(Regex.Unescape(text.Trim())));
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Unicode-GB Code转换
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="text">将Unicode编码字符转换成GB编码字符</param>
|
|
|
|
|
/// <returns>GB Code字符串</returns>
|
|
|
|
|
public string UnicodeToGB_Old(string text)
|
|
|
|
|
{
|
|
|
|
|
MatchCollection mc = Regex.Matches(text, "([\\w]+)|(\\\\u([\\w]{4}))");
|
|
|
|
|
if (mc != null && mc.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
foreach (Match m2 in mc)
|
|
|
|
|
{
|
|
|
|
|
string v = m2.Value;
|
|
|
|
|
if (v.IndexOf("\\") >= 0)
|
|
|
|
|
{
|
|
|
|
|
string word = v.Substring(2);
|
|
|
|
|
byte[] codes = new byte[2];
|
|
|
|
|
int code = Convert.ToInt32(word.Substring(0, 2), 16);
|
|
|
|
|
int code2 = Convert.ToInt32(word.Substring(2), 16);
|
|
|
|
|
codes[0] = (byte)code2;
|
|
|
|
|
codes[1] = (byte)code;
|
|
|
|
|
sb.Append(Encoding.Unicode.GetString(codes));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
sb.Append(v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return text;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 将页面post获取的利润值读入到利润实体类中
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将页面post获取的利润值读入到利润实体类中
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回利润实体类 FeeProfitEntity</returns>
|
|
|
|
|
private FeeProfitEntity GetRequestProfit()
|
|
|
|
|
{
|
|
|
|
|
FeeProfitEntity tempFeeProfitEntity = new FeeProfitEntity();
|
|
|
|
|
|
|
|
|
|
#region 保留
|
|
|
|
|
//tempFeeProfitEntity.RMBDR = Decimal.Parse(dvRecvRMBVal.InnerText.Trim());
|
|
|
|
|
//tempFeeProfitEntity.USDDR = Decimal.Parse(dvUSRecvVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.OTHERDR = Decimal.Parse(dvOtherCurrencyRecvVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.RMBCR = Decimal.Parse(dvPayRMBVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.USDCR = Decimal.Parse(dvUSPayVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.OTHERCR = Decimal.Parse(dvOtherCurrencyPayVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.DRTTL = Decimal.Parse(dvRecvTotalVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.CRTTL = Decimal.Parse(dvPaySumVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.RMBProfit = Decimal.Parse(dvRMBProfitVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.USDProfit = Decimal.Parse(dvUSProfitVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.OTHERProfit = Decimal.Parse(dvOtherCurrencyProfitVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.TTLProfit = Decimal.Parse(dvProfitTotalVal.InnerHtml.Trim());
|
|
|
|
|
//tempFeeProfitEntity.ProfitRate = dvProfitRateVal.InnerHtml.Trim();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (!gainContainer.Value.Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
string[] gainList = gainContainer.Value.Trim().Split(new char[] { ',' });
|
|
|
|
|
|
|
|
|
|
if (!gainList[0].ToString().Trim().Equals(""))
|
|
|
|
|
{
|
|
|
|
|
tempFeeProfitEntity.RMBDR = Decimal.Parse(gainList[0].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.USDDR = Decimal.Parse(gainList[1].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.OTHERDR = Decimal.Parse(gainList[2].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.RMBCR = Decimal.Parse(gainList[3].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.USDCR = Decimal.Parse(gainList[4].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.OTHERCR = Decimal.Parse(gainList[5].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.DRTTL = Decimal.Parse(gainList[6].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.CRTTL = Decimal.Parse(gainList[7].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.RMBProfit = Decimal.Parse(gainList[8].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.USDProfit = Decimal.Parse(gainList[9].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.OTHERProfit = Decimal.Parse(gainList[10].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.TTLProfit = Decimal.Parse(gainList[11].ToString().Trim());
|
|
|
|
|
tempFeeProfitEntity.ProfitRate = gainList[12].ToString().Trim();
|
|
|
|
|
tempFeeProfitEntity.CreateUser = this.strUserID;
|
|
|
|
|
tempFeeProfitEntity.ModifiedUser = this.strUserID;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
tempFeeProfitEntity.RMBDR = 0;
|
|
|
|
|
tempFeeProfitEntity.USDDR = 0;
|
|
|
|
|
tempFeeProfitEntity.OTHERDR = 0;
|
|
|
|
|
tempFeeProfitEntity.RMBCR = 0;
|
|
|
|
|
tempFeeProfitEntity.USDCR = 0;
|
|
|
|
|
tempFeeProfitEntity.OTHERCR = 0;
|
|
|
|
|
tempFeeProfitEntity.DRTTL = 0;
|
|
|
|
|
tempFeeProfitEntity.CRTTL = 0;
|
|
|
|
|
tempFeeProfitEntity.RMBProfit = 0;
|
|
|
|
|
tempFeeProfitEntity.USDProfit = 0;
|
|
|
|
|
tempFeeProfitEntity.OTHERProfit = 0;
|
|
|
|
|
tempFeeProfitEntity.TTLProfit = 0;
|
|
|
|
|
tempFeeProfitEntity.ProfitRate = "0%";
|
|
|
|
|
tempFeeProfitEntity.CreateUser = this.strUserID;
|
|
|
|
|
tempFeeProfitEntity.ModifiedUser = this.strUserID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tempFeeProfitEntity;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取用户应收、应付权限信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取用户应收、应付权限信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tempFeeType">费用类型</param>
|
|
|
|
|
/// <returns>返回 true 有权限操作数据 false 没有权限操作数据</returns>
|
|
|
|
|
private bool ValidateUserFeeAuthority(int tempFeeType)
|
|
|
|
|
{
|
|
|
|
|
int iResult = 0;
|
|
|
|
|
|
|
|
|
|
if (tempFeeType == 1)
|
|
|
|
|
{
|
|
|
|
|
UserAuthorityManage userAuthorityManageOrder = new UserAuthorityManage(strUserID, "modSeaImportList");
|
|
|
|
|
UserAuthorityManage userRecvAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiRecvFeeManagement");
|
|
|
|
|
|
|
|
|
|
if (userRecvAuthorityManage.OperateType != AuthorityType.NULL)
|
|
|
|
|
{
|
|
|
|
|
iResult = userAuthorityManageOrder.CheckOperateRange(ModuleType.OPSEAILIST, userRecvAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strSeaBSNO, "", strUserID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UserAuthorityManage userAuthorityManageOrder = new UserAuthorityManage(strUserID, "modSeaImportList");
|
|
|
|
|
UserAuthorityManage userPayAuthorityManage = new UserAuthorityManage(strUserID, "modSeaiPayFeeManagement");
|
|
|
|
|
|
|
|
|
|
if (userPayAuthorityManage.OperateType != AuthorityType.NULL)
|
|
|
|
|
{
|
|
|
|
|
iResult = userAuthorityManageOrder.CheckOperateRange(ModuleType.OPSEAILIST, userPayAuthorityManage.OperateType, strShowName, strCompanyID, strDeptName, strSeaBSNO, "", strUserID);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (iResult > 0)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region getBSNO
|
|
|
|
|
protected String getBSNO()
|
|
|
|
|
{
|
|
|
|
|
string strBSNO = Guid.NewGuid().ToString();
|
|
|
|
|
strBSNO = strBSNO.Replace("-", "");
|
|
|
|
|
strBSNO = "WmsOut" + strBSNO;
|
|
|
|
|
return strBSNO;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 提取规则编号 getCodeRuleWmsOutDetail
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提取规则编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected String getCodeRuleWmsOutDetail(string strRULENAME, string strfield)
|
|
|
|
|
{
|
|
|
|
|
//调用编码规则
|
|
|
|
|
string strRULEYEAR = "";
|
|
|
|
|
string strRULECONTENT = "";
|
|
|
|
|
string strCODENAME = "";
|
|
|
|
|
string strDEPTNO = "";
|
|
|
|
|
string strRULENOLENGTH = "";
|
|
|
|
|
int iRULENOLENGTH = 0;
|
|
|
|
|
int inum = 0;
|
|
|
|
|
string strCONTENT = "";
|
|
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL("select *,getdate() DODATE from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3");
|
|
|
|
|
if (ds != null)
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
getCodeRuleEnabled(strRULENAME, strfield);
|
|
|
|
|
//
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().Trim());
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = dETD.ToString("yyyy");
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = dETD.ToString("yy");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
|
|
|
|
|
{
|
|
|
|
|
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = fwqdate.ToString("yyyy");
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = fwqdate.ToString("yy");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
|
|
}
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
|
|
|
|
|
}
|
|
|
|
|
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
|
|
|
|
|
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
|
|
|
|
|
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
|
|
|
|
|
//
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
iRULENOLENGTH = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
|
|
|
|
|
}
|
|
|
|
|
strCONTENT = strRULECONTENT + strRULEYEAR;
|
|
|
|
|
//获取分公司的票号头字符
|
|
|
|
|
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
|
|
|
|
|
strCONTENT = tempBANKSHEAD + strCONTENT;
|
|
|
|
|
//
|
|
|
|
|
strRULENOLENGTH = 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 CREATETIME 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 = true;//false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
txt_outbsno.Disabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 提取规则编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="strRULENAME">规则项目名称</param>
|
|
|
|
|
/// <param name="strfield">需要加规则的字段</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
protected String getCodeRuleWmsIn(string strRULENAME, string strfield, string srq)
|
|
|
|
|
{
|
|
|
|
|
//调用编码规则
|
|
|
|
|
string strRULEYEAR = "";
|
|
|
|
|
string strRULECONTENT = "";
|
|
|
|
|
string strCODENAME = "";
|
|
|
|
|
string strDEPTNO = "";
|
|
|
|
|
string strRULENOLENGTH = "";
|
|
|
|
|
int iRULENOLENGTH = 0;
|
|
|
|
|
int inum = 0;
|
|
|
|
|
string strCONTENT = "";
|
|
|
|
|
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3");
|
|
|
|
|
if (ds != null)
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
getCodeRuleEnabled(strRULENAME, strfield);
|
|
|
|
|
//
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
|
|
|
|
|
{
|
|
|
|
|
if (srq.Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
DateTime dETD = System.Convert.ToDateTime(srq.Trim());
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = dETD.ToString("yyyy");
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = dETD.ToString("yy");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
|
|
|
|
|
{
|
|
|
|
|
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = fwqdate.ToString("yyyy");
|
|
|
|
|
}
|
|
|
|
|
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
|
|
|
|
|
{
|
|
|
|
|
strRULEYEAR = fwqdate.ToString("yy");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + this.hdUserID.Value.Trim() + "')");
|
|
|
|
|
}
|
|
|
|
|
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
|
|
|
|
|
{
|
|
|
|
|
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + this.hdUserID.Value.Trim() + "')");
|
|
|
|
|
}
|
|
|
|
|
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
|
|
|
|
|
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
|
|
|
|
|
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
|
|
|
|
|
//
|
|
|
|
|
if (ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
|
|
|
|
|
{
|
|
|
|
|
iRULENOLENGTH = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
|
|
|
|
|
}
|
|
|
|
|
strCONTENT = strRULECONTENT + strRULEYEAR;
|
|
|
|
|
//获取分公司的票号头字符
|
|
|
|
|
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
|
|
|
|
|
strCONTENT = tempBANKSHEAD + strCONTENT;
|
|
|
|
|
//
|
|
|
|
|
strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [wms] where " + strfield + " like '" + strCONTENT.Trim() + "%' and ISDELETE=0 order by " + strfield + " DESC");
|
|
|
|
|
if (strRULENOLENGTH == "")
|
|
|
|
|
{
|
|
|
|
|
strRULENOLENGTH = "1";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
|
|
|
|
|
inum = int.Parse(strRULENOLENGTH.Trim());
|
|
|
|
|
inum = inum + 1;
|
|
|
|
|
strRULENOLENGTH = inum.ToString();
|
|
|
|
|
}
|
|
|
|
|
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
|
|
|
|
|
for (int i = 1; i <= j; i++)
|
|
|
|
|
{
|
|
|
|
|
strRULENOLENGTH = "0" + strRULENOLENGTH;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
strCONTENT = strCONTENT + strRULENOLENGTH;
|
|
|
|
|
return strCONTENT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected String getWMSNO()
|
|
|
|
|
{
|
|
|
|
|
string strWMSNO = Guid.NewGuid().ToString();
|
|
|
|
|
strWMSNO = strWMSNO.Replace("-", "");
|
|
|
|
|
strWMSNO = "WmsZ" + strWMSNO;
|
|
|
|
|
return strWMSNO;
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
}
|
|
|
|
|
}
|