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

900 lines
44 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using DSWeb.Models;
using DSWeb.EntityDA;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using WebSqlHelper;
using System.Data.SqlClient;
namespace DSWeb.SeaiFee
{
public partial class WmsOutEditCBMGridSource : System.Web.UI.Page
{
private string strRateGid;//费率GID
private string strHandle;//费用操作说明
private const int iResult = -99;//参数错误
private string strUserID;//用户GID
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
private int iCurrentPage;//当前页数
private int iShowPage;//显示最大页数
private string strSearch;//委托信息查询条件
private string strbsno;
private string strwmsoutgid;
private string strcustomer;
private string strcustid;//客户gid
////private string strgidlist;//费率列表
private string stropseaibsno;
private string strwmsoutbsno;
private string strsum;
private string strnum;
private string strmode;
private decimal outnums = 0;
private int feedays = 0;
//附件信息
private string strtb = "";//
private string linkgid = "";//
//
public string strgids = "";
private const string PARM_FEE_GID = "@gid";
private const string PARM_FEEPROFIT_BSNO = "@bsno";//委托编号
private const string SQL_UPDATE_FEE_PROFIT_PRECENT = " UPDATE fee_gain SET PROFITRATE = A.PROFITRATE FROM ("
+ " SELECT BSNO,(CAST(CAST(CASE WHEN CRTTL=0 THEN 0 ELSE (ROUND(TTLPROFIT/CRTTL,4))*100 END as decimal(18,2)) as varchar(20))+'%') as PROFITRATE FROM fee_gain WHERE BSNO = @bsno"
+ " )as A WHERE fee_gain.BSNO = A.BSNO";
private const string SQL_DELETE_FEE_BY_GID = "DELETE FROM ch_fee WHERE GID = @gid";
protected void Page_Load(object sender, EventArgs e)
{
#region 参数处理
if (Session["USERID"] != null)
{
strUserID = Session["USERID"].ToString();
}
if (Session["SHOWNAME"] != null)
{
strShowName = Session["SHOWNAME"].ToString();
}
if (Session["COMPANYID"] != null)
{
strCompanyID = Session["COMPANYID"].ToString();
}
if (Session["DEPTNAME"] != null)
{
strDeptName = Session["DEPTNAME"].ToString();
}
if (Request.QueryString["handle"] != null)
{
strHandle = Request.QueryString["handle"].ToString();
}
if (Request.QueryString["bsno"] != null)
{
strbsno = Request.QueryString["bsno"].ToString();
}
if (Request.QueryString["tb"] != null)
{
strtb = Request.QueryString["tb"].ToString();
}
if (Request.QueryString["linkgid"] != null)
{
linkgid = Request.QueryString["linkgid"].ToString();
}
if (Request.QueryString["outnums"] != null)
{
outnums =decimal.Parse( Request.QueryString["outnums"].ToString());
}
if (Request.QueryString["feedays"] != null)
{
feedays =int.Parse( Request.QueryString["feedays"].ToString());
}
if (Request.QueryString["wmsoutgid"] != null)
{
strwmsoutgid = Request.QueryString["wmsoutgid"].ToString();
}
if (Request.QueryString["wmsoutbsno"] != null)
{
strwmsoutbsno = Request.QueryString["wmsoutbsno"].ToString();
}
if (Request.QueryString["opseaibsno"] != null)
{
stropseaibsno = Request.QueryString["opseaibsno"].ToString();
}
if (Request.QueryString["custid"] != null)
{
strcustid = Request.QueryString["custid"].ToString();
}
if (Request.QueryString["gid"] != null)
{
strRateGid = Request.QueryString["gid"].ToString();
}
if (Request.QueryString["cus"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strcustomer = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["cus"].ToString())));
}
if (Request.QueryString["search"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strSearch = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
}
if (Request.QueryString["cur_page"] != null)
{
iCurrentPage = int.Parse(Request.QueryString["cur_page"].ToString().Trim());
}
else
{
iCurrentPage = 0;
}
if (Request.QueryString["show_page"] != null)
{
iShowPage = int.Parse(Request.QueryString["show_page"].ToString().Trim());
}
else
{
iShowPage = 0;
}
if (Request.QueryString["sum"] != null)
{
strsum = Request.QueryString["sum"].ToString();
}
if (Request.QueryString["num"] != null)
{
strnum = Request.QueryString["num"].ToString();
}
if (Request.QueryString["mode"] != null)
{
strmode = Request.QueryString["mode"].ToString();
}
if (Request.QueryString["gids"] != null && Request.QueryString["gids"].ToString().Trim() != "")
{
strgids = Request.QueryString["gids"].ToString().Trim();
}
if (strHandle != null)
{
if (strHandle == "goodslist")
{ //获得货物信息
XmlDocument docs = GetDoc();
Response.ContentType = "text/xml";
Response.Write(docs.OuterXml.ToString());
return;
}
if (strHandle == "wmsinlist")
{
//获取cbm的明细入库wms_in信息
Response.Write(GetWmsInList());
return;
}
if (strHandle == "wmsinlistedit")
{
//出库修改页面
Response.Write(GetWmsInListEdit());
return;
}
if (strHandle == "deletewmsout")
{//
Response.Write(DeleteWmsOutByGid(strwmsoutgid));
}
if (strHandle == "islock")
{ //入账信息
Response.Write(setislock());
}
if (strHandle == "notlock")
{ //取消入账信息
Response.Write(setnotlock());
}
if (strHandle == "getislock")
{ //判断是否入账信息
Response.Write(getislock());
}
if (strHandle == "getiswmsin")
{ //判断是否入账信息
Response.Write(getiswmsin());
}
if (strHandle == "getCustomno")
{
string id = Request.QueryString["id"].ToString();
Response.Write(getCustomno(id));
}
}
#endregion
}
private string getCustomno(string id)
{
string strSQL = "select top 1 CUSTOMNO from wms where gid=(select top 1 ASSOCIATEDNO from wms_in where gid='" + id.Trim() + "')";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string value = T_ALL_DA.GetStrSQL("CUSTOMNO", strSQL);
return value;
}
private string getiswmsin()
{
string sGids = "'" + strgids.Replace(",", "','") + "'";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string strSQL = "select count(gid) nums from (SELECT o.GID,o.REMARK,o.bsno FROM wms AS i INNER JOIN wms_out AS o ON i.ASSOCIATEDNO = o.ASSOCIATEDNO AND o.ingidnew = i.gid AND o.ISCHANGE = 1 and o.ASSOCIATEDNO not like 'topseailcl%' and i.ISLOCK=1) as a where gid in (" + sGids + ") or bsno in (" + sGids + ") ";//o.REMARK = '货权转移'
string ls = T_ALL_DA.GetStrSQL("nums", strSQL);
return ls;
}
private string getislock()
{
string sGids = "'" + strgids.Replace(",", "','") + "'";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string ls = T_ALL_DA.GetStrSQL("nums", "select count(gid) nums from wms_out where ISLOCK=1 and (gid in (" + sGids + ") or bsno in (" + sGids + "))");
return ls;
}
private string setnotlock()
{
string sGids = "'" + strgids.Replace(",", "','") + "'";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
string ls = T_ALL_DA.GetStrSQL("nums", "select count(gid) nums from ch_fee where (bsno in (" + sGids + ") or WMSOUTBSNO in (" + sGids + ")) and (ISINVOICE=1 or AUDITSTATUS=1 or ORDERINVOICE<>0.00 or DEBITNO is not null or (FEESTATUS<>0 and FEESTATUS<>1))");
if (ls.Trim() == "0")
{
ls = T_ALL_DA.GetStrSQL("nums", "select count(gid) nums from ch_fee_do where feeid in (select gid nums from ch_fee where (bsno in (" + sGids + ") or WMSOUTBSNO in (" + sGids + ")))");
if (ls.Trim() == "0")
{
WmsOutDA WmsOutDA = new WmsOutDA();
int iResult = WmsOutDA.setnotlock2(strgids, strUserID);
if (iResult < 0)
{
return "操作有误,请重新操作!";
}
}
else
{
return "有“未申请开票、未开发票或未对帐”的入账数据,不允许取消入账,请重新操作!";
}
}
else
{
return "有“未申请开票、未开发票、未对帐”的入账数据,不允许取消入账,请重新操作!";
}
return "";
}
private string setislock()
{
//string sGids = strgids.Replace(",", "','");
//T_ALL_DA T_ALL_DA = new T_ALL_DA();
//string sSQL = "select isnull(count(*),0) as lsnum from wms_out where CUSTOMERNAME is not null and CUSTOMERNAME<>'' and gid in ('" + sGids + "')";// and TRUCKNAME is not null and TRUCKNAME<>''
//string lsnum = T_ALL_DA.GetStrSQL("lsnum", sSQL);
//if (lsnum.Trim() == "0")
//{
// return "应收客户有为空数据,不允许操作!";//应付
//}
//
WmsOutDA WmsOutDA = new WmsOutDA();
int iResult = WmsOutDA.setislock2(strgids, strUserID);
if (iResult < 0)
{
return "操作有误,请重新操作!";
}
return "";
}
#region 获取出库列表的当前页合计信息
/// <summary>
/// 获取费率信息
/// </summary>
/// <returns>返回JSON数据</returns>
private string getfpk2()
{
WmsRateDA WmsRateDA = new WmsRateDA();
DataTable sourceTable;
StringBuilder sourceBuilder = new StringBuilder();
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strSql = "";
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 "bt"://ETD BeginDate
strCondition += String.Format(" AND a.DODATE >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "et"://ETD EndDate
strCondition += String.Format(" AND a.DODATE <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://CUSTOMER
strCondition += String.Format(" AND a.CUSTOMERNAME like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "bsno"://NO
strCondition += String.Format(" AND (a.ASSOCIATEDNO in ((select bsno from op_seai where mblno like '%{0}%') union all (select bsno from op_seae where mblno like '%{0}%')) or a.bsno like '%{0}%')", strArg[1].Replace("\"", ""));
break;
case "goods":
strCondition += String.Format(" AND a.GOODSNAME like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
else
{
if (strbsno != "")
{
strCondition += String.Format(" AND a.ASSOCIATEDNO like '%{0}%' ", strbsno);
}
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format("select isnull(sum(GOODSOUTFEE),0) as GOODSOUTFEE,isnull(sum(GOODSOUTFEEAP),0) as GOODSOUTFEEAP,isnull(sum(ARFEE),0) as ARFEE,isnull(sum(APFEE),0) as APFEE,isnull(sum(GOODSPACKPFSL),0) as GOODSPACKPFSL,isnull(sum(GOODSPFSL),0) as GOODSPFSL from (SELECT {0} * from wms_out a where 1=1 {1} {2} ORDER BY a.GOODSNAME DESC) as z ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format("select isnull(sum(GOODSOUTFEE),0) as GOODSOUTFEE,isnull(sum(GOODSOUTFEEAP),0) as GOODSOUTFEEAP,isnull(sum(ARFEE),0) as ARFEE,isnull(sum(APFEE),0) as APFEE,isnull(sum(GOODSPACKPFSL),0) as GOODSPACKPFSL,isnull(sum(GOODSPFSL),0) as GOODSPFSL from (SELECT {0} * from wms_out a WHERE 1=1 and a.GID NOT IN (SELECT {1} a.GID from wms_out a WHERE 1=1 {2} {3} ORDER BY a.GOODSNAME DESC ) {2} {3} ORDER BY a.GOODSNAME DESC) as z ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
}
}
else
{
strSql = String.Format("select isnull(sum(GOODSOUTFEE),0) as GOODSOUTFEE,isnull(sum(GOODSOUTFEEAP),0) as GOODSOUTFEEAP,isnull(sum(ARFEE),0) as ARFEE,isnull(sum(APFEE),0) as APFEE,isnull(sum(GOODSPACKPFSL),0) as GOODSPACKPFSL,isnull(sum(GOODSPFSL),0) as GOODSPFSL from (SELECT {0} * from wms_out a where 1<0 {1} {2} ORDER BY a.GOODSNAME DESC) as z ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
}
sourceTable = WmsRateDA.GetExcuteSql(strSql).Tables[0];
string ls = sourceTable.Rows[0][0].ToString().Trim() + "," + sourceTable.Rows[0][1].ToString().Trim() + "," + sourceTable.Rows[0][2].ToString().Trim() + "," + sourceTable.Rows[0][3].ToString().Trim() + "," + sourceTable.Rows[0][4].ToString().Trim() + "," + sourceTable.Rows[0][5].ToString().Trim();
return ls;
}
#endregion
/// <summary>
/// 出库合计数
/// </summary>
/// <returns></returns>
private string SumJs()
{
decimal sum = 0;
decimal num = 0;
if (strsum.Trim().Equals("") || strsum.Equals(null))
{
sum = 0;
}
else
{
sum = decimal.Parse(strsum);
}
num = decimal.Parse(strnum);
if (strmode == "check")
{
sum += num;
}
else if (strmode == "uncheck")
{
if (sum > num)
{
sum -= num;
}
else
{
sum = 0;
}
}
StringBuilder totalBuilder = new StringBuilder();
totalBuilder.Append("{");
totalBuilder.Append("\"totals\":");
totalBuilder.Append("[");
totalBuilder.Append("{");
totalBuilder.Append("\"sum\":" + sum.ToString());
totalBuilder.Append("}");
totalBuilder.Append("]");
totalBuilder.Append("}");
return totalBuilder.ToString();
}
public string BuildXML()
{
string strMark="0";
int iPos = 0;
StringBuilder resultBuilder = new StringBuilder();
resultBuilder.Append("<?xml version=\"1.0\" ?>");
resultBuilder.AppendFormat("<complete{0}>", iPos == 0 ? string.Empty : " add=\"true\"");
if (!string.IsNullOrEmpty(strMark))
{
string js = "";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
DataSet ds = T_ALL_DA.GetTCodeGoods();
if (ds != null)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
if (dr["GOODCODE"].ToString().Trim() != "" || dr["GOODNAME"].ToString().Trim() != "")
{
js = dr["GOODCODE"].ToString().Trim() + " | " + dr["GOODNAME"].ToString().Trim();
resultBuilder.AppendFormat("<option value=\"{0}\">{1}</option>", dr["GOODCODE"].ToString().Trim(), js);//dr["GOODNAME"].ToString().Trim());
}
}
}
}
resultBuilder.AppendFormat("<option value=\"{0}\">{1}</option>", "", "");
resultBuilder.Append("</complete>");
return resultBuilder.ToString().Replace("&", "&amp;");
}
public XmlDocument GetDoc()
{
XmlDocument xmldoc = new XmlDocument();
string content = BuildXML();
try
{
xmldoc.LoadXml(content);
}
catch (Exception)
{
}
return xmldoc;
}
#region 获取cbm的明细入库wms_in信息
/// <summary>
/// 获取cbm的明细入库wms_in信息
/// </summary>
/// <returns>返回JSON数据</returns>
private string GetWmsInList()
{
WmsInDA WmsInDA = new WmsInDA();
DataTable sourceTable;
StringBuilder sourceBuilder = new StringBuilder();
string strCondition = "";
string strSql = "";
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 "opseaibsno"://CUSTOMER
strCondition += String.Format(" AND ASSOCIATEDNO in (select gid from wms where ASSOCIATEDNO = '{0}') ", strArg[1].Replace("\"", ""));
break;
case "cus"://CUSTOMER
strCondition += String.Format(" AND CLIENTNAME like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "blno"://NO
strCondition += String.Format(" AND BLNO like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "goodsmodel":
strCondition += String.Format(" AND goodsmodel like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "GOODSSTANDARD":
strCondition += String.Format(" AND GOODSSTANDARD like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "wmsno"://入库单号
strCondition += String.Format(" AND BSNO like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "store":
strCondition += String.Format(" AND STORAGENAME like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
else
{
if (!strbsno.Equals(null) && !strbsno.Equals(""))
{
strCondition += String.Format(" AND ASSOCIATEDNO in (select gid from wms where ASSOCIATEDNO = '{0}') ", strbsno);
}
else
{
strCondition += " and 0>1";
}
}
strCondition += " and CHARGEUNIT='CBM'";
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
//var headerArgs_wmsin = new Array("", "货主", "提单号", "入库单号", "入库日期", "开始计费日期", "等级", "品名", "品牌", "规格", "片数/件", "剩余件数", "剩余库存", "出库件数", "立方米", "应收出库费", "应付出库费", "车号", "备注", "仓库名称", "进口委托单号", "单件吨数", "原货主", "入库GID", "出库明细GID");
//板材明细1
strSql = String.Format(" SELECT GID,CLIENTNAME,BLNO,BSNO,convert(char(10),DODATE,120) DODATE"
+ ",STARTBILLINGDATE=(select convert(char(10),STARTBILLINGDATE,120) as STARTBILLINGDATE from wms where gid=wms_in.ASSOCIATEDNO)"
+ ",GOODSGRADE,GOODSNAME,GOODSMODEL,GOODSSTANDARD,GOODSTHICKNESS,GOODSWIDTH,GOODSLENGTH,GOODSSLICE,GOODSPACKSTOCK,GOODSSTOCK,0 as GOODSPACKPFSL,0 as GOODSPFSL,0 as ARFEE,0 as APFEE,' ' as TRUCKNO,' ' as REMARK,STORAGENAME"
+ ",ASSOCIATEDNO=(select ASSOCIATEDNO from wms where gid=wms_in.ASSOCIATEDNO)"
+ ",convert(numeric(18,4),(GOODSSTOCK/GOODSPACKSTOCK)) as GOODSKGS,CLIENTNAMEOLD,gid,newid() as wmsoutdetailgid "
+ ",STARTBILLINGDATEAP=(select convert(char(10),STARTBILLINGDATEAP,120) as STARTBILLINGDATEAP from wms where gid=wms_in.ASSOCIATEDNO)"
+ ",GOODSPACKSTOCK as GOODSPACKSTOCK_EDIT,GOODSSTOCK as GOODSSTOCK_EDIT"
+ " FROM wms_in where isnull(ISDELETE,0)=0 and isnull(ISLOCK,0)=1 and GOODSPACKSTOCK<>0 and GOODSSTOCK>0 {0} {1} "
+ " ORDER BY BLNO,GOODSNAME,GOODSGRADE,GOODSSTANDARD,DODATE ", strAuthorityCondition, strCondition);
sourceTable = WmsInDA.GetExcuteSql(strSql).Tables[0];
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 获取入库wms_in信息_出库更新
/// <summary>
/// 获取入库wms_in信息
/// </summary>
/// <returns>返回JSON数据</returns>
private string GetWmsInListEdit()
{
WmsInDA WmsInDA = new WmsInDA();
DataTable sourceTable;
StringBuilder sourceBuilder = new StringBuilder();
string strCondition = "";
string strSql = "";
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 "opseaibsno"://CUSTOMER
strCondition += String.Format(" AND ASSOCIATEDNO = '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cus"://CUSTOMER
strCondition += String.Format(" AND CUSTOMERNAME like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "blno"://NO
strCondition += String.Format(" AND ASSOCIATEDNO in (select bsno from VW_Settlement where MBLNO like '%{0}%')", strArg[1].Replace("\"", ""));
break;
case "goodsmodel":
strCondition += String.Format(" AND goodsmodel like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "GOODSSTANDARD":
strCondition += String.Format(" AND GOODSSTANDARD like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "wmsno"://入库单号
strCondition += String.Format(" AND INBSNO in (select GID from wms_in where BSNO like '%{0}%') ", strArg[1].Replace("\"", ""));
break;
case "store":
strCondition += String.Format(" AND STORAGENAME like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
else
{
if (!strbsno.Equals(null) && !strbsno.Equals(""))
{
strCondition += String.Format(" AND ASSOCIATEDNO = '{0}' ", strbsno);
}
//else
//{
// strCondition += " and 0>1";
//}
}
strCondition += " and CHARGEUNIT='CBM'";
string strAuthorityCondition = "";
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
//var headerArgs_wmsin = new Array("", "货主", "提单号", "入库单号", "入库日期", "开始计费日期", "等级", "品名", "品牌", "规格", "厚度", "宽度", "长度", "片数/件", "剩余件数", "剩余库存", "出库件数", "立方米", "应收出库费", "应付出库费", "车号", "备注", "仓库名称", "进口委托单号", "单件立方数", "原货主", "入库GID", "出库明细GID", "应付开始计费日期", "剩余件数_EDIT", "剩余库存_EDIT");
//板材明细_修改
strSql = String.Format(" SELECT GID,CUSTOMERNAME"
+ ",(select top 1 mblno from VW_Settlement where bsno=wms_out_detail.ASSOCIATEDNO) as BLNO"
+ ",(select top 1 BSNO from wms_in where GID=wms_out_detail.INBSNO) as WMSNO"
+ ",convert(char(10),(select top 1 DODATE from wms_in where gid=wms_out_detail.inbsno),120) as DODATE"
+ ",STARTBILLINGDATE=(select convert(char(10),STARTBILLINGDATE,120) as STARTBILLINGDATE from wms where gid=(select top 1 ASSOCIATEDNO from wms_in where gid=wms_out_detail.inbsno))"
+ ",GOODSGRADE,GOODSNAME,GOODSMODEL,GOODSSTANDARD"
+ ",(select top 1 GOODSTHICKNESS from wms_in where gid=wms_out_detail.inbsno) as GOODSTHICKNESS"
+ ",(select top 1 GOODSWIDTH from wms_in where gid=wms_out_detail.inbsno) as GOODSWIDTH"
+ ",(select top 1 GOODSLENGTH from wms_in where gid=wms_out_detail.inbsno) as GOODSLENGTH"
+ ",GOODSSLICE"
+ ",(select top 1 GOODSPACKSTOCK from wms_in where gid=wms_out_detail.inbsno) as GOODSPACKSTOCK"
+ ",(select top 1 GOODSSTOCK from wms_in where gid=wms_out_detail.inbsno) as GOODSSTOCK"
+ ",GOODSPACKPFSL,GOODSPFSL,ARFEE,APFEE,TRUCKNO,REMARK,STORAGENAME,ASSOCIATEDNO"
+ ",convert(numeric(18,4),isnull((GOODSPFSL/GOODSPACKPFSL),0)) as GOODSKGS,CLIENTNAMEOLD,inbsno,gid as wmsoutdetailgid "
+ ",STARTBILLINGDATEAP=(select convert(char(10),STARTBILLINGDATEAP,120) as STARTBILLINGDATEAP from wms where gid=(select top 1 ASSOCIATEDNO from wms_in where gid=wms_out_detail.inbsno))"
+ ",(select top 1 GOODSPACKSTOCK from wms_in where gid=wms_out_detail.inbsno)+GOODSPACKPFSL as GOODSPACKSTOCK_EDIT"
+ ",(select top 1 GOODSSTOCK from wms_in where gid=wms_out_detail.inbsno)+GOODSPFSL as GOODSSTOCK_EDIT"
+ " FROM wms_out_detail where 1=1 {0} {1} and outbsno='{2}'"
+ " ORDER BY BLNO,GOODSNAME,GOODSGRADE,GOODSSTANDARD,GOODSTHICKNESS,GOODSWIDTH,GOODSLENGTH,DODATE ", strAuthorityCondition, strCondition, strwmsoutbsno);
sourceTable = WmsInDA.GetExcuteSql(strSql).Tables[0];
sourceBuilder.Append("{");
sourceBuilder.Append("rows:[");
for (int i = 0; i < sourceTable.Rows.Count; i++)
{
sourceBuilder.Append("{id:\"" + sourceTable.Rows[i][0].ToString() + "\",");
sourceBuilder.Append("data:[");
sourceBuilder.Append("\"0\",");
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
string ls = sourceTable.Rows[i][j].ToString();
ls = ls.Replace("\r\n", " ");
ls = ls.Replace("\n", " ");
//
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + ls + "\"");
}
else
{
sourceBuilder.Append("\"" + ls + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region 删除仓储费用Wms_out、wms_out_detail、ch_fee 修改wms_in、fee_gain 并返回删除操作结果
/// <summary>
/// 删除仓储费用Wms_out、wms_out_detail、ch_fee 修改wms_in、fee_gain 并返回删除操作结果
/// </summary>
/// <param name="tempGid">出库单GID</param>
/// <returns>值1删除成功 值小于1删除失败</returns>
public int DeleteWmsOutByGid(string tempGid)
{
int result = 0;
string Sqlstr = "";
//string tempfeeGid;
//string tempCurrency;
//int tempFeeType;
//decimal tempAmount;
//decimal tempRate;
//string tempBSNO;
//出库单信息
WmsOutEntity wmsoutentity = new WmsOutEntity();
WmsOutDA wmsoutDA = new WmsOutDA();
//ch_fee处理
IList<FeeEntity> FeeEntities = new List<FeeEntity>();
FeeDA feeDA = new FeeDA();
//入库单处理:修改
WmsInEntity wmsinentity = new WmsInEntity();
WmsOutDetailDA wmsoutdetailDA = new WmsOutDetailDA();
DataSet DsWmsOutDetail = new DataSet();
DataTable DtWmsOutDetail = new DataTable();
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
//判断出库单相关的op_Seai是否锁定
wmsoutentity = wmsoutDA.GetModel(tempGid,"");//出库单信息
#region 删除ch_fee、fee_gain仓储费用
/*
//ch_fee处理
FeeEntities = feeDA.GetFeeByWmsOutBsno(wmsoutentity.BSNO);
foreach (FeeEntity feeEntity in FeeEntities)
{//逐行删除费用ch_fee
tempfeeGid = feeEntity.GID;
tempCurrency = feeEntity.Currency;
tempFeeType = feeEntity.FeeType;
tempAmount = feeEntity.Amount;
tempRate = feeEntity.ExchangeRate;
tempBSNO = feeEntity.BSNO;
if (feeEntity.FeeStatus == 1 || feeEntity.FeeStatus == 6)
{
//先将费用利润表中费用金额减兑
if (tempFeeType == 1)
{
if (tempCurrency == "RMB")
{
strSql = String.Format(" UPDATE fee_gain SET RMBDR = RMBDR - {0},DRTTL = DRTTL - {0},RMBPROFIT = RMBPROFIT - {0},TTLPROFIT = TTLPROFIT - {0} WHERE BSNO = '{1}' ", tempAmount, tempBSNO);
}
else
{
strSql = String.Format(" UPDATE fee_gain SET USDDR = USDDR - {0},DRTTL = DRTTL - {1},USDPROFIT = USDPROFIT - {0},TTLPROFIT = TTLPROFIT - {1} WHERE BSNO = '{2}' ", tempAmount, (tempAmount * tempRate), tempBSNO);
}
}
else
{
if (tempCurrency == "RMB")
{
strSql = String.Format(" UPDATE fee_gain SET RMBCR = RMBCR - {0},CRTTL = CRTTL - {0},RMBPROFIT = RMBPROFIT + {0},TTLPROFIT = TTLPROFIT + {0} WHERE BSNO = '{1}' ", tempAmount, tempBSNO);
}
else
{
strSql = String.Format(" UPDATE fee_gain SET USDCR = USDCR - {0},CRTTL = CRTTL - {1},USDPROFIT = USDPROFIT + {0},TTLPROFIT = TTLPROFIT + {1} WHERE BSNO = '{2}' ", tempAmount, (tempAmount * tempRate), tempBSNO);
}
}
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, strSql, null);
//重新计算百分率(利润总和/应付费用总和)
SqlParameter[] precentParms = new SqlParameter[] {
new SqlParameter(PARM_FEEPROFIT_BSNO,SqlDbType.VarChar,100)
};
precentParms[0].Value = tempBSNO;
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_UPDATE_FEE_PROFIT_PRECENT, precentParms);
SqlParameter parm = new SqlParameter(PARM_FEE_GID, SqlDbType.VarChar, 36);
parm.Value = tempfeeGid;
//从费用表ch_fee中将费用删除
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, SQL_DELETE_FEE_BY_GID, parm);
}
//else
//{
// result = -3;
// return result;
//}
}
*/
#endregion
//出库单明细列表
DsWmsOutDetail = wmsoutdetailDA.GetList(String.Format(" OUTBSNO='{0}' ", wmsoutentity.BSNO));
DtWmsOutDetail = DsWmsOutDetail.Tables[0];
foreach (DataRow routdetail in DtWmsOutDetail.Rows)
{
//入库单处理:修改
decimal GOODSPFSL = 0;
decimal GOODSPACKPFSL = 0;
string INBSNO = "";
GOODSPFSL= decimal.Parse(routdetail["GOODSPFSL"].ToString());
GOODSPACKPFSL = decimal.Parse(routdetail["GOODSPACKPFSL"].ToString().Equals(null) ? "0" : routdetail["GOODSPACKPFSL"].ToString());
INBSNO = routdetail["INBSNO"].ToString();
//明细表
Sqlstr = String.Format("update wms_in set GOODSSTOCK=GOODSSTOCK+{0},GOODSPACKSTOCK=GOODSPACKSTOCK+{1} where ISDELETE=0 and ISLOCK=1 and gid='{2}' ", GOODSPFSL, GOODSPACKPFSL, INBSNO);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
//主表
Sqlstr = String.Format("update wms set GOODSSTOCK=GOODSSTOCK+{0},GOODSPACKSTOCK=GOODSPACKSTOCK+{1} where ISDELETE=0 and ISLOCK=1 and gid=(select top 1 ASSOCIATEDNO from wms_in where gid='{2}') ", GOODSPFSL, GOODSPACKPFSL, INBSNO);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
Sqlstr = "";
}
//wms_out_detail处理删除
Sqlstr = String.Format("delete wms_out_detail where OUTBSNO='{0}' ", wmsoutentity.BSNO);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
//wms货权转移的费率处理删除
Sqlstr = String.Format("delete wms_rate where BSNO in (select ingidnew from wms_out where BSNO='{0}' and ISCHANGE = 1)", wmsoutentity.BSNO);//REMARK = '货权转移'
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
//wms货权转移处理删除
Sqlstr = String.Format("delete wms_in where ASSOCIATEDNO in (select ingidnew from wms_out where BSNO='{0}' and ISCHANGE = 1) ", wmsoutentity.BSNO);//REMARK = '货权转移'
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
//wms货权转移处理删除
Sqlstr = String.Format("delete wms where gid in (select ingidnew from wms_out where BSNO='{0}' and ISCHANGE = 1) ", wmsoutentity.BSNO);//REMARK = '货权转移'
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
//wms_out处理删除
Sqlstr = String.Format("delete wms_out where BSNO='{0}' ", wmsoutentity.BSNO);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
result = 1;//状态为1表示删除成功
sqlTran.Commit();
}
catch (Exception execError)
{
result = -1;//有异常,插入失败
sqlTran.Rollback();
result = -2;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
return result;
}
#endregion
//
}
}