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

888 lines
48 KiB
C#

3 years ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using DSWeb.EntityDA;
using DSWeb.Models;
using System.Xml;
using System.Text.RegularExpressions;
using WebSqlHelper;
using System.Data.SqlClient;
namespace DSWeb.WMS
{
public partial class WmsWmsrateTestListGridSource : System.Web.UI.Page
{
private int iCurrentPage;
private int iShowPage;
private string strHandle;//值为"page"获取分页状态值数组 值为"list"获取日志显示JSON数据 值为"columns"获取日志显示记录 值为"rename"更新列标题
private string strType = "51";//Grid模块号
private string strOldHeader;
private string strNewHeader;
public string strgids = "";
private string strUserID;//用户GID
private string strCompanyID;//公司GID
private string strShowName;//用户显示名
private string strDeptName;//部门名称
T_ALL_DA T_ALL_DA = new T_ALL_DA();
protected void Page_Load(object sender, EventArgs e)
{
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().Trim().ToLower();
}
if (Request.QueryString["cur_page"] != null)
{
iCurrentPage = int.Parse(Request.QueryString["cur_page"].ToString().Trim());
}
if (Request.QueryString["show_page"] != null)
{
iShowPage = int.Parse(Request.QueryString["show_page"].ToString().Trim());
}
//
ViewState["hid_sel"] = "";
if (Request.QueryString["search"] != null && Request.QueryString["search"].ToString().Trim() != "")
{
UnicodeEncoding unicode = new UnicodeEncoding();
ViewState["hid_sel"] = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["search"].ToString())));
}
//
string strJSON = "";
if (strHandle != null)
{
if (strHandle.Equals("list"))
{
if (iCurrentPage <= 0 && iShowPage < 0)
{
strJSON = "-2";//提交页数参数错误
}
}
if (strHandle.Trim().ToLower().Equals("setting"))
{
Response.Write(GetUserSettingJson());
}
if (strHandle.Trim().ToLower().Equals("page"))
{
Response.Write(GetPageInfo().ToString());
}
if (strHandle.Trim().ToLower().Equals("list"))
{
Response.Write(GetLogContent(iShowPage, iCurrentPage));
}
if (strHandle.Trim().ToLower().Equals("rename"))
{
if (Request.QueryString["old_header"] != null && Request.QueryString["new_header"] != null)
{
UnicodeEncoding unicode = new UnicodeEncoding();
strOldHeader = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["old_header"].ToString())));
strNewHeader = unicode.GetString(unicode.GetBytes(Regex.Unescape(Request.QueryString["new_header"].ToString())));
Response.Write(UpdateColumnHeader(strOldHeader, strNewHeader));
}
else
{
Response.Write("-1");//GET 参数错误
}
}
if (strHandle.Trim().ToLower().Equals("setexcel"))//导出Excel
{
Response.Write(GetExcelSQL());
}
if (strHandle.Trim().ToLower().Equals("setexcel2"))//导出Excel
{
Response.Write(GetExcelSQL2());
}
if (strHandle.Trim().ToLower().Equals("setexcel3"))//导出Excel
{
Response.Write(GetExcelSQL3());
}
}
else
{
strJSON = "-1";//GET 参数错误
}
}
private int UpdateColumnHeader(string tempOldHeader, string tempNewHeader)
{
int iResult = 0;
UserSettingDA userSettingDA = new UserSettingDA();
UserSettingEntity userSettingEntity = userSettingDA.GetUserSettingByUserIDType(strUserID, strType);
GridEntity gridEntity = null;
if (userSettingEntity != null)
{
if (userSettingEntity.GID != null)
{
gridEntity = GetSettingXml(userSettingEntity.Xml);
foreach (GridColumnEntity column in gridEntity.Columns)
{
if (column.Description.Equals(tempOldHeader))
{
column.Description = tempNewHeader;
break;
}
}
userSettingEntity.Xml = GetUserSettingXml(gridEntity).OuterXml;
iResult = userSettingDA.UpdateUserSetting(userSettingEntity);
}
else
{
iResult = -3;//没有相关用户Grid设置记录
}
}
else
{
iResult = -3;//没有相关用户Grid设置记录
}
return iResult;
}
private string GetUserSettingJson()
{
UserSettingDA userSettingDA = new UserSettingDA();
UserSettingEntity userSettingEntity = userSettingDA.GetUserSettingByUserIDType(strUserID, strType);
GridEntity gridEntity = null;
StringBuilder settingBuilder = new StringBuilder();
if (userSettingEntity != null)
{
if (userSettingEntity.GID != null)
{
gridEntity = GetSettingXml(userSettingEntity.Xml);
settingBuilder.Append("{");
settingBuilder.Append("\"show\":" + gridEntity.PagePreCount + ",");
settingBuilder.Append("\"columns\":");
int i = 0;
StringBuilder columnGroupBuilder = new StringBuilder();
while (gridEntity.Columns.Count > i)
{
foreach (GridColumnEntity column in gridEntity.Columns)
{
if (column.Index == i)
{
StringBuilder columnBuilder = new StringBuilder();
columnBuilder.Append("{\"name\":\"" + column.Name + "\",");
columnBuilder.Append("\"description\":\"" + column.Description + "\",");
columnBuilder.Append("\"index\":" + column.Index.ToString() + ",");
columnBuilder.Append("\"width\":" + column.Width.ToString() + ",");
columnBuilder.Append("\"visible\":" + column.VisibleState.ToString());
columnGroupBuilder.Append(columnBuilder.ToString() + "},");
break;
}
}
i++;
}
string strGroup = columnGroupBuilder.ToString().Trim();
if (strGroup.EndsWith(","))
{
strGroup = strGroup.Substring(0, strGroup.Length - 1);
}
strGroup = "[" + strGroup + "]";
settingBuilder.Append(strGroup);
settingBuilder.Append("}");
}
else
{
settingBuilder.Append("-3");//没有相关用户Grid设置记录
}
}
else
{
settingBuilder.Append("-3");//没有相关用户Grid设置记录
}
return settingBuilder.ToString();
}
private GridEntity GetSettingXml(string strXml)
{
XmlDocument xmlSettingDoc = new XmlDocument();
GridEntity gridEntity = new GridEntity();
try
{
xmlSettingDoc.LoadXml(strXml);
gridEntity.GID = xmlSettingDoc.ChildNodes[0].ChildNodes[0].InnerText.Trim();
gridEntity.UserID = xmlSettingDoc.ChildNodes[0].ChildNodes[1].InnerText.Trim();
gridEntity.CreateTime = DateTime.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[2].InnerText.Trim());
IList<GridColumnEntity> columnsEntities = new List<GridColumnEntity>();
int iColCount = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes.Count;
for (int i = 0; i < iColCount; i++)
{
GridColumnEntity columnEntity = new GridColumnEntity();
//columnEntity.GID = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[0].ToString();
columnEntity.Name = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[0].InnerText.Trim();
columnEntity.Description = xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[1].InnerText.Trim();
columnEntity.Index = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[2].InnerText.Trim());
columnEntity.Width = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[3].ChildNodes[i].ChildNodes[3].InnerText.Trim());
columnsEntities.Add(columnEntity);
}
gridEntity.Columns = columnsEntities;
gridEntity.GroupBy = xmlSettingDoc.ChildNodes[0].ChildNodes[4].InnerText.Trim();
gridEntity.DefaultPrePageCount = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[5].ChildNodes[0].InnerText.Trim());
gridEntity.PagePreCount = int.Parse(xmlSettingDoc.ChildNodes[0].ChildNodes[5].ChildNodes[1].InnerText.Trim());
}
catch (Exception error)
{
throw (error);
}
return gridEntity;
}
private int GetPageInfo()
{
LogDA logDA = new LogDA();
StringBuilder logBuilder = new StringBuilder();
string strSql = " SELECT COUNT(*) FROM wms_wmsrate_test where CREATEUSER='" + strUserID + "' and CORPID2='" + strCompanyID + "'";
//string strSql = String.Format("SELECT COUNT(*) FROM VW_WMS_STOCKTAKE WHERE 1=1 " + ViewState["hid_sel"].ToString().Trim());
int iTotal = logDA.GetPageTotal(strSql);
return iTotal;
}
private string GetLogContent(int tempShowPage, int tempCurPage)
{
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;//是否包含已经出库的仓储费;
string strSearch = ViewState["hid_sel"].ToString().Trim();
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 w.CUSTOMERNAME = '{0}' ", strArg[1].Replace("\"", ""));
break;
case "blno"://NO
strCondition += String.Format(" AND w.BLNO like '%{0}%' ", strArg[1].Replace("\"", ""));
break;
case "customno"://NO
strCondition += String.Format(" AND w.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, "modSeaImportList");
//if (userAuthorityManage.OperateType != AuthorityType.NULL)
//{
// strAuthorityCondition = userAuthorityManage.GetVisibleRangeSql(userAuthorityManage.VisibleType, ModuleType.OPSEAILIST, strShowName, strCompanyID, strDeptName, strUserID);
//}
if (strSearch != null)
{
#region 按计费日期计算仓储费用插入临时表
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
int iState = 0;
int result = 0;
string Sqlstr = "";
//
try
{
//
Sqlstr = "delete from wms_rate_detail where ASSOCIATEDNO in (select GID 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;
}
//
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;
}
#region 从wms中提取计费单位不等于CBM的数据
Sqlstr = String.Format("select GID,CUSTOMERNAME,STORAGENAME,BLNO,GOODSSTOCK,WMSDAYS,WMSDATE,isnull(STARTBILLINGDATE,WMSDATE) as STARTBILLINGDATE,isnull(STARTBILLINGDATEAP,WMSDATE) as STARTBILLINGDATEAP, ENDBILLINGDATE from (SELECT *,(DATEDIFF(day, convert(char(10),WMSDATE,120), '{2}') + 1) as WMSDAYS, '2013-12-07' ENDBILLINGDATE FROM wms as w where isnull(ISDELETE,0)=0 and isnull(GOODSSTOCK,0)>0 and convert(char(10),WMSDATE,120)<=convert(char(10),'{2}',120) and CHARGEUNIT<>'CBM' {0} {1} ) as a where 1=1 ORDER BY CUSTOMERNAME,BLNO ", strAuthorityCondition, strCondition, OutDate);
DataSet ds = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr, null);
if (ds != null)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
#region 计算仓储费
decimal totaloutfee = 0;//出库单的仓储费
decimal totaloutfeeap = 0;//仓储费合计
decimal sumfee = 0;
decimal sumfeeap = 0;
int feedays = 0;
int feedaysap = 0;
decimal outnums = decimal.Parse(dr["GOODSSTOCK"].ToString().Trim());//库存量
WmsOutDetailDA WmsOutDetailDA = new EntityDA.WmsOutDetailDA();
//计算应收仓储费
string getstr = WmsOutDetailDA.getWmsRate(sqlTran, dr["STARTBILLINGDATE"].ToString().Trim(), OutDate.Trim(), dr["GID"].ToString().Trim(), dr["CUSTOMERNAME"].ToString().Trim(), outnums, dr["GID"].ToString().Trim(), 1, strUserID, strShowName, "现有库存计算应收仓储费", true, false);
string[] strls = getstr.Trim().Split(new string[] { "" }, StringSplitOptions.RemoveEmptyEntries);
sumfee = Decimal.Parse(strls[0].ToString());
totaloutfee += sumfee;//仓储费合计
feedays += int.Parse(strls[1].ToString());
//计算应付仓储费
getstr = WmsOutDetailDA.getWmsRate(sqlTran, dr["STARTBILLINGDATEAP"].ToString().Trim(), OutDate.Trim(), dr["GID"].ToString().Trim(), dr["STORAGENAME"].ToString().Trim(), outnums, dr["GID"].ToString().Trim(), 2, strUserID, strShowName, "现有库存计算应付仓储费", true, false);
strls = getstr.Trim().Split(new string[] { "" }, StringSplitOptions.RemoveEmptyEntries);
sumfeeap = Decimal.Parse(strls[0].ToString());
totaloutfeeap += sumfee;//仓储费合计
feedaysap += int.Parse(strls[1].ToString());
#endregion
//
Sqlstr = String.Format("insert into wms_wmsrate_test(GID,WMSNO,INDATE,OUTDATE,ASSOCIATEDNO,BLNO,CUSTOMERNAME,STORAGENAME,GOODSNAME,GOODSMODEL,CHARGEUNIT,GOODSPACK,GOODSPACKSTOCK,GOODSRKSL,GOODSSTOCK,ARFEE,APFEE,MODIFIEDUSER,MODIFIEDTIME,ISLOCK,CORPID,CUSTOMNO,WMSDAYS,FEEDAYS,GOODSOUTFEE,FEEDAYSAP,GOODSOUTFEEAP,ISWMSOUT,CREATEUSER,CREATETIME,CORPID2,STARTBILLINGDATE,STARTBILLINGDATEAP) "
+ " select GID,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 top 1 SHOWNAME FROM [user] WHERE GID = w.MODIFIEDUSER) AS MODIFIEDUSER,getdate() as MODIFIEDTIME,ISLOCK,CORPID,CUSTOMNO,(DATEDIFF(day, convert(char(10),WMSDATE,120), '{2}') + 1) as WMSDAYS,{3} AS FEEDAYS,{4} as GOODSOUTFEE,{5} AS FEEDAYSAP,{6} as GOODSOUTFEEAP"
+ ",0 ISWMSOUT,'" + strUserID + "' as CREATEUSER,getdate() as CREATETIME,'" + strCompanyID + "' as CORPID2,'{7}'STARTBILLINGDATE,'{8}'STARTBILLINGDATEAP from wms as w 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() + "' and w.CHARGEUNIT<>'CBM' {0} {1} ", strAuthorityCondition, strCondition, OutDate, feedays, sumfee, feedaysap, sumfeeap, dr["STARTBILLINGDATE"].ToString().Trim(), dr["STARTBILLINGDATEAP"].ToString().Trim());
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
if (iState != 1)
{
sqlTran.Rollback();
result = -4;
}
}
}
#endregion
#region 从wms_in中提取计费单位等于CBM的数据
Sqlstr = String.Format("select GID,WMSGID,CUSTOMERNAME,BLNO,GOODSSTOCK,WMSDAYS from (SELECT i.GID,i.ASSOCIATEDNO as WMSGID,w.CUSTOMERNAME,w.BLNO,i.GOODSSTOCK,(DATEDIFF(day, convert(char(10),w.WMSDATE,120), '2013-09-25') + 1) as WMSDAYS FROM wms_in as i LEFT OUTER JOIN wms as w on i.ASSOCIATEDNO=w.gid where isnull(w.ISDELETE,0)=0 and isnull(i.GOODSSTOCK,0)>0 and convert(char(10),w.WMSDATE,120)<=convert(char(10),'{2}',120) and w.CHARGEUNIT='CBM' {0} {1} ) as a where 1=1 ORDER BY CUSTOMERNAME,BLNO ", strAuthorityCondition, strCondition, OutDate);
ds = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr, null);
if (ds != null)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
#region 按计费日期计算仓储费用
decimal totaloutfee = 0;//出库单的仓储费
int prescale = 0;
int nowscale = 0;
int nowgrade = 0;
decimal price = 0;
decimal gradefee = 0;
decimal sumfee = 0;
//
int iFEEDAYS = 0;//计费天数 FEEDAYS
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["WMSGID"].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;
//计算 开始计费日期和计费天数
if (price > 0)
{
iFEEDAYS = nowscale;//计费天数 FEEDAYS
}
//
prescale = nowscale;//本次收费区间
}
else
{
gradefee = outnums * price * (feedays - prescale);//出库量*收费单价*(仓储天数-上一个收费区间(0)
sumfee += gradefee;
//计算 开始计费日期和计费天数
if (price > 0)
{
iFEEDAYS = feedays - prescale;//计费天数 FEEDAYS
}
//
prescale = nowscale;//本次收费区间
break;
}
}
else if (nowgrade > 1)//收费等级
{
if (feedays > nowscale)
{
gradefee = outnums * price * (nowscale - prescale);//出库量*收费单价*(收费区间-上一个收费区间(0)
sumfee += gradefee;
//计算 开始计费日期和计费天数
if (price > 0)
{
iFEEDAYS += (nowscale - prescale);//计费天数 FEEDAYS
}
//
prescale = nowscale;//本次收费区间
}
else
{
gradefee = outnums * price * (feedays - prescale);//出库量*收费单价*(仓储天数-上一个收费区间(0)
sumfee += gradefee;
//计算 开始计费日期和计费天数
if (price > 0)
{
iFEEDAYS += (feedays - prescale);//计费天数 FEEDAYS
}
//
prescale = nowscale;//本次收费区间
break;
}
}
}
if (feedays > nowscale)
{
gradefee = outnums * price * (feedays - nowscale);//出库量*收费单价*(仓储天数-收费区间(0)
sumfee += gradefee;
//计算 开始计费日期和计费天数
if (price > 0)
{
iFEEDAYS += (feedays - nowscale);//计费天数 FEEDAYS
}
}
//
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,GOODSSLICE,GOODSGRADE,GOODSSTANDARD) "
+ " select WMSNO,convert(char(10),w.WMSDATE,120) INDATE,'{2}' OUTDATE,w.ASSOCIATEDNO,w.BLNO,w.CUSTOMERNAME,w.STORAGENAME,i.GOODSNAME,i.GOODSMODEL,w.CHARGEUNIT,isnull(i.GOODSPACK,0) as GOODSPACK,isnull(i.GOODSPACKSTOCK,0) as GOODSPACKSTOCK,isnull(i.GOODSRKSL,0) as GOODSRKSL,isnull(i.GOODSSTOCK,0) as GOODSSTOCK,isnull(i.ARFEE,0) as ARFEE,isnull(i.APFEE,0) as APFEE,(SELECT top 1 SHOWNAME FROM [user] WHERE GID = w.MODIFIEDUSER) AS MODIFIEDUSER,getdate() as MODIFIEDTIME,w.ISLOCK,w.CORPID,w.CUSTOMNO,(DATEDIFF(day, convert(char(10),w.WMSDATE,120), '{2}') + 1) as WMSDAYS,'{3}' AS FEEDAYS,{4} as GOODSOUTFEE"
+ ",0 ISWMSOUT,'" + strUserID + "' as CREATEUSER,getdate() as CREATETIME,'" + strCompanyID + "' as CORPID2,i.GOODSSLICE,i.GOODSGRADE,i.GOODSSTANDARD from wms_in as i LEFT OUTER JOIN wms as w on i.ASSOCIATEDNO=w.gid where isnull(w.ISDELETE,0)=0 and isnull(i.GOODSSTOCK,0)>0 and convert(char(10),w.WMSDATE,120)<=convert(char(10),'{2}',120) and i.GID='" + dr["GID"].ToString().Trim() + "' and w.CHARGEUNIT='CBM' {0} {1} ", strAuthorityCondition, strCondition, OutDate, iFEEDAYS, sumfee);
iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
if (iState != 1)
{
sqlTran.Rollback();
result = -4;
}
}
}
#endregion
//
result = 1;//状态为1表示删除成功
sqlTran.Commit();
}
catch (Exception execError)
{
result = -10;//有异常,插入失败
sqlTran.Rollback();
result = -11;//插入异常,事务已回滚成功
throw execError;
}
finally
{
SqlHelper.CloseConnection();
}
}
#endregion
}
//货主,提单号,备案清单号,入库单号,入库日期,计费日期,仓库名称,等级,品名,型号/品牌,规格,片数/件,剩余件数,剩余库存,计费单位,仓储天数,计费天数,仓储费,开单人,开单时间,进口委托单号,是否有出库单;
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),STARTBILLINGDATE,120) STARTBILLINGDATE,convert(char(10),STARTBILLINGDATEAP,120) STARTBILLINGDATEAP,convert(char(10),OUTDATE,120) OUTDATE,STORAGENAME,GOODSGRADE,GOODSNAME,GOODSMODEL,GOODSSTANDARD,GOODSSLICE,GOODSPACKSTOCK,GOODSSTOCK,CHARGEUNIT,WMSDAYS,FEEDAYS,GOODSOUTFEE,FEEDAYSAP,GOODSOUTFEEAP,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),STARTBILLINGDATE,120) STARTBILLINGDATE,convert(char(10),STARTBILLINGDATEAP,120) STARTBILLINGDATEAP,convert(char(10),OUTDATE,120) OUTDATE,STORAGENAME,GOODSGRADE,GOODSNAME,GOODSMODEL,GOODSSTANDARD,GOODSSLICE,GOODSPACKSTOCK,GOODSSTOCK,CHARGEUNIT,WMSDAYS,FEEDAYS,GOODSOUTFEE,FEEDAYSAP,GOODSOUTFEEAP,MODIFIEDUSER,MODIFIEDTIME,ASSOCIATEDNO,ISWMSOUT "
+ " FROM wms_wmsrate_test WHERE GID NOT IN "
+ " (SELECT {1} GID FROM wms_wmsrate_test where CREATEUSER='" + strUserID + "' and CORPID2='" + strCompanyID + "' ORDER BY CUSTOMERNAME,BLNO ) and CREATEUSER='" + strUserID + "' and CORPID2='" + strCompanyID + "'"
+ " ORDER BY CUSTOMERNAME,BLNO ", strTopInclude, strTopNotInclude);
}
}
else
{
strSql = "SELECT GID,CUSTOMERNAME,BLNO,CUSTOMNO,WMSNO,convert(char(10),INDATE,120) INDATE,convert(char(10),STARTBILLINGDATE,120) STARTBILLINGDATE,convert(char(10),STARTBILLINGDATEAP,120) STARTBILLINGDATEAP,convert(char(10),OUTDATE,120) OUTDATE,STORAGENAME,GOODSGRADE,GOODSNAME,GOODSMODEL,GOODSSTANDARD,GOODSSLICE,GOODSPACKSTOCK,GOODSSTOCK,CHARGEUNIT,WMSDAYS,FEEDAYS,GOODSOUTFEE,FEEDAYSAP,GOODSOUTFEEAP,MODIFIEDUSER,MODIFIEDTIME,ASSOCIATEDNO,0 as 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\",");
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();
}
private string GetSeaExPKGSInfoBusinessListGridSource()
{
//GetLogGridSource
LogDA logDA = new LogDA();
StringBuilder logBuilder = new StringBuilder();
StringBuilder userdateBuilder = new StringBuilder();
StringBuilder dataBuilder = new StringBuilder();
string strSql = String.Format("SELECT COUNT(*) FROM VW_WMS_STOCKTAKE WHERE 1=1 " + ViewState["hid_sel"].ToString().Trim());
DataTable sourceBuilder = logDA.GetExcuteSql(strSql).Tables[0];
logBuilder.Append("{");
logBuilder.Append("rows:[");
for (int i = 0; i < sourceBuilder.Rows.Count; i++)
{
logBuilder.Append("{id:\"" + sourceBuilder.Rows[i][0].ToString() + "\",");
userdateBuilder.Append("userdata:{");
dataBuilder.Append("data:[");
for (int j = 1; j < sourceBuilder.Columns.Count; j++)
{
if (j == sourceBuilder.Columns.Count - 1)
{
userdateBuilder.Append("\"" + sourceBuilder.Columns[j].ColumnName + "\":\"" + sourceBuilder.Rows[i][j].ToString() + "\"");
dataBuilder.Append("\"" + sourceBuilder.Rows[i][j].ToString() + "\"");
}
else
{
userdateBuilder.Append("\"" + sourceBuilder.Columns[j].ColumnName + "\":\"" + sourceBuilder.Rows[i][j].ToString() + "\",");
dataBuilder.Append("\"" + sourceBuilder.Rows[i][j].ToString() + "\",");
}
}
userdateBuilder.Append("}");
dataBuilder.Append("]");
logBuilder.Append(userdateBuilder.ToString() + ",");
logBuilder.Append(dataBuilder);
if (i == sourceBuilder.Rows.Count - 1)
{
logBuilder.Append("}");
}
else
{
logBuilder.Append("},");
}
}
logBuilder.Append("]");
logBuilder.Append("}");
return logBuilder.ToString();
//return logBuilder.ToString();
}
private DataTable GetSqlDataIndex(DataTable tempTable)
{
UserSettingDA userSettingDA = new UserSettingDA();
UserSettingEntity userSettingEntity = userSettingDA.GetUserSettingByUserIDType(strUserID, strType);
GridEntity gridEntity = null;
StringBuilder settingBuilder = new StringBuilder();
DataTable dataTable = new DataTable();
if (userSettingEntity != null)
{
if (userSettingEntity.GID != null)
{
gridEntity = GetSettingXml(userSettingEntity.Xml);
int i = 0;
StringBuilder columnGroupBuilder = new StringBuilder();
dataTable.Columns.Add(tempTable.Columns[0].ColumnName, tempTable.Columns[0].DataType);
for (int k = 0; k < tempTable.Rows.Count; k++)
{
DataRow newRow = dataTable.NewRow();
newRow[tempTable.Columns[0].ColumnName] = tempTable.Rows[k][tempTable.Columns[0].ColumnName].ToString();
dataTable.Rows.Add(newRow);
}
while (gridEntity.Columns.Count > i)
{
foreach (GridColumnEntity column in gridEntity.Columns)
{
if (column.Index == i)
{
for (int j = 1; j < tempTable.Columns.Count; j++)
{
if (tempTable.Columns[j].ColumnName.Equals(column.Name))
{
dataTable.Columns.Add(tempTable.Columns[j].ColumnName, tempTable.Columns[j].DataType);
for (int k = 0; k < tempTable.Rows.Count; k++)
{
dataTable.Rows[k][tempTable.Columns[j].ColumnName] = tempTable.Rows[k][tempTable.Columns[j].ColumnName].ToString();
}
break;
}
}
break;
}
}
i++;
}
}
else
{
return tempTable;
}
}
else
{
return tempTable;
}
return dataTable;
}
private XmlDocument GetUserSettingXml(GridEntity gridEntity)
{
XmlDocument xmlDoc = new XmlDocument();
XmlElement root = xmlDoc.CreateElement("user-settings");
//xmlDoc.AppendChild(root);
XmlElement xGID = xmlDoc.CreateElement("GID");
xGID.InnerText = gridEntity.GID;
root.AppendChild(xGID);
XmlElement xUserID = xmlDoc.CreateElement("userid");
xUserID.InnerText = gridEntity.UserID;
root.AppendChild(xUserID);
XmlElement xCreateTime = xmlDoc.CreateElement("create-time");
xCreateTime.InnerText = gridEntity.CreateTime.ToString();
root.AppendChild(xCreateTime);
XmlElement xColumns = xmlDoc.CreateElement("columns");
foreach (GridColumnEntity column in gridEntity.Columns)
{
XmlElement xColumn = xmlDoc.CreateElement("column");
XmlElement nName = xmlDoc.CreateElement("name");
nName.InnerText = column.Name;
xColumn.AppendChild(nName);
XmlElement nDescription = xmlDoc.CreateElement("description");
nDescription.InnerText = column.Description;
xColumn.AppendChild(nDescription);
XmlElement nIndex = xmlDoc.CreateElement("index");
nIndex.InnerText = column.Index.ToString();
xColumn.AppendChild(nIndex);
XmlElement nWidth = xmlDoc.CreateElement("width");
nWidth.InnerText = column.Width.ToString();
xColumn.AppendChild(nWidth);
XmlElement nVisible = xmlDoc.CreateElement("visible");
nVisible.InnerText = column.VisibleState.ToString();
xColumn.AppendChild(nVisible);
xColumns.AppendChild(xColumn);
}
root.AppendChild(xColumns);
XmlElement xGroupBy = xmlDoc.CreateElement("group-by");
xGroupBy.InnerText = gridEntity.GroupBy;
root.AppendChild(xGroupBy);
XmlElement xPage = xmlDoc.CreateElement("page");
XmlElement nPageDefault = xmlDoc.CreateElement("page-default");
nPageDefault.InnerText = gridEntity.DefaultPrePageCount.ToString();
xPage.AppendChild(nPageDefault);
XmlElement nPagePre = xmlDoc.CreateElement("page-pre");
nPagePre.InnerText = gridEntity.PagePreCount.ToString();
xPage.AppendChild(nPagePre);
root.AppendChild(xPage);
xmlDoc.AppendChild(root);
return xmlDoc;
}
/// <summary>
/// 导出Excel
/// </summary>
/// <returns></returns>
private string GetExcelSQL()
{
string strSql = " SELECT CUSTOMERNAME,BLNO,CUSTOMNO,WMSNO,convert(char(10),INDATE,120) INDATE,convert(char(10),STARTBILLINGDATE,120) STARTBILLINGDATE,convert(char(10),STARTBILLINGDATEAP,120) STARTBILLINGDATEAP,convert(char(10),OUTDATE,120) OUTDATE,STORAGENAME,GOODSGRADE,GOODSNAME,GOODSMODEL,GOODSSTANDARD,GOODSSLICE,GOODSPACKSTOCK,GOODSSTOCK,CHARGEUNIT,WMSDAYS,FEEDAYS,GOODSOUTFEE,FEEDAYSAP,GOODSOUTFEEAP,MODIFIEDUSER,MODIFIEDTIME FROM wms_wmsrate_test where CREATEUSER='" + strUserID + "' and CORPID2='" + strCompanyID + "' ORDER BY CUSTOMERNAME,BLNO ";
return strSql;
}
/// <summary>
/// 导出Excel
/// </summary>
/// <returns></returns>
private string GetExcelSQL2()
{
//货主,提单号,备案清单号,入库单号,仓库名称,等级,品名,型号/品牌,规格,片数/件,计费等级,费用类别,开始计费日期,结束计费日期,计费区间,单位,单价,出库量,仓储费,创建人,创建时间
string strSql = " SELECT W.CUSTOMERNAME,W.BLNO,W.CUSTOMNO,W.WMSNO,W.STORAGENAME"
+ ",W.GOODSGRADE,W.GOODSNAME,W.GOODSMODEL,W.GOODSSTANDARD,W.GOODSSLICE,R.FEEGRADE"
+ ",(case R.FEETYPE when 1 then '收' else '付' end) as FEETYPE"
+ ",convert(char(10),R.STARTBILLINGDATE,20) AS STARTBILLINGDATE"
+ ",convert(char(10),R.ENDBILLINGDATE,20) AS ENDBILLINGDATE"
+ ",R.FEESCALE,R.FEEUNIT,R.FEEPRICE,R.GOODSPFSL,R.OUTFEE"
+ ",MODIFIEDUSER=(select top 1 SHOWNAME from [user] where gid=R.MODIFIEDUSER),R.MODIFIEDTIME"
+ " FROM wms_wmsrate_test as W LEFT OUTER JOIN wms_rate_detail AS R on R.ASSOCIATEDNO=W.GID"
+ " where W.CREATEUSER='" + strUserID + "' and W.CORPID2='" + strCompanyID + "' and R.FEETYPE=1 "
+ " ORDER BY W.CUSTOMERNAME,W.BLNO,R.ASSOCIATEDNO,R.FEETYPE,R.FEEGRADE,R.MODIFIEDTIME";//R.GID,R.ASSOCIATEDNO,
return strSql;
}
/// <summary>
/// 导出Excel
/// </summary>
/// <returns></returns>
private string GetExcelSQL3()
{
//货主,提单号,备案清单号,入库单号,仓库名称,等级,品名,型号/品牌,规格,片数/件,计费等级,费用类别,开始计费日期,结束计费日期,计费区间,单位,单价,出库量,仓储费,创建人,创建时间
string strSql = " SELECT W.CUSTOMERNAME,W.BLNO,W.CUSTOMNO,W.WMSNO,W.STORAGENAME"
+ ",W.GOODSGRADE,W.GOODSNAME,W.GOODSMODEL,W.GOODSSTANDARD,W.GOODSSLICE,R.FEEGRADE"
+ ",(case R.FEETYPE when 1 then '收' else '付' end) as FEETYPE"
+ ",convert(char(10),R.STARTBILLINGDATE,20) AS STARTBILLINGDATE"
+ ",convert(char(10),R.ENDBILLINGDATE,20) AS ENDBILLINGDATE"
+ ",R.FEESCALE,R.FEEUNIT,R.FEEPRICE,R.GOODSPFSL,R.OUTFEE"
+ ",MODIFIEDUSER=(select top 1 SHOWNAME from [user] where gid=R.MODIFIEDUSER),R.MODIFIEDTIME"
+ " FROM wms_wmsrate_test as W LEFT OUTER JOIN wms_rate_detail AS R on R.ASSOCIATEDNO=W.GID"
+ " where W.CREATEUSER='" + strUserID + "' and W.CORPID2='" + strCompanyID + "' and R.FEETYPE=2 "
+ " ORDER BY W.CUSTOMERNAME,W.BLNO,R.ASSOCIATEDNO,R.FEETYPE,R.FEEGRADE,R.MODIFIEDTIME";//R.GID,R.ASSOCIATEDNO,
return strSql;
}
//
}
}