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.SeaiInfoLCL
{
public partial class WmsRateLCLGridSource : 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 strCacheName;//Session 缓存名称
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";
T_ALL_DA T_ALL_DA = new T_ALL_DA();
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 == "getratelist" && strcustid != null && strcustid != "")
{ //根据INFO_CLIENT.GID返回VW_WmsRateList仓储费率列表信息JSON字符串
Response.Write(GetRateListJsonByCusID(strcustid));
return;
}
if (strHandle == "goodslist")
{ //获得货物信息
XmlDocument docs = GetDoc();
Response.ContentType = "text/xml";
Response.Write(docs.OuterXml.ToString());
return;
}
if (strHandle == "getratebycus" && strcustomer !=null && strcustomer != "")
{ //获得符合条件的费率信息
Response.Write(GetRateList("cus"));
return;
}
if (strHandle == "getratebysearch" && strSearch != null && strSearch != "")
{ //获得符合条件的费率信息
Response.Write(GetRateList("search"));
return;
}
if (strHandle == "deleterate" && strSearch !=null && strSearch != "")
{//DeleteWmsRateDtj
Response.Write(DeleteWmsRateDtj());
return;
}
if (strHandle == "deleterate" && strRateGid !=null && strRateGid != "")
{//DeleteWmsRateDtj
Response.Write(DeleteWmsRate(strRateGid));
return;
}
if (strHandle == "getrate" )
{//DeleteWmsRateDtj && strSearch !=null && strSearch != ""
Response.Write(GetRateBySearch(strbsno));
//string tmpjson = "{rows:[]}";
return;
}
if (strHandle == "wmsoutlist")
{//出库单列表
Response.Write(GetWmsOutListBySearch());
return;
}
if (strHandle == "wmsoutlistpage")
{//出库单列表
Response.Write(GetWmsOutLispagetBySearch());
return;
}
if (strHandle == "wmsinlist")
{//指定条件的入库单剩余库存信息
//if (strSearch == null || strSearch == "")
//{
// string tmpjson = "{rows:[]}";
// Response.Write(tmpjson);
// return;
//}
Response.Write(GetWmsInList());
return;
}
if (strHandle == "wmsoutdetaillist")
{//指定进口委托单位的出库明细 wmsoutdetaillist
Response.Write(Getwmsoutdetaillist());
}
//wmsfeecodelist
if (strHandle == "wmsfeecodelist")
{//指定进口委托单位的出库明细 wmsoutdetaillist
Response.Write(GetWmsFeeCodeList());
}
//deleteWmsFeeCode
if (strHandle == "deleteWmsFeeCode")
{//指定进口委托单位的出库明细 wmsoutdetaillist
Response.Write(DeleteWmsFeeCode(strRateGid));
}
if (strHandle == "deletewmsout")
{//
Response.Write(DeleteWmsOutByGid(strwmsoutgid));
}
if (strHandle == "WmsFeeQuery")
{//指定进口委托单位的出库明细 wmsoutdetaillist
Response.Write(GetWmsFeeQuery());
}
if (strHandle == "getWmsFeeAndFeeDays")
{ //返回计费天数和仓储费
Response.Write(getWmsFeeAndFeeDays(strbsno, outnums, feedays));
}
if (strHandle == "wmsoutexcel")
{ //返回导出excel的Sql语句
Response.Write(GetwmsoutexcelSql());
}
//
if (strHandle == "wmsoutlistexcel")
{ //返回导出excel的Sql语句
Response.Write(GetwmsoutlistexcelSql());
}
if (strHandle == "opseaifujian")
{ //获取附件信息
Response.Write(GetLogContent(iShowPage, iCurrentPage));
}
//
if (strHandle == "page")
{ //获取附件信息
Response.Write(GetPageInfo());
}
//
if (strHandle == "getfpk")
{ //获取附件信息
Response.Write(getfpk());
}
//
if (strHandle == "getfpk2")
{ //获取附件信息
Response.Write(getfpk2());
}
//
if (strHandle == "islock")
{ //入账信息
Response.Write(setislock());
}
if (strHandle == "notlock")
{ //取消入账信息
Response.Write(setnotlock());
}
if (strHandle == "getislock")
{ //判断是否入账信息
Response.Write(getislock());
}
if (strHandle == "getiswmsin")
{ //判断是否入账信息
Response.Write(getiswmsin());
}
}
#endregion
}
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.GOODSPFSL = i.GOODSRKSL AND o.GOODSPACKPFSL = i.GOODSPACK AND o.ISCHANGE = 1 and o.ASSOCIATEDNO like 'topseailcl%') 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 获取当前列表页合计信息
///
/// 获取费率信息
///
/// 返回JSON数据
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, "modSeaImportLCLList");
//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
#region 获取所有列表合计信息
///
/// 获取费率信息
///
/// 返回JSON数据
private string getfpk()
{
WmsRateDA WmsRateDA = new WmsRateDA();
DataTable sourceTable;
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 "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, "modSeaImportLCLList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
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 * from wms_out a where 1=1 {0} {1}) as z ", 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
#region 获取附件信息
///
/// 获取附件信息
///
///
///
///
private string GetLogContent(int tempShowPage, int tempCurPage)
{
LogDA logDA = new LogDA();
StringBuilder logBuilder = new StringBuilder();
string strSql = "";
string strTopInclude = "";
string strTopNotInclude = "";
if (tempShowPage > 0 && tempCurPage > 0)
{
if (tempCurPage == 1)
{
strSql = String.Format("SELECT {0} GID,AFFIXNAME+'^'+AFFIXURL URL,AFFIXNAME,AFFIXURL,LINKGID,AFFIXSIZE,TABLENAME FROM op_sailingdateurl where TABLENAME='{1}' and LINKGID='{2}' ORDER BY AFFIXNAME", "top " + tempShowPage, strtb, linkgid);
}
else
{
strTopNotInclude = "top " + (tempShowPage * (tempCurPage - 1));//RowCount*PageNum
strTopInclude = "top " + tempShowPage;//RowCount*PageNum
strSql = String.Format("SELECT GID,AFFIXNAME+'^'+AFFIXURL URL,AFFIXNAME,AFFIXURL,LINKGID,AFFIXSIZE,TABLENAME FROM (SELECT {1} GID,AFFIXNAME+'^'+AFFIXURL URL,AFFIXNAME,AFFIXURL,LINKGID,AFFIXSIZE,TABLENAME FROM op_sailingdateurl WHERE TABLENAME='{2}' and LINKGID='{3}' and GID NOT IN (SELECT {0} GID FROM op_sailingdateurl where TABLENAME='{2}' and LINKGID='{3}' ORDER BY AFFIXNAME ) ORDER BY AFFIXNAME) AS A ", strTopNotInclude, strTopInclude, strtb, linkgid);
}
}
else
{
strSql = String.Format("SELECT GID,AFFIXNAME+'^'+AFFIXURL URL,AFFIXNAME,AFFIXURL,LINKGID,AFFIXSIZE,TABLENAME FROM op_sailingdateurl where TABLENAME='{0}' and LINKGID='{1}' ", strtb, linkgid);
}
DataTable logTable = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, strSql).Tables[0];
logBuilder.Append("{");
logBuilder.Append("rows:[");
for (int i = 0; i < logTable.Rows.Count; i++)
{
logBuilder.Append("{id:\"" + logTable.Rows[i][0].ToString() + "\",");
logBuilder.Append("data:[");
logBuilder.Append("\"0\",");
for (int j = 1; j < logTable.Columns.Count; j++)
{
if (j == logTable.Columns.Count - 1)
{
logBuilder.Append("\"" + logTable.Rows[i][j].ToString() + "\"");
}
else
{
logBuilder.Append("\"" + logTable.Rows[i][j].ToString() + "\",");
}
}
if (i == logTable.Rows.Count - 1)
{
logBuilder.Append("]}");
}
else
{
logBuilder.Append("]},");
}
}
logBuilder.Append("]");
logBuilder.Append("}");
return logBuilder.ToString();
}
private int GetPageInfo()
{
LogDA logDA = new LogDA();
StringBuilder logBuilder = new StringBuilder();
string strSql = String.Format("SELECT COUNT(*) FROM op_sailingdateurl where TABLENAME='{0}' and LINKGID='{1}' ", strtb, linkgid);
int iTotal = logDA.GetPageTotal(strSql);
return iTotal;
}
#endregion
#region 返回导出excel的Sql语句
///
/// 返回导出excel的Sql语句
///
///
private string GetwmsoutexcelSql()
{
string strSql = "";
strSql = String.Format(" SELECT b.BLNO,a.INBSNO,a.OUTBSNO,a.CUSTOMERNAME,a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,convert(char(10),b.DODATE,20) INDATE,convert(char(10),a.DODATE,20) OUTDATE, "
+ " b.GOODSRKSL,b.GOODSSTOCK,b.GOODSPACKSTOCK,a.GOODSPACKPFSL,a.GOODSPFSL,a.GOODSOUTFEE, datediff(day,b.DODATE,a.DODATE)+1 days"
+",a.feedays"
//+",feedays= case when (datediff(day,b.DODATE,a.DODATE)+1-isnull(c.FEESCALE,0)) <=0 then 0 else datediff(day,b.DODATE,a.DODATE)+1-isnull(c.FEESCALE,0) end"
+",a.TRUCKNO, CREATEUSER=(select SHOWNAME from [user] where gid=a.CREATEUSER), a.CREATETIME, a.REMARK "
+ " FROM wms_out_detail a left outer join wms_in b on a.INBSNO=b.BSNO left outer join (select * from wms_rate where isnull(FEEGRADE,0)=1 and isnull(FEEPRICE,0)=0 ) as c on c.BSNO=a.ASSOCIATEDNO and c.customername=a.customername where b.ISDELETE=0 and a.ASSOCIATEDNO='{0}' and a.OUTBSNO='{1}' "
+ " ORDER BY a.bsno ", stropseaibsno, strwmsoutbsno);
//string sSQL = "";
//sSQL = String.Format(" SELECT GID,ASSOCIATEDNO,BSNO,CUSTOMERNAME,DODATE,STORAGENAME,AREANAME, "
// + " GOODSNAME,GOODSMODEL,GOODSPACKPFSL,GOODSPFSL,GOODSOUTFEE,TRUCKNO,REMARK, "
// + " CREATEUSER,CREATETIME,MODIFIEDUSER,MODIFIEDTIME "
// + " FROM wms_out where BSNO='{0}' ", strwmsoutbsno);
return strSql;
}
///
/// 返回导出excel的Sql语句
///
///
private string GetwmsoutlistexcelSql()
{
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 "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 like '%{0}%'", strArg[1].Replace("\"", ""));
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);
}
}
strSql = String.Format(" SELECT a.BSNO,a.CUSTOMERNAME,convert(char(10),a.DODATE,20),a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSOUTFEE,a.GOODSPACKPFSL,a.TRUCKNO,a.REMARK,CREATEUSER=(select SHOWNAME from [user] where gid=a.CREATEUSER),convert(char(19),a.CREATETIME,120) "//,a.ASSOCIATEDNO,isnull(c.CLIENTNAME,'') newcust "
+ " from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms_in c on b.INBSNO=c.BSNO "
+ " where c.ISDELETE=0 {0} ORDER BY a.GOODSNAME DESC ", strCondition);
return strSql;
}
#endregion
#region 返回计费天数和仓储费
///
/// 返回计费天数和仓储费
///
/// 委托单号
/// 出库数量
/// 仓储天数
///
private string getWmsFeeAndFeeDays(string bsno, decimal outnums, int feedays)
{
int nofeedays=0;
string Sqlstr = "";
decimal totaloutfee = 0;//出库单的仓储费
int prescale = 0;
int nowscale = 0;
int nowgrade = 0;
decimal price = 0;
decimal gradefee = 0;
decimal sumfee = 0;
Sqlstr = String.Format("SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT FROM wms_rate where BSNO='{0}' order by BSNO,FEEGRADE ", bsno);
DataSet dsrate = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, Sqlstr.ToString());
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;
if (price == 0)
{
nofeedays = feedays - nowscale;
}
}
else
{
gradefee = outnums * price * (feedays - prescale);
sumfee += gradefee;
prescale = nowscale;
if (price == 0)
{
nofeedays = 0;
}
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;
}
}
StringBuilder sourceBuilder = new StringBuilder();
sourceBuilder.Append("{");
sourceBuilder.Append("wmsfee:[");
sourceBuilder.Append("{bsno:\"" + bsno + "\",");
sourceBuilder.Append("\"jsdays\":\"" + nofeedays.ToString() + "\",");
sourceBuilder.Append("\"totaloutfee\":\"" + totaloutfee.ToString() + "\"");
sourceBuilder.Append("}");
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
#region GetWmsFeeQuery
///
///
///
///
private string GetWmsFeeQuery()
{
WmsFeeCodeDA WmsFeeCodeDA = new WmsFeeCodeDA();
DataTable sourceTable;
StringBuilder sourceBuilder = new StringBuilder();
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strSql = "";
string strAuthorityCondition = "";
string OutDate="";//= DateTime.Today.ToString("yyyy-MM-dd");//出库日期
bool isout=false;//是否包含已经出库的仓储费;
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 "cus"://CUSTOMER
strCondition += String.Format(" and CUSTOMERNAME like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "blno"://NO
strCondition += String.Format(" AND BLNO like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "customno"://NO
strCondition += String.Format(" AND CUSTOMNO like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "outdate":
OutDate = strArg[1].Replace("\"", "");
break;
case "isout":
isout = bool.Parse(strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
else
{
strCondition += " and 1<0 ";
}
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
//2013-04-10 之前的
/*
//if (iCurrentPage > 0 && iShowPage > 0)
//{
// if (iCurrentPage == 1)
// {
// if (isout)
// {
// strSql = String.Format(" SELECT {0} GID,CLIENTNAME, BLNO,BSNO,convert(char(10),DODATE,120) INDATE,'{3}' OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK, GOODSPACKSTOCK,0 GOODSPFSL,0 GOODSPACKPFSL,(datediff(day,DODATE,'{3}')+1) days,0 GOODSOUTFEE,REMARK, CREATEUSER=(select SHOWNAME from [user] where gid=CREATEUSER), CREATETIME,ASSOCIATEDNO,0 iswmsout "
// + " FROM wms_in where ISDELETE=0 and GOODSSTOCK>0 {1} {2} "
// + " union all "
// + " select {0} b.GID,b.CLIENTNAME,b.BLNO,b.BSNO,convert(char(10),b.DODATE,120) INDODATE,convert(char(10),a.DODATE,120) OUTDODATE,b.STORAGENAME,b.GOODSNAME,b.GOODSMODEL,0 GOODSSTOCK,0 GOODSPACKSTOCK,GOODSPFSL,GOODSPACKPFSL,(datediff(day,b.DODATE,a.DODATE)+1) days,GOODSOUTFEE,b.REMARK,CREATEUSER=(select SHOWNAME from [user] where gid=b.CREATEUSER),convert(char(19), b.CREATETIME,120),b.ASSOCIATEDNO,1 iswmsout "
// + " from wms_out_detail a inner join wms_in b on a.INBSNO=b.BSNO where b.ISDELETE=0 {1} {2} "
// + " ORDER BY CLIENTNAME,iswmsout,BLNO "
// , "top " + iShowPage.ToString(), strAuthorityCondition, strCondition, OutDate);
// }
// else
// {
// strSql = String.Format(" SELECT {0} GID,CLIENTNAME, BLNO,BSNO,convert(char(10),DODATE,120) INDATE,'{3}' OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK, GOODSPACKSTOCK,0 GOODSPFSL,0 GOODSPACKPFSL,(datediff(day,DODATE,'{3}')+1) days,0 GOODSOUTFEE,REMARK, CREATEUSER=(select SHOWNAME from [user] where gid=CREATEUSER), CREATETIME,ASSOCIATEDNO,0 iswmsout "
// + " FROM wms_in where ISDELETE=0 and GOODSSTOCK>0 {1} {2} ORDER BY CLIENTNAME,BLNO ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition, OutDate);
// }
// }
// else
// {
// strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
// strTopInclude = "top " + iShowPage.ToString();
// if (isout)
// {
// strSql = String.Format(" SELECT {0} GID,CLIENTNAME, BLNO,BSNO,convert(char(10),DODATE,120) INDATE,'{4}' OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK, GOODSPACKSTOCK,0 GOODSPFSL,0 GOODSPACKPFSL,(datediff(day,DODATE,'{4}')+1) days,0 GOODSOUTFEE,REMARK, CREATEUSER=(select SHOWNAME from [user] where gid=CREATEUSER), CREATETIME,ASSOCIATEDNO,0 iswmsout "
// + " FROM wms_in WHERE ISDELETE=0 and BSNO NOT IN "
// + " (SELECT {1} BSNO FROM wms_in WHERE ISDELETE=0 and GOODSSTOCK>0 {2} {3} ORDER BY CLIENTNAME,BLNO ) {2} {3} "
// + " union all "
// + " select {0} b.GID,b.CLIENTNAME,b.BLNO,b.BSNO,convert(char(10),b.DODATE,120) INDODATE,convert(char(10),a.DODATE,120) OUTDODATE,b.STORAGENAME,b.GOODSNAME,b.GOODSMODEL,0 GOODSSTOCK,0 GOODSPACKSTOCK,GOODSPFSL,GOODSPACKPFSL,(datediff(day,b.DODATE,a.DODATE)+1) days,GOODSOUTFEE,b.REMARK,CREATEUSER=(select SHOWNAME from [user] where gid=b.CREATEUSER),convert(char(19), b.CREATETIME,120),b.ASSOCIATEDNO,1 iswmsout "
// + " from wms_out_detail a inner join wms_in b on a.INBSNO=b.BSNO where b.ISDELETE=0 and b.BSNO NOT IN "
// + " (SELECT {1} BSNO FROM wms_in WHERE b.ISDELETE=0 and GOODSSTOCK>0 {2} {3} ORDER BY CLIENTNAME,BLNO ) {2} {3} "
// + " ORDER BY CLIENTNAME,iswmsout,BLNO ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition, OutDate);
// }
// else
// {
// strSql = String.Format(" SELECT {0} GID,CLIENTNAME, BLNO,BSNO,convert(char(10),DODATE,120) INDATE,'{4}' OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK, GOODSPACKSTOCK,0 GOODSPFSL,0 GOODSPACKPFSL,(datediff(day,DODATE,'{4}')+1) days,0 GOODSOUTFEE,REMARK, CREATEUSER=(select SHOWNAME from [user] where gid=CREATEUSER), CREATETIME,ASSOCIATEDNO,0 iswmsout "
// + " FROM wms_in WHERE ISDELETE=0 and BSNO NOT IN "
// + " (SELECT {1} BSNO FROM wms_in WHERE ISDELETE=0 and GOODSSTOCK>0 {2} {3} ORDER BY CLIENTNAME,BLNO ) {2} {3} "
// + " ORDER BY CLIENTNAME,iswmsout,BLNO ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition, OutDate);
// }
// }
//}
//else
//{
// if (isout)
// {
// strSql = String.Format(" SELECT GID,CLIENTNAME, BLNO,BSNO,convert(char(10),DODATE,120) INDATE,'{2}' OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK, GOODSPACKSTOCK,0 GOODSPFSL,0 GOODSPACKPFSL,(datediff(day,DODATE,'{2}')+1) days,0 GOODSOUTFEE,REMARK, CREATEUSER=(select SHOWNAME from [user] where gid=CREATEUSER), CREATETIME,ASSOCIATEDNO,0 iswmsout "
// + " FROM wms_in where ISDELETE=0 and GOODSSTOCK>0 {0} {1} "
// + " union all "
// + " select b.GID,b.CLIENTNAME,b.BLNO,b.BSNO,convert(char(10),b.DODATE,120) INDODATE,convert(char(10),a.DODATE,120) OUTDODATE,b.STORAGENAME,b.GOODSNAME,b.GOODSMODEL,0 GOODSSTOCK,0 GOODSPACKSTOCK,GOODSPFSL,GOODSPACKPFSL,(datediff(day,b.DODATE,a.DODATE)+1) days,GOODSOUTFEE,b.REMARK,CREATEUSER=(select SHOWNAME from [user] where gid=b.CREATEUSER),convert(char(19), b.CREATETIME,120),b.ASSOCIATEDNO,1 iswmsout "
// + " from wms_out_detail a inner join wms_in b on a.INBSNO=b.BSNO where ISDELETE=0 {0} {1} "
// + " ORDER BY CLIENTNAME,iswmsout,BLNO ", strAuthorityCondition, strCondition, OutDate);
// }
// else
// {
// strSql = String.Format(" SELECT GID,CLIENTNAME, BLNO,BSNO,convert(char(10),DODATE,120) INDATE,'{2}' OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK, GOODSPACKSTOCK,0 GOODSPFSL,0 GOODSPACKPFSL,(datediff(day,DODATE,'{2}')+1) days,0 GOODSOUTFEE,REMARK, CREATEUSER=(select SHOWNAME from [user] where gid=CREATEUSER), CREATETIME,ASSOCIATEDNO,0 iswmsout "
// + " FROM wms_in where ISDELETE=0 and GOODSSTOCK>0 {0} {1} "
// + " ORDER BY CLIENTNAME,BLNO ", strAuthorityCondition, strCondition, OutDate);
// }
//}
*/
if (strSearch != null)
{
#region 按计费日期计算仓储费用插入临时表
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
int iState = 0;
int result = 0;
string Sqlstr = "";
decimal totaloutfee = 0;//出库单的仓储费
int prescale = 0;
int nowscale = 0;
int nowgrade = 0;
decimal price = 0;
decimal gradefee = 0;
decimal sumfee = 0;
//
try
{
//Sqlstr = String.Format("SELECT *, ISNULL((SELECT CUSTOMNO FROM wms_out WHERE (BSNO=(SELECT TOP (1) OUTBSNO FROM wms_out_detail WHERE (INBSNO = a.GID)))), '') AS CUSTOMNO,0 ISWMSOUT,convert(char(10),WMSDATE,120) INDATE,'{2}' OUTDATE,(DATEDIFF(day, convert(char(10),WMSDATE,120), '{2}') + 1) as WMSDAYS,(case when (select ((DATEDIFF(day, convert(char(10),wms.WMSDATE,120), '{2}') + 1)-FEESCALE) as FEEDAYS from wms_rate where bsno=wms.gid and isnull(FEEPRICE,0)=0)<=0 then 0 else (select ((DATEDIFF(day, convert(char(10),wms.WMSDATE,120), '{2}') + 1)-FEESCALE) as FEEDAYS from wms_rate where bsno=wms.gid and isnull(FEEPRICE,0)=0) end) as FEEDAYS FROM wms where isnull(ISDELETE,0)=0 and isnull(GOODSSTOCK,0)>0 and convert(char(10),WMSDATE,120)<=convert(char(10),'{2}',120) {0} {1} ORDER BY CUSTOMERNAME,BLNO ", strAuthorityCondition, strCondition, OutDate);
Sqlstr = String.Format("select GID,CUSTOMERNAME,BLNO,GOODSSTOCK,WMSDAYS from (SELECT *, ISNULL((SELECT CUSTOMNO FROM wms_out WHERE (BSNO=(SELECT TOP (1) OUTBSNO FROM wms_out_detail WHERE (INBSNO = wms.GID)))), '') AS CUSTOMNO,(DATEDIFF(day, convert(char(10),WMSDATE,120), '{2}') + 1) as WMSDAYS FROM wms where isnull(ISDELETE,0)=0 and isnull(GOODSSTOCK,0)>0 and convert(char(10),WMSDATE,120)<=convert(char(10),'{2}',120) {0} ) as a where 1=1 {1} ORDER BY CUSTOMERNAME,BLNO ", strAuthorityCondition, strCondition, OutDate);
DataSet ds = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr, null);
if (ds != null)
{
//strUserID
Sqlstr = "delete from wms_wmsrate_test where CREATEUSER='" + strUserID + "' and CORPID2='" + strCompanyID + "'";
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
if (iState < 0)
{
sqlTran.Rollback();
result = -3;
}
//
foreach (DataRow dr in ds.Tables[0].Rows)
{
#region 按计费日期计算仓储费用
decimal outnums = decimal.Parse(dr["GOODSSTOCK"].ToString().Trim());//库存量
int feedays = int.Parse(dr["WMSDAYS"].ToString().Trim());
if (feedays > 0)
{
Sqlstr = "SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT FROM wms_rate where BSNO='" + dr["GID"].ToString().Trim() + "' and CUSTOMERNAME like '%" + dr["CUSTOMERNAME"].ToString().Trim() + "%' order by BSNO,FEEGRADE ";
DataSet dsrate = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr, null);
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);//出库量*收费单价*(仓储天数-上一个收费区间(0))
sumfee += gradefee;
prescale = nowscale;//本次收费区间
break;
}
}
else if (nowgrade > 1)//收费等级
{
if (feedays > nowscale)
{
gradefee = outnums * price * (nowscale - prescale);//出库量*收费单价*(收费区间-上一个收费区间(0))
sumfee += gradefee;
prescale = nowscale;//本次收费区间
}
else
{
gradefee = outnums * price * (feedays - prescale);//出库量*收费单价*(仓储天数-上一个收费区间(0))
sumfee += gradefee;
prescale = nowscale;//本次收费区间
break;
}
}
}
if (feedays > nowscale)
{
gradefee = outnums * price * (feedays - nowscale);//出库量*收费单价*(仓储天数-收费区间(0))
sumfee += gradefee;
}
totaloutfee += sumfee;
sumfee = T_ALL_DA.getDigit(sumfee, 2);
}
}
}
#endregion
//
Sqlstr = String.Format("insert into wms_wmsrate_test(WMSNO,INDATE,OUTDATE,ASSOCIATEDNO,BLNO,CUSTOMERNAME,STORAGENAME,GOODSNAME,GOODSMODEL,CHARGEUNIT,GOODSPACK,GOODSPACKSTOCK,GOODSRKSL,GOODSSTOCK,ARFEE,APFEE,MODIFIEDUSER,MODIFIEDTIME,ISLOCK,CORPID,CUSTOMNO,WMSDAYS,FEEDAYS,GOODSOUTFEE,ISWMSOUT,CREATEUSER,CREATETIME,CORPID2) "
+ " select WMSNO,convert(char(10),WMSDATE,120) INDATE,'{2}' OUTDATE,ASSOCIATEDNO,BLNO,CUSTOMERNAME,STORAGENAME,GOODSNAME,GOODSMODEL,CHARGEUNIT,isnull(GOODSPACK,0) as GOODSPACK,isnull(GOODSPACKSTOCK,0) as GOODSPACKSTOCK,isnull(GOODSRKSL,0) as GOODSRKSL,isnull(GOODSSTOCK,0) as GOODSSTOCK,isnull(ARFEE,0) as ARFEE,isnull(APFEE,0) as APFEE,(SELECT SHOWNAME FROM [user] WHERE GID = MODIFIEDUSER) AS MODIFIEDUSER,MODIFIEDTIME,ISLOCK,CORPID,ISNULL((SELECT CUSTOMNO FROM wms_out WHERE (BSNO=(SELECT TOP (1) OUTBSNO FROM wms_out_detail WHERE (INBSNO = wms.GID)))), '') AS CUSTOMNO,(DATEDIFF(day, convert(char(10),WMSDATE,120), '{2}') + 1) as WMSDAYS"
+ ",ISNULL((SELECT TOP (1) FEEDAYS FROM wms_out_detail WHERE (INBSNO = wms.GID)), '0') AS FEEDAYS"
//+",(case when (select ((DATEDIFF(day, convert(char(10),wms.WMSDATE,120), '{2}') + 1)-FEESCALE) as FEEDAYS from wms_rate where bsno=wms.gid and isnull(FEEPRICE,0)=0)<=0 then 0 else (select ((DATEDIFF(day, convert(char(10),wms.WMSDATE,120), '{2}') + 1)-FEESCALE) as FEEDAYS from wms_rate where bsno=wms.gid and isnull(FEEPRICE,0)=0) end) as FEEDAYS"
+",{3} as GOODSOUTFEE,0 ISWMSOUT,'1BEC90E1-9780-472F-90C2-0C6390C044A4' as CREATEUSER,getdate() as CREATETIME,'Comcab2d43f60454327af30a131fc1d3abd' as CORPID2 from wms where isnull(ISDELETE,0)=0 and isnull(GOODSSTOCK,0)>0 and convert(char(10),WMSDATE,120)<=convert(char(10),'{2}',120) and GID='" + dr["GID"].ToString().Trim() + "' {0} {1} ", strAuthorityCondition, strCondition, OutDate, sumfee);
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
if (iState != 1)
{
sqlTran.Rollback();
result = -4;
}
}
}
result = 1;//状态为1表示删除成功
sqlTran.Commit();
}
catch (Exception execError)
{
result = -10;//有异常,插入失败
sqlTran.Rollback();
result = -11;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
#endregion
}
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
//("", "货主", "提单号", "备案清单号", "入库单号", "入库日期", "出库日期", "仓库名称", "品名", "型号", "剩余库存", "剩余件数", "仓储天数", "计费天数", "仓储费", "开单人", "开单时间", "进口委托单号", "是否有出库单");
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} GID,CUSTOMERNAME,BLNO,CUSTOMNO,WMSNO,convert(char(10),INDATE,120) INDATE,convert(char(10),OUTDATE,120) OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK,GOODSPACKSTOCK,WMSDAYS,FEEDAYS,GOODSOUTFEE,MODIFIEDUSER,MODIFIEDTIME,ASSOCIATEDNO,ISWMSOUT "
+ " FROM wms_wmsrate_test where CREATEUSER='" + strUserID + "' and CORPID2='" + strCompanyID + "' ORDER BY CUSTOMERNAME,BLNO ", "top " + iShowPage.ToString());
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} GID,CUSTOMERNAME,BLNO,CUSTOMNO,WMSNO,convert(char(10),INDATE,120) INDATE,convert(char(10),OUTDATE,120) OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK,GOODSPACKSTOCK,WMSDAYS,FEEDAYS,GOODSOUTFEE,MODIFIEDUSER,MODIFIEDTIME,ASSOCIATEDNO,0 ISWMSOUT "
+ " FROM wms_wmsrate_test WHERE BSNO NOT IN "
+ " (SELECT {1} BSNO FROM wms_wmsrate_test where CREATEUSER='" + strUserID + "' and CORPID2='" + strCompanyID + "' ORDER BY CUSTOMERNAME,BLNO ) CREATEUSER='" + strUserID + "' and CORPID2='" + strCompanyID + "'"
+ " ORDER BY CUSTOMERNAME,iswmsout,BLNO ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = "SELECT GID,CUSTOMERNAME,BLNO,CUSTOMNO,WMSNO,convert(char(10),INDATE,120) INDATE,convert(char(10),OUTDATE,120) OUTDATE,STORAGENAME,GOODSNAME,GOODSMODEL,GOODSSTOCK,GOODSPACKSTOCK,WMSDAYS,FEEDAYS,GOODSOUTFEE,MODIFIEDUSER,MODIFIEDTIME,ASSOCIATEDNO,0 ISWMSOUT FROM wms_wmsrate_test where 1<0 ";
}
sourceTable = WmsFeeCodeDA.GetRateListByCondition(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\",");
/*
//string bsno = sourceTable.Rows[i]["ASSOCIATEDNO"].ToString();
//decimal outnums = 0;
//int days = 0;
//int nofeedays = 0;
//decimal wmsfee = 0;
//int iswmsout = int.Parse(sourceTable.Rows[i]["iswmsout"].ToString());
//if (iswmsout==0)
//{
// outnums = decimal.Parse(sourceTable.Rows[i]["GOODSSTOCK"].ToString());
// days = int.Parse(sourceTable.Rows[i]["days"].ToString());
// nofeedays = 0;
// wmsfee = 0;
// wmsfee = GetWmsFee(bsno, outnums, days, ref nofeedays);
//}
//else if (iswmsout==1)
//{
// days = int.Parse(sourceTable.Rows[i]["days"].ToString());
// nofeedays = GetWmsFeeDays(bsno, days);
//}
//for (int j = 1; j < sourceTable.Columns.Count; j++)
//{
// if (j == sourceTable.Columns.Count - 1)
// {
// sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
// }
// else
// {
// if (iswmsout==0)
// {
// if (sourceTable.Columns[j].ColumnName.ToString().Equals("GOODSOUTFEE"))
// {
// sourceBuilder.Append("\"" + nofeedays.ToString() + "\",");
// sourceBuilder.Append("\"" + wmsfee.ToString() + "\",");
// }
// else
// {
// sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
// }
// }
// else if (iswmsout==1)
// {
// if (sourceTable.Columns[j].ColumnName.ToString().Equals("GOODSOUTFEE"))
// {
// sourceBuilder.Append("\"" + nofeedays.ToString() + "\",");
// }
// sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
// }
// }
//}
*/
for (int j = 1; j < sourceTable.Columns.Count; j++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
private int GetWmsFeeDays(string bsno, int feedays)
{
string Sqlstr = "";
int nowscale = 0;
int nowgrade = 0;
decimal price = 0;
int nofeedays = 0;//计费天数
Sqlstr = String.Format("SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT FROM wms_rate where BSNO='{0}' order by BSNO,FEEGRADE ", bsno);
DataSet dsrate = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, Sqlstr.ToString());
DataTable dtrate = new DataTable();
if (dsrate != null)
{
dtrate = dsrate.Tables[0];
if (dtrate.Rows.Count > 0)
{
nowscale = 0;
nowgrade = 0;
price = 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)
{
if (price == 0)
{
nofeedays = feedays - nowscale;
}
break;
}
else
{
if (price == 0)
{
nofeedays = 0;
}
break;
}
}
}
}
}
return nofeedays;
}
private decimal GetWmsFee(string bsno, decimal outnums, int feedays,ref int nofeedays)
{
string Sqlstr = "";
decimal totaloutfee = 0;//出库单的仓储费
int prescale = 0;
int nowscale = 0;
int nowgrade = 0;
decimal price = 0;
decimal gradefee = 0;
decimal sumfee = 0;
Sqlstr = String.Format("SELECT FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT FROM wms_rate where BSNO='{0}' order by BSNO,FEEGRADE ", bsno);
DataSet dsrate = SqlHelper.ExecuteDataset(SqlHelper.ConnectionStringLocalTransaction, CommandType.Text, Sqlstr.ToString());
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;
if (price == 0)
{
nofeedays = feedays - nowscale;
}
}
else
{
gradefee = outnums * price * (feedays - prescale);
sumfee += gradefee;
prescale = nowscale;
if (price == 0)
{
nofeedays = 0;
}
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;
}
}
return totaloutfee;
}
private string GetWmsFeeCodeList()
{
WmsFeeCodeDA WmsFeeCodeDA = new WmsFeeCodeDA();
DataTable sourceTable;
StringBuilder sourceBuilder = new StringBuilder();
//string strCondition = "";
//string strTopInclude = "";
//string strTopNotInclude = "";
string strSql = "";
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
//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 {0} BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK "
// + " FROM wms_in where 1>0 {1} {2} ORDER BY BLNO,GOODSNAME,DODATE ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
// }
// else
// {
// strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
// strTopInclude = "top " + iShowPage.ToString();
// strSql = String.Format(" SELECT {0} BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK "
// + " FROM wms_in WHERE BSNO NOT IN "
// + " (SELECT {1} BSNO FROM wms_in WHERE 1>0 {2} {3} ORDER BY BLNO,GOODSNAME,DODATE ) {2} {3} "
// + " ORDER BY BLNO,GOODSNAME,DODATE ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
// }
//}
//else
//{
// strSql = String.Format(" SELECT BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK"
// + " FROM wms_in where 1>0 {0} {1} "
// + " ORDER BY BLNO,GOODSNAME,DODATE ", strAuthorityCondition, strCondition);
//}
//strSql = String.Format(" SELECT a.BSNO,a.BLNO,convert(char(10),a.DODATE,120) DODATE,a.GOODSNAME,a.GOODSMODEL,a.GOODSSTOCK,isnull(b.GOODSPFSL,0) GOODSPFSL,isnull(b.TRUCKNO,'') TRUCKNO,isnull(b.REMARK,'') REMARK,a.STORAGENAME "
// + " FROM wms_in a left outer join wms_out_detail b on a.bsno=b.INBSNO where 1>0 {0} {1} "
// + " ORDER BY a.BLNO,a.GOODSNAME,a.DODATE ", strAuthorityCondition, strCondition);
strSql = String.Format(" SELECT GID,UNITPRICE,REMARK,CREATEUSER,CREATETIME "
+ " FROM wms_feeCode where BSNO='{0}' {1} "
+ " ORDER BY FEETYPE,FEENAME ", strbsno, strAuthorityCondition);
sourceTable = WmsFeeCodeDA.GetRateListByCondition(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();
}
#region Getwmsoutdetaillist`
///
/// Getwmsoutdetaillist
///
///
private string Getwmsoutdetaillist()
{
WmsInDA WmsInDA = new WmsInDA();
DataTable sourceTable;
StringBuilder sourceBuilder = new StringBuilder();
//string strCondition = "";
//string strTopInclude = "";
//string strTopNotInclude = "";
string strSql = "";
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
//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 {0} BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK "
// + " FROM wms_in where 1>0 {1} {2} ORDER BY BLNO,GOODSNAME,DODATE ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
// }
// else
// {
// strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
// strTopInclude = "top " + iShowPage.ToString();
// strSql = String.Format(" SELECT {0} BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK "
// + " FROM wms_in WHERE BSNO NOT IN "
// + " (SELECT {1} BSNO FROM wms_in WHERE 1>0 {2} {3} ORDER BY BLNO,GOODSNAME,DODATE ) {2} {3} "
// + " ORDER BY BLNO,GOODSNAME,DODATE ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
// }
//}
//else
//{
// strSql = String.Format(" SELECT BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK"
// + " FROM wms_in where 1>0 {0} {1} "
// + " ORDER BY BLNO,GOODSNAME,DODATE ", strAuthorityCondition, strCondition);
//}
//strSql = String.Format(" SELECT a.BSNO,a.BLNO,convert(char(10),a.DODATE,120) DODATE,a.GOODSNAME,a.GOODSMODEL,a.GOODSSTOCK,isnull(b.GOODSPFSL,0) GOODSPFSL,isnull(b.TRUCKNO,'') TRUCKNO,isnull(b.REMARK,'') REMARK,a.STORAGENAME "
// + " FROM wms_in a left outer join wms_out_detail b on a.bsno=b.INBSNO where 1>0 {0} {1} "
// + " ORDER BY a.BLNO,a.GOODSNAME,a.DODATE ", strAuthorityCondition, strCondition);
//"","提单号","入库单号","出库单号","转移对象","仓库名称","品名","型号","入库日期","出库日期"
//,"入库数量","剩余库存","剩余件数","本次出库","仓储费","仓储天数","车号","制单人","制单时间","备注"
//strSql = String.Format(" SELECT a.GID,b.BLNO,a.INBSNO,a.OUTBSNO,a.CUSTOMERNAME,a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,convert(char(10),b.DODATE,20) INDATE,convert(char(10),a.DODATE,20) OUTDATE, "
// + " b.GOODSRKSL,b.GOODSSTOCK,b.GOODSPACKSTOCK,a.GOODSPACKPFSL,a.GOODSPFSL,a.ARFEE,a.APFEE,a.GOODSOUTFEE,a.GOODSOUTFEEAP "
// + ",datediff(day,b.DODATE,a.DODATE)+1 days,feedays= case when (datediff(day,b.DODATE,a.DODATE)+1-isnull(c.FEESCALE,0)) <=0 then 0 else datediff(day,b.DODATE,a.DODATE)+1-isnull(c.FEESCALE,0) end,a.TRUCKNO, a.CREATEUSER, a.CREATETIME, a.REMARK "
// + " FROM wms_out_detail a left outer join wms_in b on a.INBSNO=b.BSNO left outer join (select * from wms_rate where isnull(FEEGRADE,0)=1 and isnull(FEEPRICE,0)=0 ) as c on c.BSNO=a.ASSOCIATEDNO and c.customername=a.customername where b.ISLOCK=1 and b.ISDELETE=0 and a.ASSOCIATEDNO='{0}' and a.OUTBSNO='{1}' {2} "
// + " ORDER BY a.bsno ", stropseaibsno, strwmsoutbsno, strAuthorityCondition);
//strSql = String.Format(" SELECT a.GID,b.BLNO,b.WMSNO,a.OUTBSNO,a.CLIENTNAMEOLD,a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,convert(char(10),b.WMSDATE,20) INDATE,convert(char(10),a.DODATE,20) OUTDATE, b.GOODSRKSL,b.GOODSSTOCK,b.GOODSPACKSTOCK,a.GOODSPACKPFSL,a.GOODSPFSL,a.ARFEE,a.APFEE,a.GOODSOUTFEE,a.GOODSOUTFEEAP,datediff(day,b.WMSDATE,a.DODATE)+1 days,feedays= case when (datediff(day,b.WMSDATE,a.DODATE)+1-isnull(c.FEESCALE,0)) <=0 then 0 else datediff(day,b.WMSDATE,a.DODATE)+1-isnull(c.FEESCALE,0) end,a.TRUCKNO, CREATEUSER=(select SHOWNAME from [user] where gid=a.CREATEUSER), a.CREATETIME, a.REMARK "//,a.CUSTOMERNAME
// + " FROM wms_out_detail a left outer join wms b on a.INBSNO=b.GID left outer join (select * from wms_rate where isnull(FEEGRADE,0)=1 and isnull(FEEPRICE,0)=0 ) as c on c.BSNO=a.ASSOCIATEDNO and c.customername=a.customername where b.ISLOCK=1 and b.ISDELETE=0 and a.ASSOCIATEDNO='{0}' and a.OUTBSNO='{1}' {2} "
// + " ORDER BY a.bsno ", stropseaibsno, strwmsoutbsno, 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
//"出库件数", "出库数量", "应收出库费", "应付出库费", "应收仓储费", "应付仓储费", "仓储天数", "计费天数", "车号", "制单人", "制单时间", "备注");
strSql = String.Format(" SELECT a.GID,b.BLNO,b.WMSNO,a.OUTBSNO,a.CLIENTNAMEOLD,c.TRUCKNAME,a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,convert(char(10),b.WMSDATE,20) INDATE,convert(char(10),a.DODATE,20) OUTDATE, b.GOODSRKSL,b.GOODSSTOCK,b.GOODSPACKSTOCK,a.GOODSPACKPFSL,a.GOODSPFSL,a.ARFEE,a.APFEE,a.GOODSOUTFEE,a.GOODSOUTFEEAP,days=(datediff(day,b.WMSDATE,a.DODATE)+1)"
+ ",a.feedays"
//+",feedays=(datediff(day,b.WMSDATE,c.OLDCUSTFEEDATE)+1)"
+",a.TRUCKNO, CREATEUSER=(select SHOWNAME from [user] where gid=a.CREATEUSER), a.CREATETIME, a.REMARK "//,a.CUSTOMERNAME
+ " FROM wms_out_detail a left outer join wms b on a.INBSNO=b.GID left outer join wms_out as c on a.OUTBSNO=c.BSNO where b.ISLOCK=1 and b.ISDELETE=0 and a.ASSOCIATEDNO='{0}' and a.OUTBSNO='{1}' {2} "
+ " ORDER BY a.bsno ", stropseaibsno, strwmsoutbsno, strAuthorityCondition);
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
///
/// 出库合计数
///
///
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();
}
#region 根据INFO_CLIENT.GID返回VW_WmsRateList仓储费率列表信息JSON字符串
///
/// 根据INFO_CLIENT.GID返回VW_WmsRateList仓储费率列表信息JSON字符串
///
/// 返回VW_WmsRateList仓储费率列表信息JSON字符串
public string GetRateListJsonByCusID(string strcustid)
{
string strSql = "";
WmsRateDA WmsRateDA = new WmsRateDA();
DataTable sourceTable;
strSql =String.Format ( " SELECT (newid()) GID,CUSTOMERNAME, CONTRACTNO, STARTTIME, ENDTIME, GOODSNAME FROM VW_WmsRateList "
+ " where CUSTOMERNAME in (select SHORTNAME from info_client where gid='{0}')"
+" order by CUSTOMERNAME,CONTRACTNO",strcustid);
sourceTable = WmsRateDA.GetExcuteSql(strSql).Tables[0];
StringBuilder sourceBuilder = new StringBuilder();
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++)
{
if (j == sourceTable.Columns.Count - 1)
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\"");
}
else
{
sourceBuilder.Append("\"" + sourceTable.Rows[i][j].ToString() + "\",");
}
}
if (i == sourceTable.Rows.Count - 1)
{
sourceBuilder.Append("]}");
}
else
{
sourceBuilder.Append("]},");
}
}
sourceBuilder.Append("]");
sourceBuilder.Append("}");
return sourceBuilder.ToString();
}
#endregion
public string BuildXML()
{
string strMark="0";
int iPos = 0;
StringBuilder resultBuilder = new StringBuilder();
resultBuilder.Append("");
resultBuilder.AppendFormat("", 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("", dr["GOODCODE"].ToString().Trim(), js);//dr["GOODNAME"].ToString().Trim());
}
}
}
}
resultBuilder.AppendFormat("", "", "");
resultBuilder.Append("");
return resultBuilder.ToString().Replace("&", "&");
}
public XmlDocument GetDoc()
{
XmlDocument xmldoc = new XmlDocument();
string content = BuildXML();
try
{
xmldoc.LoadXml(content);
}
catch (Exception)
{
}
return xmldoc;
}
#region 获取费率信息
///
/// 获取费率信息
///
/// 返回JSON数据
private string GetRateBySearch(string strSearch)
{
WmsRateDA WmsRateDA = new WmsRateDA();
DataTable sourceTable;
StringBuilder sourceBuilder = new StringBuilder();
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strSql = "";
TopSeaiEntity topseaientity = new TopSeaiEntity();
SeaImportInfoDA opseaiDA = new SeaImportInfoDA();
topseaientity = opseaiDA.GetID(strbsno);
string customername = "";
if (!strcustomer.Equals(""))
{
customername = strcustomer;
}
else
{
if (topseaientity != null)
{
customername = topseaientity.CUSTOMERNAME;
}
}
strCondition += String.Format(" and BSNO='{0}' and CUSTOMERNAME like '%{1}%' ", strbsno, customername);
//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 STARTTIME = '{0}' ", strArg[1].Replace("\"", ""));
// break;
// case "et"://ETD EndDate
// strCondition += String.Format(" AND ENDTIME = '{0}' ", strArg[1].Replace("\"", ""));
// break;
// case "cusid"://CUSTOMER
// strCondition += String.Format(" AND CLIENTGID = '{0}' ", strArg[1].Replace("\"", ""));
// break;
// case "no"://NO
// strCondition += String.Format(" AND CONTRACTNO = '{0}'", strArg[1].Replace("\"", ""));
// break;
// case "goods":
// strCondition += String.Format(" AND GOODSNAME like '%{0}%' ", strArg[1].Replace("\"", ""));
// break;
// default:
// break;
// }
// }
// }
// }
//}
//else
//{
// strCondition += " and 0>1";
//}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
//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 {0} GID,FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT,REMARK,CREATEUSER,MODIFIEDTIME,BSNO "
+ " FROM wms_rate where 1>0 {1} {2} ORDER BY FEEGRADE ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} GID,FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT,REMARK,CREATEUSER,MODIFIEDTIME,BSNO "
+ " FROM wms_rate WHERE GID NOT IN "
+ " (SELECT {1} GID FROM wms_rate WHERE 1>0 {2} {3} ORDER BY FEEGRADE ) {2} {3} "
+ " ORDER BY FEEGRADE ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
}
}
else
{
strSql = String.Format(" SELECT GID,FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT,REMARK,CREATEUSER,MODIFIEDTIME,BSNO"
+ " FROM wms_rate where 1>0 {0} {1} "
+ " ORDER BY FEEGRADE ", strAuthorityCondition, strCondition);
}
sourceTable = WmsRateDA.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 获取费率信息
///
/// 获取费率信息
///
/// 返回JSON数据
private string GetRateList( string mode)
{
WmsRateDA WmsRateDA =new WmsRateDA();
DataTable sourceTable;
StringBuilder sourceBuilder = new StringBuilder();
string strCondition = "";
string strTopInclude = "";
string strTopNotInclude = "";
string strSql = "";
switch(mode)
{
case "search":
if (strSearch != null)
{
if (!strSearch.Trim().Equals(""))
{
if (strCacheName != null)
{
if (Session[strCacheName] != null)
{
Session.Remove(strCacheName);
}
}
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 STARTTIME >= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "et"://ETD EndDate
strCondition += String.Format(" AND ENDTIME <= '{0}' ", strArg[1].Replace("\"", ""));
break;
case "cusid"://CUSTOMER
strCondition += String.Format(" AND CLIENTGID = '{0}' ", strArg[1].Replace("\"", ""));
break;
case "no"://NO
strCondition += String.Format(" AND CONTRACTNO = '{0}'", strArg[1].Replace("\"", ""));
break;
case "goods":
strCondition += String.Format(" AND GOODSNAME like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
default:
break;
}
}
}
}
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
//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 {0} GID,GOODSNAME,FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT,REMARK,CREATEUSER,MODIFIEDTIME "
+ " FROM wms_rate where 1>0 {1} {2} ORDER BY GOODSNAME DESC ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} GID,GOODSNAME,FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT,REMARK,CREATEUSER,MODIFIEDTIME "
+ " FROM wms_rate WHERE GID NOT IN "
+ " (SELECT {1} GID FROM wms_rate WHERE 1>0 {2} {3} ORDER BY GOODSNAME DESC ) {2} {3} "
+ " ORDER BY GOODSNAME DESC ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
}
}
else
{
strSql = String.Format(" SELECT GID,GOODSNAME,FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT,REMARK,CREATEUSER,MODIFIEDTIME"
+ " FROM wms_rate where 1>0 {0} {1} "
+ " ORDER BY GOODSNAME DESC ", strAuthorityCondition, strCondition);
}
sourceTable = WmsRateDA.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("}");
break;
case "cus":
strSql = String.Format(" SELECT GID,GOODSNAME,FEEGRADE,FEESCALE,FEEPRICE,FEEUNIT,REMARK,CREATEUSER,MODIFIEDTIME FROM wms_rate where CUSTOMERNAME='{0}'", strcustomer);
sourceTable = WmsRateDA.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("}");
break;
}
return sourceBuilder.ToString();
}
#endregion
# region 删除仓储费率(Wms_Feecode),并返回删除操作结果
///
/// 删除仓储费率,并返回删除操作结果
///
///
/// 返回删除操作结果
private bool DeleteWmsFeeCode(string strRateGid)
{
bool iResult = false;
WmsFeeCodeDA WmsFeeCodeDA = new WmsFeeCodeDA();
iResult = WmsFeeCodeDA.Delete(strRateGid);
return iResult;
}
#endregion
# region 删除仓储费率(Wms_rate),并返回删除操作结果
///
/// 删除仓储费率,并返回删除操作结果
///
///
/// 返回删除操作结果
private bool DeleteWmsRate(string strRateGid)
{
bool iResult=false ;
WmsRateDA wmsRateDA = new WmsRateDA();
iResult = wmsRateDA.Delete(strRateGid);
return iResult;
}
#endregion
# region 多条件删除仓储费率(Wms_rate),并返回删除操作结果
///
/// 多条件删除仓储费率,并返回删除操作结果
///
///
/// 返回删除操作结果
private bool DeleteWmsRateDtj()
{
bool iResult = false;
WmsRateDA wmsRateDA = new WmsRateDA();
string cusid = "", no = "", goods = "";
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 "cusid"://CUSTOMER
cusid = strArg[1].Replace("\"", "");
break;
case "no"://CONTRACTNO
no = strArg[1].Replace("\"", "");
break;
case "goods"://goodsname
goods = strArg[1].Replace("\"", "");
break;
default:
break;
}
}
}
iResult = wmsRateDA.DeleteDTj(strbsno);
return iResult;
}
#endregion
#region 获取费率信息
///
/// 获取费率信息
///
/// 返回JSON数据
private string GetWmsOutListBySearch()
{
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("\"", "")); //by lcx
strCondition += String.Format(" AND a.ASSOCIATEDNO 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, "modSeaImportLCLList");
//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 {0} a.GID,a.BSNO,b.CUSTOMERNAME,convert(char(10),a.DODATE,20),a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSOUTFEE,b.GOODSPACKPFSL,a.TRUCKNO,a.REMARK,a.CREATEUSER,convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,isnull(c.CUSTOMERNAME,'') newcust "
// + " from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms c on b.INBSNO=c.GID "
// + " where c.ISDELETE=0 {1} {2} ORDER BY a.GOODSNAME DESC ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
// }
// else
// {
// strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
// strTopInclude = "top " + iShowPage.ToString();
// strSql = String.Format(" SELECT {0} a.GID,a.BSNO,b.CUSTOMERNAME,convert(char(10),a.DODATE,20),a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSOUTFEE,b.GOODSPACKPFSL,a.TRUCKNO,a.REMARK,a.CREATEUSER,convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,isnull(c.CUSTOMERNAME,'') newcust "
// + " from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms c on b.INBSNO=c.GID WHERE c.ISDELETE=0 and a.GID NOT IN "
// + " (SELECT {1} a.GID from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms c on b.INBSNO=c.GID WHERE c.ISDELETE=0 {2} {3} ORDER BY a.GOODSNAME DESC ) {2} {3} "
// + " ORDER BY a.GOODSNAME DESC ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
// }
//}
//else
//{
// strSql = String.Format(" SELECT {0} a.GID,a.BSNO,b.CUSTOMERNAME,convert(char(10),a.DODATE,20),a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSOUTFEE,b.GOODSPACKPFSL,a.TRUCKNO,a.REMARK,a.CREATEUSER,convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,isnull(c.CUSTOMERNAME,'') newcust "
// + " from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms c on b.INBSNO=c.GID where c.ISDELETE=0 {0} {1} "
// + " ORDER BY a.GOODSNAME DESC ", strAuthorityCondition, strCondition);
//}
if (iCurrentPage > 0 && iShowPage > 0)
{
if (iCurrentPage == 1)
{
strSql = String.Format(" SELECT {0} a.GID,(case a.ISLOCK when 1 then '是' else '否' end) as ISLOCK"
+ ",(case a.ISCHANGE when 1 then '货权转移' else '' end) as ISCHANGE"
//+ ",(case when a.REMARK like '%货权转移%' then '货权转移' else '' end) as ISREMARK"
+ ", blno=(select top 1 mblno from op_seai where bsno=a.ASSOCIATEDNO),a.BSNO,a.CUSTOMERNAME,a.CLIENTNAMEOLD,a.TRUCKNAME,convert(char(10),a.DODATE,20) as DODATE,convert(char(10),a.OLDCUSTFEEDATE,20) as OLDCUSTFEEDATE,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSPACKPFSL,a.GOODSOUTFEE,CREATEUSER=(select SHOWNAME from [user] where gid=a.CREATEUSER),convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,a.TRUCKNO "
+ " from wms_out a "
+ " where 1=1 {1} {2} ORDER BY a.GOODSNAME DESC ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
}
else
{
strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
strTopInclude = "top " + iShowPage.ToString();
strSql = String.Format(" SELECT {0} a.GID,(case a.ISLOCK when 1 then '是' else '否' end) as ISLOCK"
+ ",(case a.ISCHANGE when 1 then '货权转移' else '' end) as ISCHANGE"
//+ ",(case when a.REMARK like '%货权转移%' then '货权转移' else '' end) as ISREMARK"
+ ", blno=(select top 1 mblno from op_seai where bsno=a.ASSOCIATEDNO),a.BSNO,a.CUSTOMERNAME,a.CLIENTNAMEOLD,a.TRUCKNAME,convert(char(10),a.DODATE,20) as DODATE,convert(char(10),a.OLDCUSTFEEDATE,20) as OLDCUSTFEEDATE,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSPACKPFSL,a.GOODSOUTFEE,CREATEUSER=(select SHOWNAME from [user] where gid=a.CREATEUSER),convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,a.TRUCKNO "
+ " 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 ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
}
}
else
{
strSql = String.Format(" SELECT {0} a.GID,(case a.ISLOCK when 1 then '是' else '否' end) as ISLOCK"
+ ",(case a.ISCHANGE when 1 then '货权转移' else '' end) as ISCHANGE"
//+ ",(case when a.REMARK like '%货权转移%' then '货权转移' else '' end) as ISREMARK"
+ ", blno=(select top 1 mblno from op_seai where bsno=a.ASSOCIATEDNO),a.BSNO,a.CUSTOMERNAME,a.CLIENTNAMEOLD,a.TRUCKNAME,convert(char(10),a.DODATE,20) as DODATE,convert(char(10),a.OLDCUSTFEEDATE,20) as OLDCUSTFEEDATE,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSPACKPFSL,a.GOODSOUTFEE,CREATEUSER=(select SHOWNAME from [user] where gid=a.CREATEUSER),convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,a.TRUCKNO "
+ " from wms_out a "
+ " ORDER BY a.GOODSNAME DESC ", strAuthorityCondition, strCondition);
}
sourceTable = WmsRateDA.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 获取费率信息
///
/// 获取费率信息
///
/// 返回JSON数据
private int GetWmsOutLispagetBySearch()
{
int TmpCount = 0;
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 like '%{0}%'", strArg[1].Replace("\"", ""));
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 != "" && strbsno!=null)
{
strCondition += String.Format(" AND a.ASSOCIATEDNO like '%{0}%' ", strbsno);
}
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
//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 {0} a.GID,a.BSNO,a.CUSTOMERNAME,convert(char(19),a.DODATE,120),a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSOUTFEE,a.GOODSPACKPFSL,a.TRUCKNO,a.REMARK,a.CREATEUSER,convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,isnull(c.CLIENTNAME,'') newcust "
// + " from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms_in c on b.INBSNO=c.BSNO "
// + " where c.ISDELETE=0 {1} {2} ORDER BY GOODSNAME DESC ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
// }
// else
// {
// strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
// strTopInclude = "top " + iShowPage.ToString();
// strSql = String.Format(" SELECT {0} a.GID,a.BSNO,a.CUSTOMERNAME,convert(char(19),a.DODATE,120),a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSOUTFEE,a.GOODSPACKPFSL,a.TRUCKNO,a.REMARK,a.CREATEUSER,convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,isnull(c.CLIENTNAME,'') newcust "
// + " from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms_in c on b.INBSNO=c.BSNO WHERE c.ISDELETE=0 and a.GID NOT IN "
// + " (SELECT {1} a.GID from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms_in c on b.INBSNO=c.BSNO WHERE c.ISDELETE=0 {2} {3} ORDER BY GOODSNAME DESC ) {2} {3} "
// + " ORDER BY GOODSNAME DESC ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
// }
//}
//else
//{
// strSql = String.Format(" SELECT {0} a.GID,a.BSNO,a.CUSTOMERNAME,convert(char(19),a.DODATE,120),a.STORAGENAME,a.GOODSNAME,a.GOODSMODEL,a.GOODSPFSL,a.GOODSOUTFEE,a.GOODSPACKPFSL,a.TRUCKNO,a.REMARK,a.CREATEUSER,convert(char(19),a.CREATETIME,120),a.ASSOCIATEDNO,isnull(c.CLIENTNAME,'') newcust "
// + " from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms_in c on b.INBSNO=c.BSNO where c.ISDELETE=0 {0} {1} "
// + " ORDER BY GOODSNAME DESC ", strAuthorityCondition, strCondition);
//}
//strSql = String.Format(" SELECT COUNT(*) "
// + " from wms_out a left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms_in c on b.INBSNO=c.BSNO where c.ISDELETE=0 {0} {1} "
// , strAuthorityCondition, strCondition);
strSql = String.Format(" SELECT COUNT(*) "
+ " from wms_out a "//left outer join wms_out_detail b on a.BSNO=b.OUTBSNO left outer join wms_in c on b.INBSNO=c.BSNO
+ " where 1=1 {0} {1} "
, strAuthorityCondition, strCondition);
sourceTable = WmsRateDA.GetExcuteSql(strSql).Tables[0];
if (sourceTable!=null){
TmpCount=int.Parse(sourceTable.Rows[0][0].ToString());
}
return TmpCount;
}
#endregion
#region 获取入库wms_in信息
///
/// 获取入库wms_in信息
///
/// 返回JSON数据
private string GetWmsInList()
{
WmsInDA WmsInDA = new WmsInDA();
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 "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 BLNO 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";
}
}
string strAuthorityCondition = "";
//UserAuthorityManage userAuthorityManage = new UserAuthorityManage(strUserID, "modSeaImportLCLList");
//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 {0} BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK "
// + " FROM wms_in where 1>0 {1} {2} ORDER BY BLNO,GOODSNAME,DODATE ", "top " + iShowPage.ToString(), strAuthorityCondition, strCondition);
// }
// else
// {
// strTopNotInclude = "top " + (iShowPage * (iCurrentPage - 1)).ToString();//RowCount*PageNum
// strTopInclude = "top " + iShowPage.ToString();
// strSql = String.Format(" SELECT {0} BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK "
// + " FROM wms_in WHERE BSNO NOT IN "
// + " (SELECT {1} BSNO FROM wms_in WHERE 1>0 {2} {3} ORDER BY BLNO,GOODSNAME,DODATE ) {2} {3} "
// + " ORDER BY BLNO,GOODSNAME,DODATE ", strTopInclude, strTopNotInclude, strAuthorityCondition, strCondition);
// }
//}
//else
//{
// strSql = String.Format(" SELECT BSNO,BLNO,DODATE,GOODSNAME,GOODSMODEL,GOODSSTOCK,0 BCPFSL,'' TRUCKNO,'' REMARK"
// + " FROM wms_in where 1>0 {0} {1} "
// + " ORDER BY BLNO,GOODSNAME,DODATE ", strAuthorityCondition, strCondition);
//}
//strSql = String.Format(" SELECT a.BSNO,a.BLNO,convert(char(10),a.DODATE,120) DODATE,a.GOODSNAME,a.GOODSMODEL,a.GOODSSTOCK,isnull(b.GOODSPFSL,0) GOODSPFSL,isnull(b.TRUCKNO,'') TRUCKNO,isnull(b.REMARK,'') REMARK,a.STORAGENAME "
// + " FROM wms_in a left outer join wms_out_detail b on a.bsno=b.INBSNO where 1>0 {0} {1} "
// + " ORDER BY a.BLNO,a.GOODSNAME,a.DODATE ", strAuthorityCondition, strCondition);
//strSql = String.Format(" SELECT BSNO,CLIENTNAME,BLNO,convert(char(10),DODATE,120) DODATE,GOODSNAME,GOODSMODEL,GOODSPACKSTOCK,GOODSSTOCK,0 as GOODSPACKPFSL,0 as GOODSPFSL,0 as ARFEE,0 as APFEE,' ' as TRUCKNO,' ' as REMARK,STORAGENAME,ASSOCIATEDNO,(GOODSSTOCK/GOODSPACKSTOCK) GOODSKGS,CLIENTNAMEOLD "
// + " 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,DODATE ", strAuthorityCondition, strCondition);
//sourceTable = WmsInDA.GetExcuteSql(strSql).Tables[0];
strSql = String.Format(" SELECT GID,CUSTOMERNAME,BLNO,convert(char(10),WMSDATE,120) WMSDATE,GOODSNAME,GOODSMODEL,GOODSPACKSTOCK,GOODSSTOCK,0 as GOODSPACKPFSL,0 as GOODSPFSL,0 as ARFEE,0 as APFEE,' ' as TRUCKNO,' ' as REMARK,STORAGENAME,ASSOCIATEDNO,convert(numeric(18,4),(GOODSSTOCK/GOODSPACKSTOCK)) as GOODSKGS,CLIENTNAMEOLD "
+ " FROM wms where isnull(ISDELETE,0)=0 and isnull(ISLOCK,0)=1 and GOODSPACKSTOCK<>0 and GOODSSTOCK>0 {0} {1} "
+ " ORDER BY BLNO,GOODSNAME,WMSDATE ", 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_out、wms_out_detail、ch_fee ),修改wms_in、fee_gain 并返回删除操作结果
///
/// 删除仓储费用(Wms_out、wms_out_detail、ch_fee ),修改wms_in、fee_gain 并返回删除操作结果
///
/// 出库单GID
/// 值1删除成功 值小于1删除失败
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 FeeEntities = new List();
FeeDA feeDA = new FeeDA();
//入库单处理:修改
WmsInEntity wmsinentity = new WmsInEntity();
WmsOutDetailDA wmsoutdetailDA = new WmsOutDetailDA();
DataSet DsWmsOutDetail = new DataSet();
DataTable DtWmsOutDetail = new DataTable();
//string strSql = "";
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 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 = "";
}
//wms_out_detail处理:删除
Sqlstr = String.Format("delete wms_out_detail where OUTBSNO='{0}' ", wmsoutentity.BSNO);
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
Sqlstr = "";
//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
//
}
}