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/Areas/MvcShipping/DAL/WMSOUT_GuiGe/WMSOUT_GuiGeDAL.cs

2905 lines
180 KiB
C#

3 years ago
using System;
using System.IO;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.WMSOUT_GuiGe;
using DSWeb.MvcShipping.Models.WMSRate;
using WebSqlHelper;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Data.SqlClient;
//using DSWeb.DataAccess;
using HcUtility.Core;
using DSWeb.Areas.CommMng.DAL;
using Ivony.Html;
using DSWeb.MvcShipping.DAL.MsSysParamSet;
using Ivony.Fluent;
using DSWeb.MvcShipping.DAL.WMSStock;
namespace DSWeb.MvcShipping.DAL.WMSOUT_GuiGeDAL
{
public class WMSOUT_GuiGeDAL
{
#region 查询主表
static public List<WMSOUT_GuiGe> GetDataListHJ(string strCondition, string userid, string usercode, string companyid, int start=0, int limit=10000, string sort = null)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(userid);
var strSql = new StringBuilder();
strSql.Append(" *, MODIFIEDUSERNAME=(select top 1 [SHOWNAME] from [user] where gid=wms_out.MODIFIEDUSER),FEESTATUSREF=(case when FEESTATUS='True' then '锁定' else '未锁定' end)"
+ ", dbo.F_GetBillDrFeeStatus_WMS(GID) DRFEESTATUS"//需求编号SR2017071300002-1
+ ", dbo.F_GetBillCrFeeStatus_WMS(GID) CRFEESTATUS"//需求编号SR2017071300002-1
//+ ", MBLNO=isnull((select top 1 MBLNO from op_seai where bsno=wms_out.ASSOCIATEDNO),(select top 1 BLNO from wms where ASSOCIATEDNO=wms_out.ASSOCIATEDNO))"//需求编号SR2017071300002-2
+ ",MBLNO = ISNULL( "
+ "(select top 1 BLNO from wms where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno)),"
+ "(select top 1 BLNO from wms where gid = (select top 1 ASSOCIATEDNO from wms_in where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno))))"
// + ", WMSNO=(case when (CHARGEUNIT='CBM' or CHARGEUNIT='箱') then (select top 1 WMSNO from wms where gid=(select top 1 ASSOCIATEDNO from wms_in where gid=(select top 1 inbsno from wms_out_detail where outbsno=wms_out.bsno))) else (select top 1 WMSNO from wms where gid=(select top 1 inbsno from wms_out_detail where outbsno=wms_out.bsno)) end)"//需求编号SR2017071300002-2
+ ", WMSNO = (case when(CHARGEUNIT = 'CBM' or CHARGEUNIT = '箱') then(select top 1 WMSNO from wms where gid = (select top 1 ASSOCIATEDNO from wms_in where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno)))"
+ " else ISNULL("
+ " (select top 1 WMSNO from wms where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno)),"
+ " (select top 1 WMSNO from wms where gid = (select top 1 ASSOCIATEDNO from wms_in where gid = (select top 1 inbsno from wms_out_detail where outbsno = wms_out.bsno)))) end)"
+ ", CONTRACTNO=(select top 1 CONTRACTNO from wms where gid=(select top 1 ASSOCIATEDNO from wms_in where gid=(select top 1 inbsno from wms_out_detail where outbsno=wms_out.bsno)))"//需求编号SR2017071300002-2
+ ", ISBONDED=isnull((select top 1 (case when ISBONDED=1 then '是' else '否' end) as ISBONDED from op_seai where bsno=wms_out.ASSOCIATEDNO),'否')"//需求编号SR2017071300002-2
+ ",dbo.F_Str_wmsoutgoodsname(wms_out.BSNO) DETAILGOODSNAME"//需求编号SR2017071300002-2
+ ",FilePath FilePath_2"
+ ",(SELECT distinct wi.PICIHAO+'/' FROM wms_in wi where wi.GID in (select inbsno from wms_out_detail where BSNO=wms_out.bsno) and ISNULL(wi.PICIHAO,'')<>'' FOR XML PATH(''))as PICIHAO "
+ " ,isnull(CNTRTOTAL,'')CNTRTOTAL_2 ,isnull(KGS_OUT,0)KGS_OUT_2 ,isnull(PKGS_OUT,0)PKGS_OUT_2 ,isnull(CBM_OUT,0)CBM_OUT_2 "
+ " , dbo.F_WMSOUTCOUNTRY_CN(BSNO) COUNTRYOFORIGIN_2 "
+ " from wms_out WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null)");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
//
var sortstring = DatasetSort.Getsortstring(sort);
//if (!string.IsNullOrEmpty(sortstring))
//{
// strSql.Append(" order by " + sortstring);
//}
//else
//{
// strSql.Append(" order by DODATE desc");
//}
var strSql2 = new StringBuilder();
strSql2.Append(@"SELECT * from (SELECT row_number() over (");
if (!string.IsNullOrEmpty(sortstring))
{
strSql2.Append(" order by " + sortstring);
}
else
{
strSql2.Append(" order by DODATE desc");
}
strSql2.Append(@") as num , ");
strSql2.Append(strSql);
strSql2.Append(@")as t ");
strSql2.Append(string.Format("where t.num>{0} and t.num<={1} order by t.num ", start, start + limit));
return SetDataHJ(strSql2);
}
private static List<WMSOUT_GuiGe> SetDataHJ(StringBuilder strSql)
{
var headList = new List<WMSOUT_GuiGe>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
WMSOUT_GuiGe data = new WMSOUT_GuiGe();
#region Set DB data to Object
//字段过滤器(判断是否存在该列)
reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= 'EXPRESSEXNO'";
if (reader.GetSchemaTable().DefaultView.Count > 0)
data.EXPRESSEXNO = Convert.ToString(reader["EXPRESSEXNO"]);
reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= 'EXPRESSCORP'";
if (reader.GetSchemaTable().DefaultView.Count > 0)
data.EXPRESSCORP = Convert.ToString(reader["EXPRESSCORP"]);
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号
data.ASSOCIATEDNO = (reader["ASSOCIATEDNO"] == null ? "" : Convert.ToString(reader["ASSOCIATEDNO"]));//关联号
data.BSNO = (reader["BSNO"] == null ? "" : Convert.ToString(reader["BSNO"]));//仓单明细号
data.ISDETAIL = (reader["ISDETAIL"] == null? "-1": Convert.ToString(reader["ISDETAIL"]));
data.CLIENTGID = (reader["CLIENTGID"] == null ? "" : Convert.ToString(reader["CLIENTGID"]));//CLIENTGID
data.CLIENTCODE = (reader["CLIENTCODE"] == null ? "" : Convert.ToString(reader["CLIENTCODE"]));//客户编码
data.CUSTOMERNAME = (reader["CUSTOMERNAME"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME"]));//客户名称
if (reader["DODATE"] != null && reader["DODATE"].ToString().Trim().IndexOf("0001") < 0 && reader["DODATE"].ToString().Trim().IndexOf("1900") < 0 && reader["DODATE"].ToString().Trim() != "")
{
data.DODATE = Convert.ToDateTime(reader["DODATE"]);//操作时间
}
data.STORAGECODE = (reader["STORAGECODE"] == null ? "" : Convert.ToString(reader["STORAGECODE"]));//仓库编码
data.STORAGENAME = (reader["STORAGENAME"] == null ? "" : Convert.ToString(reader["STORAGENAME"]));//仓库名称
data.AREACODE = (reader["AREACODE"] == null ? "" : Convert.ToString(reader["AREACODE"]));//储位编码
data.AREANAME = (reader["AREANAME"] == null ? "" : Convert.ToString(reader["AREANAME"]));//储位名称
data.GOODSCODE = (reader["GOODSCODE"] == null ? "" : Convert.ToString(reader["GOODSCODE"]));//货物编号
data.GOODSNAME = (reader["GOODSNAME"] == null ? "" : Convert.ToString(reader["GOODSNAME"]));//货物名称
if (reader["GOODSNAME"] == null || reader["GOODSNAME"] == "")
{
//data.GOODSNAME = (reader["DETAILGOODSNAME"] == null ? "" : Convert.ToString(reader["DETAILGOODSNAME"]));//如无则使用明细内品名
data.GOODSNAME = (reader["GOODSNAMEID"] == null ? "" : Convert.ToString(reader["GOODSNAMEID"]));//品名20181210xxq Modified
}
data.GOODSTYPE = (reader["GOODSTYPE"] == null ? "" : Convert.ToString(reader["GOODSTYPE"]));//货物类型
data.GOODSMODEL = (reader["GOODSMODEL"] == null ? "" : Convert.ToString(reader["GOODSMODEL"]));//型号
data.GOODSSTANDARD = (reader["GOODSSTANDARD"] == null ? "" : Convert.ToString(reader["GOODSSTANDARD"]));//规格
data.GOODSPACK = (reader["GOODSPACK"] == null ? "" : Convert.ToString(reader["GOODSPACK"]));//包装
data.GOODSPFSL = (reader["GOODSPFSL"] == null ? 0 : Convert.ToDecimal(reader["GOODSPFSL"]));//出库量
data.GOODSOUTFEE = (reader["GOODSOUTFEE"] == null ? 0 : Convert.ToDecimal(reader["GOODSOUTFEE"]));//仓储费用
data.TRUCKNO = (reader["TRUCKNO"] == null ? "" : Convert.ToString(reader["TRUCKNO"]));//TRUCKNO
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
data.ISDELETE = (reader["ISDELETE"] == null ? false : Convert.ToBoolean(reader["ISDELETE"]));//是否废除
if (reader["DELETETIME"] != null && reader["DELETETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["DELETETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["DELETETIME"].ToString().Trim() != "")
{
data.DELETETIME = Convert.ToDateTime(reader["DELETETIME"]);//废除时间
}
data.DELETEUSER = (reader["DELETEUSER"] == null ? "" : Convert.ToString(reader["DELETEUSER"]));//废除操作人
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人
if (reader["CREATETIME"] != null && reader["CREATETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["CREATETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["CREATETIME"].ToString().Trim() != "")
{
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
}
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//最后一次更新操作人
if (reader["MODIFIEDTIME"] != null && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFIEDTIME"].ToString().Trim() != "")
{
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//最后一次更新操作时间
}
data.GOODSPACKPFSL = (reader["GOODSPACKPFSL"] == null ? 0 : Convert.ToDecimal(reader["GOODSPACKPFSL"]));//GOODSPACKPFSL
data.TRUCKNAME = (reader["TRUCKNAME"] == null ? "" : Convert.ToString(reader["TRUCKNAME"]));//TRUCKNAME
data.WMSOP = (reader["WMSOP"] == null ? "" : Convert.ToString(reader["WMSOP"]));//WMSOP
data.STOREMAN = (reader["STOREMAN"] == null ? "" : Convert.ToString(reader["STOREMAN"]));//STOREMAN
data.ISLOCK = (reader["ISLOCK"] == null ? false : Convert.ToBoolean(reader["ISLOCK"]));//ISLOCK
data.LOCKUSER = (reader["LOCKUSER"] == null ? "" : Convert.ToString(reader["LOCKUSER"]));//LOCKUSER
if (reader["LOCKTIME"] != null && reader["LOCKTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["LOCKTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["LOCKTIME"].ToString().Trim() != "")
{
data.LOCKTIME = Convert.ToDateTime(reader["LOCKTIME"]);//LOCKTIME
}
data.GOODSOUTFEEAP = (reader["GOODSOUTFEEAP"] == null ? 0 : Convert.ToDecimal(reader["GOODSOUTFEEAP"]));//GOODSOUTFEEAP
data.ARFEE = (reader["ARFEE"] == null ? 0 : Convert.ToDecimal(reader["ARFEE"]));//ARFEE
data.ARFEE_2 = (reader["ARFEE_2"] == null ? 0 : Convert.ToDecimal(reader["ARFEE_2"]));//ARFEE_2需求编号SR2017073000001
data.APFEE = (reader["APFEE"] == null ? 0 : Convert.ToDecimal(reader["APFEE"]));//APFEE
data.INSPECTIONNO = (reader["INSPECTIONNO"] == null ? "" : Convert.ToString(reader["INSPECTIONNO"]));//INSPECTIONNO
data.CUSTOMNO = (reader["CUSTOMNO"] == null ? "" : Convert.ToString(reader["CUSTOMNO"]));//CUSTOMNO
data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//CORPID
data.CLIENTNAMEOLD = (reader["CLIENTNAMEOLD"] == null ? "" : Convert.ToString(reader["CLIENTNAMEOLD"]));//CLIENTNAMEOLD
if (reader["OLDCUSTFEEDATE"] != null && reader["OLDCUSTFEEDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["OLDCUSTFEEDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["OLDCUSTFEEDATE"].ToString().Trim() != "")
{
data.OLDCUSTFEEDATE = Convert.ToDateTime(reader["OLDCUSTFEEDATE"]);//OLDCUSTFEEDATE
}
data.CLIENTBSNO = (reader["CLIENTBSNO"] == null ? "" : Convert.ToString(reader["CLIENTBSNO"]));//CLIENTBSNO
data.ARCLIENT = (reader["ARCLIENT"] == null ? "" : Convert.ToString(reader["ARCLIENT"]));//ARCLIENT
data.INGIDNEW = (reader["INGIDNEW"] == null ? "" : Convert.ToString(reader["INGIDNEW"]));//INGIDNEW
data.TOTALNO = (reader["TOTALNO"] == null ? "" : Convert.ToString(reader["TOTALNO"]));//TOTALNO
data.REMARK2 = (reader["REMARK2"] == null ? "" : Convert.ToString(reader["REMARK2"]));//REMARK2
if (reader["VALIDDATE"] != null && reader["VALIDDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["VALIDDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["VALIDDATE"].ToString().Trim() != "")
{
data.VALIDDATE = Convert.ToDateTime(reader["VALIDDATE"]);//VALIDDATE
}
data.CHARGEUNIT = (reader["CHARGEUNIT"] == null ? "" : Convert.ToString(reader["CHARGEUNIT"]));//CHARGEUNIT
data.MBLNONEW = (reader["MBLNONEW"] == null ? "" : Convert.ToString(reader["MBLNONEW"]));//MBLNONEW
data.ISCHANGE = (reader["ISCHANGE"] == null ? false : Convert.ToBoolean(reader["ISCHANGE"]));//ISCHANGE
data.MARKETVALUE = (reader["MARKETVALUE"] == null ? 0 : Convert.ToDecimal(reader["MARKETVALUE"]));//MARKETVALUE
data.ARCLIENTWMSOUT = (reader["ARCLIENTWMSOUT"] == null ? "" : Convert.ToString(reader["ARCLIENTWMSOUT"]));//ARCLIENTWMSOUT
data.ISCOLLECTING = (reader["ISCOLLECTING"] == null ? false : Convert.ToBoolean(reader["ISCOLLECTING"]));//ISCOLLECTING
//data.WMSOUTSTATUS = (reader["WMSOUTSTATUS"] == null ? 0 : Convert.ToInt32(reader["WMSOUTSTATUS"]));//WMSOUTSTATUS
if ((reader["WMSOUTSTATUS"] == null) || (reader["WMSOUTSTATUS"] == DBNull.Value))
{
data.WMSOUTSTATUS = 0;
}
else
{
Convert.ToInt32(reader["WMSOUTSTATUS"]);
}
data.BZTCHNO = (reader["BZTCHNO"] == null ? "" : Convert.ToString(reader["BZTCHNO"]));//BZTCHNO
data.MODIFIEDUSERNAME = (reader["MODIFIEDUSERNAME"] == null ? "" : Convert.ToString(reader["MODIFIEDUSERNAME"]));
data.GOODSNAMEID = (reader["GOODSNAMEID"] == null ? "" : Convert.ToString(reader["GOODSNAMEID"]));//品名gid
data.WHS_CODE = (reader["WHS_CODE"] == null ? "" : Convert.ToString(reader["WHS_CODE"]));//库别
data.ACCDATE = (reader["ACCDATE"] == null ? "" : Convert.ToString(reader["ACCDATE"]));//会计期间
data.FEESTATUS = (reader["FEESTATUS"] == null ? false : Convert.ToBoolean(reader["FEESTATUS"]));//费用状态
data.FEESTATUSREF = (reader["FEESTATUSREF"] == null ? "" : Convert.ToString(reader["FEESTATUSREF"]));//费用状态
data.DRFEESTATUS = getfeestatus(Convert.ToString(reader["DRFEESTATUS"]));//需求编号SR2017071300002-1
data.CRFEESTATUS = getfeestatus(Convert.ToString(reader["CRFEESTATUS"]));//需求编号SR2017071300002-1
data.MBLNO = (reader["MBLNO"] == null ? "" : Convert.ToString(reader["MBLNO"]));//需求编号SR2017071300002-2
data.WMSNO = (reader["WMSNO"] == null ? "" : Convert.ToString(reader["WMSNO"]));//需求编号SR2017071300002-2
data.ISBONDED = (reader["ISBONDED"] == null ? "" : Convert.ToString(reader["ISBONDED"]));//需求编号SR2017071300002-2
data.FilePath = (reader["FilePath_2"] == null ? "" : Convert.ToString(reader["FilePath"]));
data.PICIHAO = (reader["PICIHAO"] == null ? "" : Convert.ToString(reader["PICIHAO"]));//批次号
if ((reader["EIP"] == null) || (reader["EIP"] == DBNull.Value))
{
data.EIP = false;
}
else
{
data.EIP=Convert.ToBoolean(reader["EIP"]);
}
//SR2020030900003
if (BasicDataRefDAL.ReadFieldExist(reader, "CNTRTOTAL_2"))
data.CNTRTOTAL = (reader["CNTRTOTAL"] == DBNull.Value ? "" : Convert.ToString(reader["CNTRTOTAL"]));
//Convert.ToString(reader["CNTRTOTAL"]);
if (BasicDataRefDAL.ReadFieldExist(reader, "KGS_OUT_2"))
data.KGS_OUT = (reader["KGS_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["KGS_OUT"]));//KGS_OUT
if (BasicDataRefDAL.ReadFieldExist(reader, "PKGS_OUT_2"))
data.PKGS_OUT = (reader["PKGS_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["PKGS_OUT"]));//KGS_OUT
if (BasicDataRefDAL.ReadFieldExist(reader, "CBM_OUT_2"))
data.CBM_OUT = (reader["CBM_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["CBM_OUT"]));//KGS_OUT
if (BasicDataRefDAL.ReadFieldExist(reader, "COUNTRYOFORIGIN_2"))
data.COUNTRYOFORIGIN = reader["COUNTRYOFORIGIN"].ToString();
#endregion
headList.Add(data);
}
reader.Close();
reader.Dispose();
}
return headList;
}
public static int getTotalCountHJ(string strCondition, string userid, string usercode, string companyid)
{
var rangstr = GetRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(*) ");
strSql.Append(" from wms_out WITH(NOLOCK) where (ISDELETE=0 or ISDELETE is null) ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
int cnt = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
cnt = Convert.ToInt32(reader[0]);
}
}
return cnt;
}
/// <summary>
/// 获取费用状态的显示文字需求编号SR2017071300002-1
/// </summary>
/// <param name="feestatusint"></param>
/// <returns></returns>
public static string getfeestatus(string feestatusint)
{
var result = "";
if (feestatusint == "0:")
{
return "审核通过";
}
else if (feestatusint == "1:")
{
return "录入状态";
}
else if (feestatusint == "2:")
{
return "提交审核";
}
else if (feestatusint == "8:")
{
return "部分结算";
}
else if (feestatusint == "9:")
{
return "结算完毕";
}
else if (feestatusint == "")
{
return "未录入";
}
else if (feestatusint == "3:")
{
return "申请修改";
}
else if (feestatusint == "4:")
{
return "申请删除";
}
else if (feestatusint == "6:")
{
return "驳回提交";
}
else if (feestatusint == "7:")
{
return "驳回申请";
}
else if (feestatusint.IndexOf("9:") > -1)
{
return "部分结算";
}
else if (feestatusint.IndexOf("8:") > -1)
{
return "部分结算";
}
else if (feestatusint.IndexOf("0:") > -1)
{
return "部分审核";
}
else if (feestatusint.IndexOf("2:") > -1)
{
return "部分提交";
}
else if (feestatusint.IndexOf("6:") > -1)
{
return "驳回提交";
}
else if (feestatusint.IndexOf("7:") > -1)
{
return "驳回申请";
}
return result;
}
#endregion
#region 查询明细表
static public List<VwWmsDetailModels> GetDetailList(string opStatus, string strCondition,string outType, string userid, string usercode, string companyid)
{
var strSql = new StringBuilder();
string sTableName = "VW_WMS_DETAIL_NULL_OUTSTOCKDETAIL";
if (opStatus == "add")
{
if (outType == "StockOut")
{
sTableName = "VW_WMS_DETAIL_NULL_OUTSTOCK";
}
var rangstr = GetImpRangDAStr("index", userid, usercode, companyid);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
}
else if (opStatus == "edit")
{
sTableName = "VW_WMS_DETAIL";
}
strSql.Append(" SELECT *,ISBONDEDNAME=(case when ISBONDED=1 then '是' else '否' end)");
//20191206
strSql.Append(" ,(select GOODSCKQSTOCK from wms_out_detail where gid = gid_out) GOODSCKQSTOCK ");
strSql.Append(" from " + sTableName + " WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" and ISLOCK=1 and ISLOCK2=0 " );
if (outType == "StockOut")
{
strSql.Append(" and isnull(isdetail, -1) <> '1' ");
}
else if (outType == "StockOutDetail")
{
strSql.Append(" and isnull(isdetail, -1) <> '0' ");
}
strSql.Append(" order by WMSDATE,CUSTOMERNAME,BLNO,WMSNO,BSNO_OUT");
return SetDetail(strSql);
}
private static List<VwWmsDetailModels> SetDetail(StringBuilder strSql)
{
var headList = new List<VwWmsDetailModels>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
VwWmsDetailModels data = new VwWmsDetailModels();
#region Set DB data to Object
//字段过滤器(判断是否存在该列)
reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= 'EXPRESSEXNO'";
if (reader.GetSchemaTable().DefaultView.Count > 0)
data.EXPRESSEXNO = Convert.ToString(reader["EXPRESSEXNO"]);
reader.GetSchemaTable().DefaultView.RowFilter = "ColumnName= 'EXPRESSCORP'";
if (reader.GetSchemaTable().DefaultView.Count > 0)
data.EXPRESSCORP = Convert.ToString(reader["EXPRESSCORP"]);
data.PICIHAO = (reader["PICIHAO"] == null ? "" : Convert.ToString(reader["PICIHAO"]));//批次号
data.NID = (reader["NID"] == null ? "" : Convert.ToString(reader["NID"]));//NID
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
data.ASSOCIATEDNO = (reader["ASSOCIATEDNO"] == null ? "" : Convert.ToString(reader["ASSOCIATEDNO"]));//ASSOCIATEDNO
data.BSNO = (reader["BSNO"] == null ? "" : Convert.ToString(reader["BSNO"]));//BSNO
data.BLNO = (reader["BLNO"] == null ? "" : Convert.ToString(reader["BLNO"]));//BLNO
data.CONTRACTNO = (reader["CONTRACTNO"] == null ? "" : Convert.ToString(reader["CONTRACTNO"]));//CONTRACTNO
data.STORAGENAME = (reader["STORAGENAME"] == null ? "" : Convert.ToString(reader["STORAGENAME"]));//STORAGENAME
data.GOODSNAME = Convert.ToString(reader["GOODSNAME"]);
//if (reader["GOODSNAME"] == null || reader["GOODSNAME"] == "")
//{
//data.GOODSNAME = (reader["DETAILGOODSNAME"] == null ? "" : Convert.ToString(reader["DETAILGOODSNAME"]));//如无则使用明细内品名
//data.GOODSNAME = (reader["GOODSNAMEID"] == null ? "" : Convert.ToString(reader["GOODSNAMEID"]));//品名20181210xxq Modified
//}
data.GOODSMODEL = (reader["GOODSMODEL"] == null ? "" : Convert.ToString(reader["GOODSMODEL"]));//GOODSMODEL
data.GOODSPACK = (reader["GOODSPACK"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSPACK"]));//GOODSPACK
data.CHARGEUNIT = (reader["CHARGEUNIT"] == null ? "" : Convert.ToString(reader["CHARGEUNIT"]));//CHARGEUNIT
data.GOODSRKSL = (reader["GOODSRKSL"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSRKSL"]));//GOODSRKSL
data.GOODSSTOCK = (reader["GOODSSTOCK"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSSTOCK"]));//GOODSSTOCK
data.FREESTORAGEPERIOD = (reader["FREESTORAGEPERIOD"] == DBNull.Value ? 0 : Convert.ToInt32(reader["FREESTORAGEPERIOD"]));//FREESTORAGEPERIOD
data.ISLOCK = (reader["ISLOCK"] == DBNull.Value ? 0 : Convert.ToInt32(reader["ISLOCK"]));//ISLOCK
if (reader["LOCKTIME"] != null && reader["LOCKTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["LOCKTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["LOCKTIME"].ToString().Trim() != "")
{
data.LOCKTIME = Convert.ToDateTime(reader["LOCKTIME"]);//LOCKTIME
}
data.LOCKUSER = (reader["LOCKUSER"] == null ? "" : Convert.ToString(reader["LOCKUSER"]));//LOCKUSER
data.ISDELETE = (reader["ISDELETE"] == null ? false : Convert.ToBoolean(reader["ISDELETE"]));//ISDELETE
if (reader["DELETETIME"] != null && reader["DELETETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["DELETETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["DELETETIME"].ToString().Trim() != "")
{
data.DELETETIME = Convert.ToDateTime(reader["DELETETIME"]);//DELETETIME
}
data.DELETEUSER = (reader["DELETEUSER"] == null ? "" : Convert.ToString(reader["DELETEUSER"]));//DELETEUSER
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//MODIFIEDUSER
if (reader["MODIFIEDTIME"] != null && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFIEDTIME"].ToString().Trim() != "")
{
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//MODIFIEDTIME
}
data.GID_OUT = (reader["GID_OUT"] == null ? "" : Convert.ToString(reader["GID_OUT"]));//GID_OUT
data.ASSOCIATEDNO_OUT = (reader["ASSOCIATEDNO_OUT"] == null ? "" : Convert.ToString(reader["ASSOCIATEDNO_OUT"]));//ASSOCIATEDNO_OUT
data.INBSNO_OUT = (reader["INBSNO_OUT"] == null ? "" : Convert.ToString(reader["INBSNO_OUT"]));//INBSNO_OUT
data.OUTBSNO_OUT = (reader["OUTBSNO_OUT"] == null ? "" : Convert.ToString(reader["OUTBSNO_OUT"]));//OUTBSNO_OUT
data.BSNO_OUT = (reader["BSNO_OUT"] == null ? "" : Convert.ToString(reader["BSNO_OUT"]));//BSNO_OUT
data.CLIENTGID_OUT = (reader["CLIENTGID_OUT"] == null ? "" : Convert.ToString(reader["CLIENTGID_OUT"]));//CLIENTGID_OUT
data.CLIENTCODE_OUT = (reader["CLIENTCODE_OUT"] == null ? "" : Convert.ToString(reader["CLIENTCODE_OUT"]));//CLIENTCODE_OUT
data.CUSTOMERNAME_OUT = (reader["CUSTOMERNAME_OUT"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME_OUT"]));//CUSTOMERNAME_OUT
data.DODATE_OUT = (reader["DODATE_OUT"] == null ? "" : Convert.ToString(reader["DODATE_OUT"]));//DODATE_OUT
data.STORAGECODE_OUT = (reader["STORAGECODE_OUT"] == null ? "" : Convert.ToString(reader["STORAGECODE_OUT"]));//STORAGECODE_OUT
data.STORAGENAME_OUT = (reader["STORAGENAME_OUT"] == null ? "" : Convert.ToString(reader["STORAGENAME_OUT"]));//STORAGENAME_OUT
data.AREACODE_OUT = (reader["AREACODE_OUT"] == null ? "" : Convert.ToString(reader["AREACODE_OUT"]));//AREACODE_OUT
data.AREANAME_OUT = (reader["AREANAME_OUT"] == null ? "" : Convert.ToString(reader["AREANAME_OUT"]));//AREANAME_OUT
data.GOODSCODE_OUT = (reader["GOODSCODE_OUT"] == null ? "" : Convert.ToString(reader["GOODSCODE_OUT"]));//GOODSCODE_OUT
data.GOODSNAME_OUT = (reader["GOODSNAME_OUT"] == null ? "" : Convert.ToString(reader["GOODSNAME_OUT"]));//GOODSNAME_OUT
data.GOODSTYPE_OUT = (reader["GOODSTYPE_OUT"] == null ? "" : Convert.ToString(reader["GOODSTYPE_OUT"]));//GOODSTYPE_OUT
data.GOODSMODEL_OUT = (reader["GOODSMODEL_OUT"] == null ? "" : Convert.ToString(reader["GOODSMODEL_OUT"]));//GOODSMODEL_OUT
data.GOODSSTANDARD_OUT = (reader["GOODSSTANDARD_OUT"] == null ? "" : Convert.ToString(reader["GOODSSTANDARD_OUT"]));//GOODSSTANDARD_OUT
data.GOODSPACK_OUT = (reader["GOODSPACK_OUT"] == null ? "" : Convert.ToString(reader["GOODSPACK_OUT"]));//GOODSPACK_OUT
data.CHARGEUNIT_OUT = (reader["CHARGEUNIT_OUT"] == null ? "" : Convert.ToString(reader["CHARGEUNIT_OUT"]));//CHARGEUNIT_OUT
data.GOODSPFSL_OUT = (reader["GOODSPFSL_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSPFSL_OUT"]));//GOODSPFSL_OUT
data.TRUCKNO_OUT = (reader["TRUCKNO_OUT"] == null ? "" : Convert.ToString(reader["TRUCKNO_OUT"]));//TRUCKNO_OUT
data.CREATEUSER_OUT = (reader["CREATEUSER_OUT"] == null ? "" : Convert.ToString(reader["CREATEUSER_OUT"]));//CREATEUSER_OUT
if (reader["CREATETIME_OUT"] != DBNull.Value && reader["CREATETIME_OUT"].ToString().Trim().IndexOf("0001") < 0 && reader["CREATETIME_OUT"].ToString().Trim().IndexOf("1900") < 0 && reader["CREATETIME_OUT"].ToString().Trim() != "")
{
data.CREATETIME_OUT = Convert.ToDateTime(reader["CREATETIME_OUT"]);//CREATETIME_OUT
}
data.REMARK_OUT = (reader["REMARK_OUT"] == null ? "" : Convert.ToString(reader["REMARK_OUT"]));//REMARK_OUT
data.GOODSPACKPFSL_OUT = (reader["GOODSPACKPFSL_OUT"] == null ? 0 : Convert.ToDecimal(reader["GOODSPACKPFSL_OUT"]));//GOODSPACKPFSL_OUT
data.ARFEE = (reader["ARFEE"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["ARFEE"]));//ARFEE
data.APFEE = (reader["APFEE"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["APFEE"]));//APFEE
data.ARFEE_OUT = (reader["ARFEE_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["ARFEE_OUT"]));//ARFEE_OUT
data.ARFEE_2_OUT = (reader["ARFEE_2_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["ARFEE_2_OUT"]));//ARFEE_2_OUT需求编号SR2017073000001
data.APFEE_OUT = (reader["APFEE_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["APFEE_OUT"]));//APFEE_OUT
data.GOODSOUTFEE_OUT = (reader["GOODSOUTFEE_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSOUTFEE_OUT"]));//GOODSOUTFEE_OUT
data.GOODSOUTFEEAP_OUT = (reader["GOODSOUTFEEAP_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSOUTFEEAP_OUT"]));//GOODSOUTFEEAP_OUT
data.WMSNO = (reader["WMSNO"] == null ? "" : Convert.ToString(reader["WMSNO"]));//WMSNO
data.WMSDATE = (reader["WMSDATE"] == null ? "" : Convert.ToString(reader["WMSDATE"]));//WMSDATE
data.CUSTOMERNAME = (reader["CUSTOMERNAME"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME"]));//CUSTOMERNAME
data.WMSOP = (reader["WMSOP"] == null ? "" : Convert.ToString(reader["WMSOP"]));//WMSOP
data.STOREMAN = (reader["STOREMAN"] == null ? "" : Convert.ToString(reader["STOREMAN"]));//STOREMAN
data.GOODSPACKSTOCK = (reader["GOODSPACKSTOCK"] == null ? 0 : Convert.ToDecimal(reader["GOODSPACKSTOCK"]));//GOODSPACKSTOCK
data.TRUCKNAME = (reader["TRUCKNAME"] == null ? "" : Convert.ToString(reader["TRUCKNAME"]));//TRUCKNAME
if (reader["STARTBILLINGDATE"] != DBNull.Value && reader["STARTBILLINGDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["STARTBILLINGDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["STARTBILLINGDATE"].ToString().Trim() != "")
{
data.STARTBILLINGDATE = Convert.ToDateTime(reader["STARTBILLINGDATE"]);//STARTBILLINGDATE
}
data.CUSTOMNO = (reader["CUSTOMNO"] == null ? "" : Convert.ToString(reader["CUSTOMNO"]));//CUSTOMNO
data.CUSTNO = (reader["CUSTNO"] == null ? "" : Convert.ToString(reader["CUSTNO"]));//CUSTNO
data.GOODSSTANDARD = (reader["GOODSSTANDARD"] == null ? "" : Convert.ToString(reader["GOODSSTANDARD"]));//GOODSSTANDARD
data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//CORPID
data.GOODSPACKACTUAL = (reader["GOODSPACKACTUAL"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSPACKACTUAL"]));//GOODSPACKACTUAL
data.GOODSRKSLACTUAL = (reader["GOODSRKSLACTUAL"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSRKSLACTUAL"]));//GOODSRKSLACTUAL
data.CLIENTNAMEOLD = (reader["CLIENTNAMEOLD"] == null ? "" : Convert.ToString(reader["CLIENTNAMEOLD"]));//CLIENTNAMEOLD
data.ISCHANGE = (reader["ISCHANGE"] == DBNull.Value ? false : Convert.ToBoolean(reader["ISCHANGE"]));//ISCHANGE
data.ISCHANGE_OUT = (reader["ISCHANGE_OUT"] == DBNull.Value ? false : Convert.ToBoolean(reader["ISCHANGE_OUT"]));//ISCHANGE_OUT
data.WMSGID = (reader["WMSGID"] == null ? "" : Convert.ToString(reader["WMSGID"]));//WMSGID
data.OUTGID = (reader["OUTGID"] == null ? "" : Convert.ToString(reader["OUTGID"]));//OUTGID
data.OUTREMARK = (reader["OUTREMARK"] == null ? "" : Convert.ToString(reader["OUTREMARK"]));//OUTREMARK
data.OUTREMARK2 = (reader["OUTREMARK2"] == null ? "" : Convert.ToString(reader["OUTREMARK2"]));//OUTREMARK2
data.GOODSNAMEID = (reader["GOODSNAMEID"] == null ? "" : Convert.ToString(reader["GOODSNAMEID"]));//品名gid
data.WHS_CODE = (reader["WHS_CODE"] == null ? "" : Convert.ToString(reader["WHS_CODE"]));//库别
data.AREANAME = (reader["AREANAME"] == null ? "" : Convert.ToString(reader["AREANAME"]));//储位
data.BZTCHNO = (reader["BZTCHNO"] == null ? "" : Convert.ToString(reader["BZTCHNO"]));//电子账册号
data.GOODNO = (reader["GOODNO"] == null ? "" : Convert.ToString(reader["GOODNO"]));//料号
data.ACCDATE = (reader["ACCDATE"] == null ? "" : Convert.ToString(reader["ACCDATE"]));//会计期间
data.FEESTATUSREF = (reader["FEESTATUSREF"] == null ? "" : Convert.ToString(reader["FEESTATUSREF"]));//费用状态
data.ACCDATE_OUT = (reader["ACCDATE_OUT"] == null ? "" : Convert.ToString(reader["ACCDATE_OUT"]));//会计期间_OUT
data.FEESTATUS = (reader["FEESTATUS"] == DBNull.Value ? false : Convert.ToBoolean(reader["FEESTATUS"]));//费用状态_OUT
data.FEESTATUSREF_OUT = (reader["FEESTATUSREF_OUT"] == null ? "" : Convert.ToString(reader["FEESTATUSREF_OUT"]));//费用状态_OUT
data.GOODSSLICE = (reader["GOODSSLICE"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSSLICE"]));//包装件数//需求编号SR2017061800001-7
data.ISLOCK2 = (reader["ISLOCK2"] == DBNull.Value ? 0 : Convert.ToInt32(reader["ISLOCK2"]));//需求编号SR2017061400006-1
data.ISBONDED = (reader["ISBONDED"] == DBNull.Value ? 0 : Convert.ToInt32(reader["ISBONDED"]));//需求编号SR2017061900001-1
data.ISBONDEDNAME = (reader["ISBONDEDNAME"] == null ? "" : Convert.ToString(reader["ISBONDEDNAME"]));//需求编号SR2017062600003
data.GOODSNUM = (reader["GOODSNUM"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSNUM"]));//完税件数
data.WeiWanShui = (reader["WeiWanShui"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["WeiWanShui"]));//未完税件数//需求编号SR2017062200002
if (data.ISBONDED == 0)
{
data.GOODSNUM = 0;//是否保税SR2017062600003
data.WeiWanShui = 0;//是否保税SR2017062600003
}
data.GOODSSLICE_OUT = (reader["GOODSSLICE_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSSLICE_OUT"]));//需求编号SR2017071100001
data.TRUCKTYPE_OUT = (reader["TRUCKTYPE_OUT"] == null ? "" : Convert.ToString(reader["TRUCKTYPE_OUT"]));//需求编号SR2017073000001
data.ZHUANGXIEGONGID_OUT = (reader["ZHUANGXIEGONGID_OUT"] == null ? "" : Convert.ToString(reader["ZHUANGXIEGONGID_OUT"]));//需求编号SR2017073000001
data.ZHUANGXIEGONG_OUT = (reader["ZHUANGXIEGONG_OUT"] == null ? "" : Convert.ToString(reader["ZHUANGXIEGONG_OUT"]));//需求编号SR2017073000001
data.TRUCKKGS_OUT = (reader["TRUCKKGS_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["TRUCKKGS_OUT"]));//需求编号SR2017073000001
data.QianFengNO = (reader["QianFengNO"] == null ? "" : Convert.ToString(reader["QianFengNO"]));//需求编号SR2017073000001
data.ARCLIENTWMSOUT = (reader["ARCLIENTWMSOUT"] == null ? "" : Convert.ToString(reader["ARCLIENTWMSOUT"]));//需求编号SR2017073000001
data.ARCLIENT = (reader["ARCLIENT"] == null ? "" : Convert.ToString(reader["ARCLIENT"]));//需求编号SR2017073000001
data.TRUCKNAME_OUT = (reader["TRUCKNAME_OUT"] == null ? "" : Convert.ToString(reader["TRUCKNAME_OUT"]));//需求编号SR2017073000001
data.GOODSPACKPFSL_OUT_2 = (reader["GOODSPACKPFSL_OUT"] == null ? 0 : Convert.ToDecimal(reader["GOODSPACKPFSL_OUT"]));//需求编号SR2017073000001
if (reader["OLDCUSTFEEDATE"] != null && reader["OLDCUSTFEEDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["OLDCUSTFEEDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["OLDCUSTFEEDATE"].ToString().Trim() != "")
{
data.OLDCUSTFEEDATE = Convert.ToDateTime(reader["OLDCUSTFEEDATE"]);//需求编号SR2017073000001
}
if (reader["STARTBILLINGDATEAP"] != null && reader["STARTBILLINGDATEAP"].ToString().Trim().IndexOf("0001") < 0 && reader["STARTBILLINGDATEAP"].ToString().Trim().IndexOf("1900") < 0 && reader["STARTBILLINGDATEAP"].ToString().Trim() != "")
{
data.STARTBILLINGDATEAP = Convert.ToDateTime(reader["STARTBILLINGDATEAP"]);//需求编号SR2017073000001
}
data.CHIMA1 = (reader["CHIMA1"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["CHIMA1"]));//CHIMA1
data.CHIMA2 = (reader["CHIMA2"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["CHIMA2"]));//CHIMA2
data.GOODSKGS = (reader["GOODSKGS"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSKGS"]));//GOODSKGS
data.ZHONGLIANG2 = (reader["ZHONGLIANG2"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["ZHONGLIANG2"]));//ZHONGLIANG2
data.COUNTRY = (reader["COUNTRY"] == null ? "" : Convert.ToString(reader["COUNTRY"]));//COUNTRY
data.COUNTRYID = (reader["COUNTRYID"] == null ? "" : Convert.ToString(reader["COUNTRYID"]));//COUNTRYID
data.ISDETAIL = (reader["ISDETAIL"] == null ? "-1" : Convert.ToString(reader["ISDETAIL"]));//ISDETAIL
data.TRAYNO = (reader["TRAYNO"] == null ? "" : Convert.ToString(reader["TRAYNO"]));//TRAYNO
data.EIPCNTRNO = (reader["EIPCNTRNO"] == null ? "" : Convert.ToString(reader["EIPCNTRNO"]));//EIPCNTRNO
data.CNTRNO = (reader["CNTRNO"] == null ? "" : Convert.ToString(reader["CNTRNO"]));//CNTRNO
data.SEALNO = (reader["SEALNO"] == null ? "" : Convert.ToString(reader["SEALNO"]));//SEALNO
data.ZHUANGXIEFEI = (reader["ZHUANGXIEFEI"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["ZHUANGXIEFEI"]));
data.MODEL = (reader["MODEL"] == null ? "" : Convert.ToString(reader["MODEL"]));//MODEL
data.QUOTANO = (reader["QUOTANO"] == null ? "" : Convert.ToString(reader["QUOTANO"]));//MODEL
data.DRIVERIDCARD = (reader["DRIVERIDCARD"] == null ? "" : Convert.ToString(reader["DRIVERIDCARD"]));//MODEL
data.LOADERFEE = (reader["LOADERFEE"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["LOADERFEE"]));//LOADERFEE
data.RENTAREA = (reader["RENTAREA"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["RENTAREA"]));//LOADERFEE
data.GOODSCKQSTOCK = (reader["GOODSCKQSTOCK"] == DBNull.Value ? "0" : Convert.ToString(reader["GOODSCKQSTOCK"]));//出库时库存
if (BasicDataRefDAL.ReadFieldExist(reader, "CNTRTOTAL"))
data.CNTRTOTAL = (reader["CNTRTOTAL"] == null ? "" : Convert.ToString(reader["CNTRTOTAL"]));
else data.CNTRTOTAL = "";
if (BasicDataRefDAL.ReadFieldExist(reader, "KGS_OUT"))
data.KGS_OUT = (reader["KGS_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["KGS_OUT"]));//
else data.KGS_OUT = 0;
if (BasicDataRefDAL.ReadFieldExist(reader, "PKGS_OUT"))
data.PKGS_OUT = (reader["PKGS_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["PKGS_OUT"]));//
else data.PKGS_OUT = 0;
if (BasicDataRefDAL.ReadFieldExist(reader, "CBM_OUT"))
data.CBM_OUT = (reader["CBM_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["CBM_OUT"]));//
else data.CBM_OUT = 0;
#endregion
headList.Add(data);
}
reader.Close();
reader.Dispose();
}
return headList;
}
//出库是否一致
static public string JudgeOutType(string strCondition, string outType, string userid, string usercode, string companyid)
{
var strSql = new StringBuilder();
string sTableName = "VW_WMS_DETAIL_NULL_OUTSTOCKDETAIL";
if (outType == "StockOut")
{
sTableName = "VW_WMS_DETAIL_NULL_OUTSTOCK";
}
strSql.Append(" SELECT count(NID) ");
strSql.Append(" from " + sTableName + " WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
if (outType == "StockOut")
{
strSql.Append(" and isdetail='1' " );
}
else
{
strSql.Append(" and isdetail='0' ");
}
Database db = DatabaseFactory.CreateDatabase();
string value = "0";
var rst = db.ExecuteScalar(CommandType.Text, strSql.ToString());
if (rst != null && rst != DBNull.Value && rst.ToString() != "")
{
value = rst.ToString();
}
return value;
}
static public VwWmsDetailModels GetData(string condition, string companyid, string userid)
{
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(userid);
var strSql = new StringBuilder();
strSql.Append("SELECT *,ISBONDEDNAME=(case when ISBONDED=1 then '是' else '否' end),(select GOODSCKQSTOCK from wms_out_detail where gid = gid_out) GOODSCKQSTOCK");
strSql.Append(" from VW_WMS_DETAIL WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" and " + condition);
}
strSql.Append(" order by CUSTOMERNAME,BLNO,WMSNO,WMSDATE,BSNO_OUT");
var list = SetDetail(strSql);
if (list.Count > 0)
return list[0];
return new VwWmsDetailModels();
}
static public VwWmsDetailModels GetDataEdit(string condition, string companyid, string userid)
{
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(userid);
var strSql = new StringBuilder();
strSql.Append("SELECT *,ISBONDEDNAME=(case when ISBONDED=1 then '是' else '否' end),(select GOODSCKQSTOCK from wms_out_detail where gid = gid_out) GOODSCKQSTOCK");
strSql.Append(" from VW_WMS_DETAIL WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" and " + condition);
}
strSql.Append(" order by CUSTOMERNAME,BLNO,WMSNO,WMSDATE,BSNO_OUT");
var list = SetDetail(strSql);
if (list.Count > 0)
return list[0];
return new VwWmsDetailModels();
}
static public string GetDataListStr(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT NID as 出库明细GID,CUSTOMERNAME as 客户名称,STORAGENAME as 所属仓库,BLNO as 提单号,WMSNO as 入库单号,WMSDATE as 入库时间,GOODSNAME as 品名,GOODSMODEL as 单位,GOODSSTANDARD as 规格,GOODSPACKSTOCK as 剩余件数,WeiWanShui as 未完税件数,(case when ISBONDED=1 then GOODSNUM else 0 end) as 完税件数,(case when ISBONDED=1 then WeiWanShui else 0 end) as 未完税件数,GOODSPACKPFSL_OUT as 出库件数,GOODSSLICE_OUT as 出库包装件数,REMARK_OUT as 明细备注,OUTREMARK as 出库备注,OUTBSNO_OUT as 出库单号,DODATE_OUT as 出库日期,WHS_CODE as 库别,AREANAME as 储位,BZTCHNO as 电子账册号,GOODNO as 料号,ACCDATE_OUT as 会计期间,是否保税业务=(case when ISBONDED=1 then '是' else '否' end),TRUCKTYPE_OUT as 车辆类型,ZHUANGXIEGONGID_OUT as 装卸工,TRUCKKGS_OUT as 平均重量,QianFengNO as 铅封号,ARCLIENTWMSOUT as 应收仓储客户,ARCLIENT as 应收出库客户,TRUCKNAME_OUT as 应付客户");//,GOODSSTOCK as 剩余库存//需求编号SR2017061800001-7、SR2017062200002、SR2017071100001、SR2017071300002-2//需求编号SR2017073000001
strSql.Append(" from VW_WMS_DETAIL WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" order by CUSTOMERNAME,BLNO,WMSNO,WMSDATE,BSNO_OUT");
return strSql.ToString();
}
#endregion
#region 提取规则编号 getCodeRuleWmsOut
/// <summary>
/// 提取规则编号
/// </summary>
/// OutBsno = getCodeRuleWmsOut("出库单号", "BSNO");
/// <param name="strRULENAME">规则项目名称</param>
/// <param name="strfield">需要加规则的字段</param>
/// <param name="iCount">需要添加的行数</param>
/// <returns></returns>
static public String getCodeRuleWmsOut(string strRULENAME, string strfield, int iCount, string strUserID, string strCompanyID)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
//调用编码规则
string strRULEYEAR = "";
string strRULECONTENT = "";
string strCODENAME = "";
string strDEPTNO = "";
string strRULENOLENGTH = "";
int iRULENOLENGTH = 0;
int inum = 0;
string strCONTENT = "";
DataSet ds = T_ALL_DA.GetAllSQL("select *,getdate() DODATE from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
{
getCodeRuleEnabled(strRULENAME, strfield);
//
if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("业务日期"))
{
if (ds.Tables[0].Rows[0]["DODATE"].ToString().Trim() == "")
{
return "";
}
DateTime dETD = System.Convert.ToDateTime(ds.Tables[0].Rows[0]["DODATE"].ToString().Trim());
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy") + dETD.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy") + dETD.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = dETD.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = dETD.ToString("yy");
}
}
}
else if (ds.Tables[0].Rows[0]["RULEDATE"].ToString().Trim().Equals("自然月份"))
{
DateTime fwqdate = System.Convert.ToDateTime(T_ALL_DA.GetStrSQL("fwqdate", "select fwqdate=getdate()"));
if (ds.Tables[0].Rows[0]["ISCLEAREDINEARLY"].ToString().Trim().Equals("True"))
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy") + fwqdate.ToString("MM");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy") + fwqdate.ToString("MM");
}
}
else
{
if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "4")
{
strRULEYEAR = fwqdate.ToString("yyyy");
}
else if (ds.Tables[0].Rows[0]["RULEYEAR"].ToString().Trim() == "2")
{
strRULEYEAR = fwqdate.ToString("yy");
}
}
}
//
if (ds.Tables[0].Rows[0]["ISCOMPANY"].ToString().Trim().Equals("True"))
{
strCODENAME = T_ALL_DA.GetStrSQL("CODENAME", "select CODENAME from [company] where GID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
}
if (ds.Tables[0].Rows[0]["ISDEPT"].ToString().Trim().Equals("True"))
{
strDEPTNO = T_ALL_DA.GetStrSQL("DEPTNO", "select DEPTNO from [sys_dept] where LINKID=(select top 1 COMPANYID from user_company where USERID='" + strUserID + "')");
}
strRULECONTENT = ds.Tables[0].Rows[0]["RULECONTENT"].ToString().Trim();
strRULECONTENT = strRULECONTENT.Replace("《COMPANY》", strCODENAME);
strRULECONTENT = strRULECONTENT.Replace("《DEPT》", strDEPTNO);
//
if (ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim() == "")
{
iRULENOLENGTH = 0;
}
else
{
iRULENOLENGTH = int.Parse(ds.Tables[0].Rows[0]["RULENOLENGTH"].ToString().Trim());
}
strCONTENT = strRULECONTENT + strRULEYEAR;
//获取分公司的票号头字符
string tempBANKSHEAD = T_ALL_DA.GetStrSQL("BANKSHEAD", "SELECT TOP 1 BANKSHEAD FROM company WHERE GID='" + strCompanyID.Trim() + "'");
strCONTENT = tempBANKSHEAD + strCONTENT;
//
strRULENOLENGTH = T_ALL_DA.GetStrSQL(strfield, "select top 1 " + strfield + " from [wms_out] where " + strfield + " like '" + strCONTENT.Trim() + "%' and isnull(ISDELETE,0)=0 order by " + strfield + " DESC");
if (strRULENOLENGTH == "")
{
strRULENOLENGTH = "1";
}
else
{
strRULENOLENGTH = strRULENOLENGTH.Replace(strCONTENT.Trim(), "");
inum = int.Parse(strRULENOLENGTH.Trim());
inum = inum + iCount;
strRULENOLENGTH = inum.ToString();
}
int j = iRULENOLENGTH - strRULENOLENGTH.Length;
for (int i = 1; i <= j; i++)
{
strRULENOLENGTH = "0" + strRULENOLENGTH;
}
//
strCONTENT = strCONTENT + strRULENOLENGTH;
return strCONTENT;
}
}
}
return "";
}
#endregion
#region 规则编号_是否生成之后允许编辑 getCodeRuleEnabled
/// <summary>
/// 规则编号_是否生成之后允许编辑
/// </summary>
/// <param name="strRULENAME">规则项目名称</param>
/// <param name="strfield">需要加规则的字段</param>
/// <returns></returns>
static public Boolean getCodeRuleEnabled(string strRULENAME, string strfield)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
bool blRule = false;
//是否生成之后允许编辑
DataSet ds = T_ALL_DA.GetAllSQL("select * from code_rule where RULENAME='" + strRULENAME.Trim() + "' and RULETYPE=3");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["ISSTARTUSING"].ToString().Trim().Equals("True"))
{
if (strfield == "BSNO")
{
if (ds.Tables[0].Rows[0]["ISALLOWEDITS"].ToString().Trim().Equals("True"))
{
blRule = false;
}
else
{
blRule = true;
}
}
}
}
}
return blRule;
}
#endregion
#region 出库单更新入库(包括明细出库和整体出库明细出库在存储过程中被定义为【ASSOCIATEDNO=wmsGID的入库明细条数=1】)
public static bool UpdateWMSIN(string wmsGID,string wmsOutGID)
{
var iError = 0;
string strSql = "exec Proc_WMSOUT_Update '" + wmsGID + "','" + wmsOutGID + "' ";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
iError = Convert.ToInt16(reader["result"]);
break;
}
reader.Close();
}
if (iError == 0)
{
return true;
}
else
{
return false;
}
}
#endregion
#region 删除出库
public static DBResult Delete(string gids,bool eip, string strUserID)
{
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
var result = new DBResult();
#region 判断货权转移入库单是否入账
string sSQL3 = "select count(*) as hj from wms where gid in (select INGIDNEW from wms_out where ISCHANGE=1 and BSNO in ('" + gids.Replace(",", "','") + "')) and (ISLOCK=1 or ISLOCK2=1 or FEESTATUS=1)";
int iHJ2 = int.Parse(T_ALL_DA.GetStrSQL("hj", sSQL3));
if (iHJ2 > 0)
{
result.Success = false;
result.Message = "出库单的货权转移入库单已经入账或锁定等,不允许做删除操作!";
return result;
}
#endregion
var iError = 0;
int iHJ = int.Parse(T_ALL_DA.GetStrSQL("hj", "select top 1 count(*) as hj from ch_fee where BSNO in (select GID from wms_out where BSNO in ('" + gids.Replace(",", "','") + "'))"));
if (iHJ == 0)
{
#region 出库件数 返 入库库存//需求编号SR2017073000001
var strOutBSNO = gids.Replace(",", "','");
string strSql = "exec Proc_WMSOUT_DelByBSNO '" + strOutBSNO + "' ";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
iError = Convert.ToInt16(reader["result"]);
break;
}
reader.Close();
}
if (iError == 0)
{
result.Success = true;
if (eip)
{
result= WMSEIPStockDAL.UpdateTrayState(strOutBSNO);
}
result.Message = "操作成功";
return result;
}
else
{
result.Success = false;
result.Message = "部分操作失败,请尽快联系管理员解决,并告知返回值" + iError + ",避免造成更大的数据损失!";
return result;
}
#endregion
#region 注释掉原来删除出库
/*
var sOUTBSNO = " and OUTBSNO_OUT in ('" + gids.Replace(",", "','") + "')";
string sSQL = "update wms_in set GOODSPACKSTOCK=GOODSPACK-isnull((select sum(GOODSPACKPFSL_OUT) as GOODSPACKPFSL_OUT from VW_WMS_DETAIL where INBSNO_OUT=wms_in.GID and GID_OUT not in (select GID_OUT from VW_WMS_DETAIL where 1=1" + sOUTBSNO + ")),0),GOODSSTOCK=GOODSRKSL-isnull((select sum(GOODSPFSL_OUT) as GOODSPFSL_OUT from VW_WMS_DETAIL where INBSNO_OUT=wms_in.GID and GID_OUT not in (select GID_OUT from VW_WMS_DETAIL where 1=1" + sOUTBSNO + ")),0) where GID in (select INBSNO_OUT from VW_WMS_DETAIL where 1=1" + sOUTBSNO + ")";
bool bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (!bl)
{
iError = -1;
}
else
{
sSQL = "update wms set GOODSPACKSTOCK=(select sum(GOODSPACKSTOCK) as GOODSPACKSTOCK from wms_in where ASSOCIATEDNO=wms.gid),GOODSSTOCK=(select sum(GOODSSTOCK) as GOODSSTOCK from wms_in where ASSOCIATEDNO=wms.gid) where gid in (select ASSOCIATEDNO from wms_in where GID in (select INBSNO_OUT from VW_WMS_DETAIL where 1=1" + sOUTBSNO + "))";
bl = T_ALL_DA.GetExecuteSqlCommand(sSQL);
if (!bl)
{
iError = -2;
}
}
*/
#endregion
#region 注释掉原来删除出库
/*
if (iError < 0)
{
result.Success = false;
result.Message = "部分操作失败,请尽快联系管理员解决,并告知返回值" + iError + ",避免造成更大的数据损失!";
return result;
}
else
{
Database db = DatabaseFactory.CreateDatabase();
using (var conn = db.CreateConnection())
{
conn.Open();
var tran = conn.BeginTransaction();
try
{
//删除入库明细
var cmdDelete = db.GetSqlStringCommand("delete from wms_in where ASSOCIATEDNO in (select INGIDNEW from wms_out where ISCHANGE=1 and BSNO in ('" + gids.Replace(",", "','") + "'))");
db.ExecuteNonQuery(cmdDelete, tran);
//删除主表信息
cmdDelete = db.GetSqlStringCommand("delete from wms where gid in (select INGIDNEW from wms_out where ISCHANGE=1 and BSNO in ('" + gids.Replace(",", "','") + "'))");
db.ExecuteNonQuery(cmdDelete, tran);
//删除入库仓储费率表
cmdDelete = db.GetSqlStringCommand("delete from wms_rate where BSNO in (select INGIDNEW from wms_out where ISCHANGE=1 and BSNO in ('" + gids.Replace(",", "','") + "'))");
db.ExecuteNonQuery(cmdDelete, tran);
cmdDelete = db.GetSqlStringCommand("delete from wms_out_detail where 1=1 and OUTBSNO in ('" + gids.Replace(",", "','") + "')");
db.ExecuteNonQuery(cmdDelete, tran);
cmdDelete = db.GetSqlStringCommand("delete from wms_out where 1=1 and BSNO in ('" + gids.Replace(",", "','") + "')");
db.ExecuteNonQuery(cmdDelete, tran);
tran.Commit();
}
catch (Exception)
{
iError = -3;
tran.Rollback();
result.Success = false;
result.Message = "部分操作失败,请尽快联系管理员解决,并告知返回值" + iError + ",避免造成更大的数据损失!";
return result;
}
}
result.Success = true;
result.Message = "操作成功";
return result;
}
*/
#endregion
}
else
{
result.Success = false;
result.Message = "已经录入费用的出库单不允许删除!";
return result;
}
}
#endregion
#region 计算仓储费
/// <summary>
/// 计算仓储费
/// </summary>
/// <param name="sqlTran">事务</param>
/// <param name="strSTARTBILLINGDATE">开始计费日期</param>
/// <param name="strOLDCUSTFEEDATE">上家承担仓储期限</param>
/// <param name="strINBSNO">出库明细关联的入库单wms或wms_in的BSNO</param>
/// <param name="strCUSTOMERNAME">出库主表的客户名称</param>
/// <param name="outnums">出库量</param>
/// <param name="strASSOCIATEDNO">关联wms_out_detail的GID</param>
/// <param name="strFEETYPE">区别费用收、付类型</param>
/// <param name="strUserID">登陆用户GID</param>
/// <param name="strShowName">登陆用户名</param>
/// <param name="sBillno">出库单号或其他单据号</param>
/// <param name="ck_jsfee">是否计算仓储费</param>
/// <param name="ck_jsfee">是否库存</param>
/// <returns></returns>
public static String getWmsRate(string strSTARTBILLINGDATE, string strOLDCUSTFEEDATE, string strINBSNO, string strCUSTOMERNAME, Decimal outnums, string strASSOCIATEDNO, int strFEETYPE, string strUserID, string strShowName, string sBillno, string sOUTGID, bool ck_jsfee, bool isKuCun)
{
string sR = "";
//int iState = 0;
int result = 0;
string Sqlstr = "";
#region 计算仓储费
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
WmsOutDetailDA WmsOutDetailDA = new EntityDA.WmsOutDetailDA();
IList<WmsRateDetail> tempWmsRateDetailDetailEntities = new List<WmsRateDetail>();
int totalfeedays = 0;//总计费区间仓储天数
int feedays = 0;//区间仓储数
int prescale = 0;//总计费区间仓储数
int feeMonth = 0;//区间仓储月数
Decimal sumfee = 0;//总仓储费
string strSTARTBILLINGDATE2 = strSTARTBILLINGDATE;//按区间计费的开始计费日期
#region 删除费率出库明细表的区间仓储费
Sqlstr = "delete from wms_rate_detail where ASSOCIATEDNO = '" + strASSOCIATEDNO.Trim() + "' and FEETYPE=" + strFEETYPE;
//iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
bool bl = T_ALL_DA.GetExecuteSqlCommand(Sqlstr);
if (!bl)
{
result = -9;
//sqlTran.Rollback();
//Clearh();
return result.ToString();
}
#endregion
if (ck_jsfee)//是否计算仓储费
{
#region 如果入库有免仓储期,则出库时插入费率出库明细表
//按仓储费率计算仓储费
Sqlstr = "SELECT top 1 * FROM wms where GID='" + strINBSNO + "' or gid in (select ASSOCIATEDNO from wms_in where gid='" + strINBSNO + "')";
//DataSet dsrate = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr, null);
DataSet dsrate = T_ALL_DA.GetAllSQL(Sqlstr);
if (dsrate != null)
{
if (dsrate.Tables[0].Rows.Count > 0)
{
string sAP = dsrate.Tables[0].Rows[0]["FREESTORAGEPERIOD"].ToString().Trim();
if (strFEETYPE == 2)
{
sAP = dsrate.Tables[0].Rows[0]["FREESTORAGEPERIODAP"].ToString().Trim();
}
if (sAP != "0")
{
WmsRateDetail model3 = new WmsRateDetail();
model3.FEEPRICE = 0;
model3.GOODSPFSL = outnums;
model3.OUTFEE = 0;
model3.FEEUNIT = dsrate.Tables[0].Rows[0]["CHARGEUNIT"].ToString().Trim() + "天";
model3.STARTBILLINGDATE = DateTime.Parse(dsrate.Tables[0].Rows[0]["WMSDATE"].ToString().Trim());
DateTime dt = DateTime.Parse(dsrate.Tables[0].Rows[0]["STARTBILLINGDATE"].ToString().Trim()).AddDays(-1);
if (DateTime.Parse(strOLDCUSTFEEDATE) < dt)
{
dt = DateTime.Parse(strOLDCUSTFEEDATE);
}
model3.ENDBILLINGDATE = dt;
model3.FEESCALE = int.Parse(GetDaysCount("day", model3.STARTBILLINGDATE.ToString().Trim(), dt.ToString().Trim()).ToString());
model3.FEEGRADE = 0;
model3.REMARK = "";
model3.CREATEUSER = strUserID;
model3.MODIFIEDUSER = strUserID;
model3.ASSOCIATEDNO = strASSOCIATEDNO;
model3.CUSTOMERNAME = strCUSTOMERNAME;
model3.FEETYPE = strFEETYPE;
model3.WMSOUTGID = sOUTGID;
tempWmsRateDetailDetailEntities.Add(model3);
}
}
}
#endregion
feedays = GetDaysCount("day", strSTARTBILLINGDATE, strOLDCUSTFEEDATE.Trim());//WmsOutEntity.DODATE.ToString() 出库-开始计费日期+1
if (feedays > 0)
{
totalfeedays = feedays;
//按仓储费率计算仓储费
Sqlstr = "SELECT GID,FEEGRADE,FEETYPE,FEESCALE,FEEPRICE,ADDPRICE,FEEUNIT,convert(char(10),ENDBILLINGDATE,20) AS ENDBILLINGDATE,REMARK,CREATEUSER,CREATETIME,BSNO,CAPPRICE FROM wms_rate where (BSNO='" + strINBSNO + "' or BSNO in (select ASSOCIATEDNO from wms_in where gid='" + strINBSNO + "')) and FEETYPE=" + strFEETYPE + " order by FEEGRADE ";
//dsrate = SqlHelper.ExecuteQueryDataset(sqlTran, CommandType.Text, Sqlstr, null);
dsrate = T_ALL_DA.GetAllSQL(Sqlstr);
if (dsrate != null)
{
if (dsrate.Tables[0].Rows.Count > 0)
{
int nowscale = 0;//区间计费区间(仓储月数/天数)
Decimal price = 0;//计费单价
Decimal gradefee = 0;//区间仓储费
int nowgrade = 1;
for (int i = 0; i < dsrate.Tables[0].Rows.Count; i++)
{
if (isKuCun)
{
if (DateTime.Parse(strSTARTBILLINGDATE) > DateTime.Parse(dsrate.Tables[0].Rows[i]["ENDBILLINGDATE"].ToString()))
{
continue;
}
}
WmsRateDetail model = new WmsRateDetail();
//nowgrade = int.Parse(dsrate.Tables[0].Rows[i]["FEEGRADE"].ToString());//计费等级
nowscale = int.Parse(dsrate.Tables[0].Rows[i]["FEESCALE"].ToString());//计费区间
price = Decimal.Parse(dsrate.Tables[0].Rows[i]["FEEPRICE"].ToString());//计费单价
Decimal ADDPRICE = Decimal.Parse(dsrate.Tables[0].Rows[i]["ADDPRICE"].ToString());//增值价
Decimal CAPPRICE = Decimal.Parse(dsrate.Tables[0].Rows[i]["CAPPRICE"].ToString());//
string FEEUNIT = dsrate.Tables[0].Rows[i]["FEEUNIT"].ToString();//计费单位
string ENDBILLINGDATE = dsrate.Tables[0].Rows[i]["ENDBILLINGDATE"].ToString();//结束计费日期
//计算区间是按天或按月
string DorM = "day";
if (FEEUNIT.IndexOf("月") > -1)
{
DorM = "month";
}
#region 按区间计算仓储费
feedays = GetDaysCount(DorM, strSTARTBILLINGDATE2, strOLDCUSTFEEDATE.Trim());//总仓储月数
if (feedays > nowscale) //总仓储月数 > 区间计费区间(仓储月数/天数)
{
feeMonth = GetDaysCount(DorM, strSTARTBILLINGDATE2, ENDBILLINGDATE.Trim());//i区间仓储月数
if (feeMonth > nowscale)//i区间仓储月数 > 区间计费区间(仓储月数/天数)
{
int sjMonth = 0;//实际仓储月数
int sjMonth2 = 0;//实际仓储月数,如果是最后一条的判断数
if (feedays > feeMonth)//总仓储月数 > i区间仓储月数
{
sjMonth = nowscale;// feeMonth;// (feeMonth - nowscale);//实际仓储月数
sjMonth2 = feeMonth;//实际仓储月数,如果是最后一条的判断数
if ((i + 1) == dsrate.Tables[0].Rows.Count)//即最后一条时,以后的时间都按最后一条取值
{
if (ADDPRICE <= 0)//增值价>0则求增值费率
{
sjMonth = feedays;//(feedays - nowscale);//实际仓储月数
ENDBILLINGDATE = strOLDCUSTFEEDATE;
}
sjMonth2 = feedays;// (feedays - nowscale);//实际仓储月数
}
}
else//总仓储月数 <= i区间仓储月数
{
//sjMonth = feedays;//(feedays - nowscale);//实际仓储月数
sjMonth = nowscale;// feeMonth;// (feeMonth - nowscale);//实际仓储月数
sjMonth2 = feedays;//实际仓储月数,如果是最后一条的判断数
ENDBILLINGDATE = strOLDCUSTFEEDATE;
}
//
#region 增值价>0则求增值费率
if (ADDPRICE > 0)//增值价>0则求增值费率
{
//int idiv = (int)(sjMonth / nowscale);
//int imod = (int)(sjMonth % nowscale);
int idiv = (int)(sjMonth2 / nowscale);
int imod = (int)(sjMonth2 % nowscale);
Decimal dprice = price;//计费单价
for (int j = 0; j < idiv; j++)//循环求增值费率
{
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
DateTime dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddDays(nowscale - 1);
int dtDays = sjMonth;// nowscale;
string FEEUNIT2 = FEEUNIT;
if (FEEUNIT.IndexOf("月") > -1)
{
dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddMonths(nowscale).AddDays(-1);
if (dtENDBILLINGDATE > DateTime.Parse(ENDBILLINGDATE))//strOLDCUSTFEEDATE
{
if ((i + 1) == dsrate.Tables[0].Rows.Count && dtENDBILLINGDATE > DateTime.Parse(strOLDCUSTFEEDATE))//即最后一条时,以后的时间都按最后一条取值
{
dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
}
else
{
dtENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);//strOLDCUSTFEEDATE
}
}
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
dtDays = GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
}
//--- END ---
gradefee = outnums * dprice * dtDays;// nowscale;//出库量*计费单价*实际仓储月数
sumfee += gradefee;
prescale += dtDays;//nowscale;//累计天数
//
WmsRateDetail model1 = new WmsRateDetail();
model1.FEEPRICE = dprice;
model1.GOODSPFSL = outnums;
model1.FEESCALE = dtDays;// nowscale;
model1.OUTFEE = gradefee;
model1.FEEUNIT = FEEUNIT2;
model1.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
model1.ENDBILLINGDATE = dtENDBILLINGDATE;
//model1.ENDBILLINGDATE = model1.STARTBILLINGDATE.AddDays(nowscale - 1);
//if (FEEUNIT.IndexOf("月") > -1)
//{
// DateTime dt = model1.STARTBILLINGDATE.AddMonths(nowscale).AddDays(-1);
// model1.ENDBILLINGDATE = dt;
// if (dt > DateTime.Parse(strOLDCUSTFEEDATE))
// {
// model1.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
// }
//}
model1.FEEGRADE = nowgrade;
model1.REMARK = "";
model1.CREATEUSER = strUserID;
model1.MODIFIEDUSER = strUserID;
model1.ASSOCIATEDNO = strASSOCIATEDNO;
model1.CUSTOMERNAME = strCUSTOMERNAME;
model1.FEETYPE = strFEETYPE;
model1.WMSOUTGID = sOUTGID;
tempWmsRateDetailDetailEntities.Add(model1);
//
nowgrade++;
if (CAPPRICE != 0)
{
if (dprice < CAPPRICE)
{
dprice += ADDPRICE;
}
else
{
dprice = CAPPRICE;
}
}
else
{
dprice += ADDPRICE;
}
strSTARTBILLINGDATE2 = (model1.ENDBILLINGDATE.AddDays(1)).ToString();//按区间计费的开始计费日期
}
//
if (imod > 0)//增值费率余数大于0则实际仓储月份等于imod
{
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
DateTime dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddDays(imod - 1);
int dtDays = imod;// nowscale;
string FEEUNIT2 = FEEUNIT;
if (FEEUNIT.IndexOf("月") > -1)
{
dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddMonths(imod).AddDays(-1);
if (dtENDBILLINGDATE > DateTime.Parse(ENDBILLINGDATE))//strOLDCUSTFEEDATE
{
if ((i + 1) == dsrate.Tables[0].Rows.Count && dtENDBILLINGDATE > DateTime.Parse(strOLDCUSTFEEDATE))//即最后一条时,以后的时间都按最后一条取值
{
dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
}
else
{
dtENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);//strOLDCUSTFEEDATE
}
}
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
dtDays = GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
}
//--- END ---
//dprice += ADDPRICE;
gradefee = outnums * dprice * dtDays;// imod;//出库量*计费单价*实际仓储月数
sumfee += gradefee;
prescale += dtDays;//imod;//累计天数
//
model.FEEPRICE = dprice;
model.GOODSPFSL = outnums;
model.FEESCALE = dtDays;//imod;
model.OUTFEE = gradefee;
model.FEEUNIT = FEEUNIT2;
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
model.ENDBILLINGDATE = dtENDBILLINGDATE;
//model.ENDBILLINGDATE = model.STARTBILLINGDATE.AddDays(imod - 1);
//if (FEEUNIT.IndexOf("月") > -1)
//{
// DateTime dt = model.STARTBILLINGDATE.AddMonths(imod).AddDays(-1);
// model.ENDBILLINGDATE = dt;
// if (dt > DateTime.Parse(strOLDCUSTFEEDATE))
// {
// model.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
// }
//}
model.FEEGRADE = nowgrade;
model.REMARK = "";
model.CREATEUSER = strUserID;
model.MODIFIEDUSER = strUserID;
model.ASSOCIATEDNO = strASSOCIATEDNO;
model.CUSTOMERNAME = strCUSTOMERNAME;
model.FEETYPE = strFEETYPE;
model.WMSOUTGID = sOUTGID;
tempWmsRateDetailDetailEntities.Add(model);
//
nowgrade++;
strSTARTBILLINGDATE2 = (model.ENDBILLINGDATE.AddDays(1)).ToString();//按区间计费的开始计费日期
}
}
else
{
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
DateTime dtENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);
int dtDays = sjMonth;// nowscale;
string FEEUNIT2 = FEEUNIT;
if (FEEUNIT.IndexOf("月") > -1)
{
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
dtDays = GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
}
//--- END ---
gradefee = outnums * price * dtDays;// sjMonth;//出库量*计费单价*实际仓储月数
sumfee += gradefee;
prescale += dtDays;//sjMonth;//累计天数
//
model.FEEPRICE = price;
model.GOODSPFSL = outnums;
model.FEESCALE = dtDays;//sjMonth;
model.OUTFEE = gradefee;
model.FEEUNIT = FEEUNIT2;
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
model.ENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);
model.FEEGRADE = nowgrade;
model.REMARK = "";
model.CREATEUSER = strUserID;
model.MODIFIEDUSER = strUserID;
model.ASSOCIATEDNO = strASSOCIATEDNO;
model.CUSTOMERNAME = strCUSTOMERNAME;
model.FEETYPE = strFEETYPE;
model.WMSOUTGID = sOUTGID;
tempWmsRateDetailDetailEntities.Add(model);
//
nowgrade++;
strSTARTBILLINGDATE2 = (DateTime.Parse(ENDBILLINGDATE).AddDays(1)).ToString();//按区间计费的开始计费日期
}
#endregion
//结束费率区间的循环
if (feedays <= feeMonth)//总仓储月数 <= i区间仓储月数
{
break;//结束费率区间的循环
}
}
else//i区间仓储月数 <= 区间计费区间(仓储月数/天数)
{
int sjMonth = 0;//实际仓储月数
int sjMonth2 = 0;//实际仓储月数,如果是最后一条的判断数
if (feedays > feeMonth)//总仓储月数 > i区间仓储月数
{
sjMonth = feeMonth;//实际仓储月数
sjMonth2 = feeMonth;//实际仓储月数,如果是最后一条的判断数
if ((i + 1) == dsrate.Tables[0].Rows.Count)//即最后一条时,以后的时间都按最后一条取值
{
if (ADDPRICE <= 0)//增值价>0则求增值费率
{
sjMonth = feedays;// (feedays - nowscale);//实际仓储月数
ENDBILLINGDATE = strOLDCUSTFEEDATE;
}
sjMonth2 = feedays;// (feedays - nowscale);//实际仓储月数,如果是最后一条的判断数
}
}
else//总仓储月数 <= i区间仓储月数
{
//sjMonth = feedays;//(feedays - nowscale);//实际仓储月数
sjMonth = nowscale;// feeMonth;// (feeMonth - nowscale);//实际仓储月数
sjMonth2 = feedays;//实际仓储月数,如果是最后一条的判断数
ENDBILLINGDATE = strOLDCUSTFEEDATE;
}
//
#region 增值价>0则求增值费率
if (ADDPRICE > 0)//增值价>0则求增值费率
{
//int idiv = (int)(sjMonth / nowscale);
//int imod = (int)(sjMonth % nowscale);
int idiv = (int)(sjMonth2 / nowscale);
int imod = (int)(sjMonth2 % nowscale);
Decimal dprice = price;//计费单价
for (int j = 0; j < idiv; j++)//循环求增值费率
{
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
DateTime dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddDays(nowscale - 1);
int dtDays = sjMonth;// nowscale;
string FEEUNIT2 = FEEUNIT;
if (FEEUNIT.IndexOf("月") > -1)
{
dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddMonths(nowscale).AddDays(-1);
if (dtENDBILLINGDATE > DateTime.Parse(strOLDCUSTFEEDATE))
{
dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
}
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
dtDays = GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
}
//--- END ---
gradefee = outnums * dprice * dtDays;// nowscale;//出库量*计费单价*实际仓储月数
sumfee += gradefee;
prescale += dtDays;//nowscale;//累计天数
//
WmsRateDetail model1 = new WmsRateDetail();
model1.FEEPRICE = dprice;
model1.GOODSPFSL = outnums;
model1.FEESCALE = dtDays;//nowscale;
model1.OUTFEE = gradefee;
model1.FEEUNIT = FEEUNIT2;
model1.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
model1.ENDBILLINGDATE = dtENDBILLINGDATE;
//model1.ENDBILLINGDATE = model1.STARTBILLINGDATE.AddDays(nowscale - 1);
//if (FEEUNIT.IndexOf("月") > -1)
//{
// DateTime dt = model1.STARTBILLINGDATE.AddMonths(nowscale).AddDays(-1);
// model1.ENDBILLINGDATE = dt;
// if (dt > DateTime.Parse(strOLDCUSTFEEDATE))
// {
// model1.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
// }
//}
model1.FEEGRADE = nowgrade;
model1.REMARK = "";
model1.CREATEUSER = strUserID;
model1.MODIFIEDUSER = strUserID;
model1.ASSOCIATEDNO = strASSOCIATEDNO;
model1.CUSTOMERNAME = strCUSTOMERNAME;
model1.FEETYPE = strFEETYPE;
model1.WMSOUTGID = sOUTGID;
tempWmsRateDetailDetailEntities.Add(model1);
//
nowgrade++;
if (CAPPRICE != 0)
{
if (dprice < CAPPRICE)
{
dprice += ADDPRICE;
}
else
{
dprice = CAPPRICE;
}
}
else
{
dprice += ADDPRICE;
}
strSTARTBILLINGDATE2 = (model1.ENDBILLINGDATE.AddDays(1)).ToString();//按区间计费的开始计费日期
}
//
if (imod > 0)//增值费率余数大于0则实际仓储月份等于imod
{
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
DateTime dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddDays(imod - 1);
int dtDays = imod;// nowscale;
string FEEUNIT2 = FEEUNIT;
if (FEEUNIT.IndexOf("月") > -1)
{
dtENDBILLINGDATE = dtSTARTBILLINGDATE.AddMonths(imod).AddDays(-1);
if (dtENDBILLINGDATE > DateTime.Parse(strOLDCUSTFEEDATE))
{
dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
}
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
dtDays = GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
}
//--- END ---
//dprice += ADDPRICE;
gradefee = outnums * dprice * dtDays;// imod;//出库量*计费单价*实际仓储月数
sumfee += gradefee;
prescale += dtDays;//imod;//累计天数
//
model.FEEPRICE = dprice;
model.GOODSPFSL = outnums;
model.FEESCALE = dtDays;//imod;
model.OUTFEE = gradefee;
model.FEEUNIT = FEEUNIT2;
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
model.ENDBILLINGDATE = dtENDBILLINGDATE;
//model.ENDBILLINGDATE = model.STARTBILLINGDATE.AddDays(imod - 1);
//if (FEEUNIT.IndexOf("月") > -1)
//{
// DateTime dt = model.STARTBILLINGDATE.AddMonths(imod).AddDays(-1);
// model.ENDBILLINGDATE = dt;
// if (dt > DateTime.Parse(strOLDCUSTFEEDATE))
// {
// model.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
// }
//}
model.FEEGRADE = nowgrade;
model.REMARK = "";
model.CREATEUSER = strUserID;
model.MODIFIEDUSER = strUserID;
model.ASSOCIATEDNO = strASSOCIATEDNO;
model.CUSTOMERNAME = strCUSTOMERNAME;
model.FEETYPE = strFEETYPE;
model.WMSOUTGID = sOUTGID;
tempWmsRateDetailDetailEntities.Add(model);
//
nowgrade++;
strSTARTBILLINGDATE2 = (model.ENDBILLINGDATE.AddDays(1)).ToString();//按区间计费的开始计费日期
}
}
else
{
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
DateTime dtENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);
int dtDays = sjMonth;//nowscale;
string FEEUNIT2 = FEEUNIT;
if (FEEUNIT.IndexOf("月") > -1)
{
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
dtDays = GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
}
//--- END ---
gradefee = outnums * price * dtDays;//sjMonth;//出库量*计费单价*实际仓储月数
sumfee += gradefee;
prescale += dtDays;//sjMonth;//累计天数
//
model.FEEPRICE = price;
model.GOODSPFSL = outnums;
model.FEESCALE = dtDays;//sjMonth;
model.OUTFEE = gradefee;
model.FEEUNIT = FEEUNIT2;
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
model.ENDBILLINGDATE = DateTime.Parse(ENDBILLINGDATE);
model.FEEGRADE = nowgrade;
model.REMARK = "";
model.CREATEUSER = strUserID;
model.MODIFIEDUSER = strUserID;
model.ASSOCIATEDNO = strASSOCIATEDNO;
model.CUSTOMERNAME = strCUSTOMERNAME;
model.FEETYPE = strFEETYPE;
model.WMSOUTGID = sOUTGID;
tempWmsRateDetailDetailEntities.Add(model);
//
nowgrade++;
strSTARTBILLINGDATE2 = (DateTime.Parse(ENDBILLINGDATE).AddDays(1)).ToString();//按区间计费的开始计费日期
}
#endregion
//结束费率区间的循环
if (feedays <= feeMonth)//总仓储月数 <= i区间仓储月数
{
break;//结束费率区间的循环
}
}
}
else//总仓储月数 <= 区间计费区间(仓储月数/天数)
{
//--- BEGIN --- 如果是月则计算开始和结束日期之间的天数
DateTime dtSTARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
DateTime dtENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
int dtDays = feedays;
string FEEUNIT2 = FEEUNIT;
if (FEEUNIT.IndexOf("月") > -1)
{
FEEUNIT2 = FEEUNIT.Trim().Substring(0, 1) + "天";
dtDays = GetDaysCount("day", dtSTARTBILLINGDATE.ToString().Trim(), dtENDBILLINGDATE.ToString().Trim());//按月的区间天数
}
//--- END ---
gradefee = outnums * price * dtDays;//feedays;//出库量*计费单价*仓储区间(//仓储天数-上一个计费区间(0)
sumfee += gradefee;
prescale += dtDays;//feedays;//累计天数
//
model.FEEPRICE = price;
model.GOODSPFSL = outnums;
model.FEESCALE = dtDays;//feedays;
model.OUTFEE = gradefee;
model.FEEUNIT = FEEUNIT2;
model.STARTBILLINGDATE = DateTime.Parse(strSTARTBILLINGDATE2);
model.ENDBILLINGDATE = DateTime.Parse(strOLDCUSTFEEDATE);
model.FEEGRADE = nowgrade;
model.REMARK = "";
model.CREATEUSER = strUserID;
model.MODIFIEDUSER = strUserID;
model.ASSOCIATEDNO = strASSOCIATEDNO;
model.CUSTOMERNAME = strCUSTOMERNAME;
model.FEETYPE = strFEETYPE;
model.WMSOUTGID = sOUTGID;
tempWmsRateDetailDetailEntities.Add(model);
//
nowgrade++;
strSTARTBILLINGDATE2 = (DateTime.Parse(strOLDCUSTFEEDATE).AddDays(1)).ToString();//按区间计费的开始计费日期
break;//结束费率区间的循环
}
#endregion
}
}
else
{
//仓储费率没有设定
//sqlTran.Rollback();
//result = -2;
//Page.ClientScript.RegisterStartupScript(this.GetType(), "key0", "<script>alert('仓储费率没有设置');</script>");
//Clearh();
//return result;
totalfeedays = 0;
feedays = 0;
sumfee = 0;
}
}
else
{
totalfeedays = 0;
feedays = 0;
sumfee = 0;
}
}
else
{
totalfeedays = 0;
feedays = 0;
sumfee = 0;
}
//
#region 按区间计算仓储费,插入费率出库明细表
if (tempWmsRateDetailDetailEntities != null)//是否有要入库的仓储费
{
if (tempWmsRateDetailDetailEntities.Count > 0)
{
foreach (WmsRateDetail model2 in tempWmsRateDetailDetailEntities)
{
Sqlstr = String.Format("insert into wms_rate_detail(GID,FEEPRICE,GOODSPFSL,OUTFEE,REMARK,CREATEUSER,CREATETIME,ASSOCIATEDNO,CUSTOMERNAME,FEETYPE,FEEGRADE,STARTBILLINGDATE,ENDBILLINGDATE,FEESCALE,FEEUNIT,MODIFIEDUSER,WMSOUTGID)"
+ " values(newid(),'{0}','{1}','{2}','{3}','{4}',getdate(),'{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}')"
, model2.FEEPRICE, model2.GOODSPFSL, model2.OUTFEE, model2.REMARK, model2.CREATEUSER, model2.ASSOCIATEDNO, model2.CUSTOMERNAME, model2.FEETYPE, model2.FEEGRADE, model2.STARTBILLINGDATE, model2.ENDBILLINGDATE, model2.FEESCALE, model2.FEEUNIT, model2.MODIFIEDUSER, model2.WMSOUTGID);
//iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, Sqlstr, null);
//if (iState != 1)
bl = T_ALL_DA.GetExecuteSqlCommand(Sqlstr);
if (!bl)
{
result = -1;
//sqlTran.Rollback();
//Clearh();
return result.ToString();
}
//
string str0 = "insert into sys_log(NAME,LOGTYPE,LOGCONTENT,CREATEUSER) values('添加出库明细的费率明细信息','INSERT 插入操作','" + strShowName + " 添加 费率明细信息 出库单号:" + sBillno.Trim() + " ','" + model2.MODIFIEDUSER.ToString() + "')";
//iState = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, str0, null);
//if (iState != 1)
bl = T_ALL_DA.GetExecuteSqlCommand(str0);
if (!bl)
{
result = -1;
//sqlTran.Rollback();
//Clearh();
return result.ToString();
}
}
}
}
#endregion
}
else
{
tempWmsRateDetailDetailEntities = null;
totalfeedays = 0;
feedays = 0;
sumfee = 0;
}
#endregion
sR = sumfee.ToString() + "" + totalfeedays.ToString();
return sR;
}
#endregion
#region 计算仓储时间差 +1
/// <summary>
/// 计算仓储时间差 +1
/// </summary>
public static int GetDaysCount(string ymd, string indate, string outdate)
{
string strSql = String.Format(" select datediff({0},'{1}','{2}') ", ymd, indate, outdate);
if (ymd == "day")
{
strSql = String.Format(" select datediff({0},'{1}','{2}')+1 ", ymd, indate, outdate);
}
object obj = SqlHelper.GetSingle(SqlHelper.ConnectionStringLocalTransaction, strSql.ToString());
if (obj == null)
{
return 0;
}
else
{
if (ymd == "month")
{
int inum = int.Parse(obj.ToString());
DateTime dt = DateTime.Parse(indate).AddMonths(inum).AddDays(-1);
if (DateTime.Parse(outdate) > dt)
{
inum = inum + 1;
return Convert.ToInt32(inum);
}
}
return Convert.ToInt32(obj);
}
}
#endregion
#region 查询仓储费列表//需求编号SR2017073000001
static public List<WmsRateDetail> GetWmsRateDetailList(string strCondition, string userid, string usercode, string companyid)
{
var strSql = new StringBuilder();
strSql.Append("SELECT *,FEETYPENAME=(case when FEETYPE=1 then '收' else '付' end)");
strSql.Append(" from wms_rate_detail WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" order by WMSOUTGID,ASSOCIATEDNO,FEETYPE,FEEGRADE");
return SetWmsRateDetail(strSql);
}
static public List<WmsRateDetail> GetSettleRateDetailList(string strCondition, string userid, string usercode, string companyid)
{
var strSql = new StringBuilder();
strSql.Append("SELECT *,FEETYPENAME=(case when FEETYPE=1 then '收' else '付' end)");
strSql.Append(" from wms_settle_detail_rate WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" order by WMSOUTGID,ASSOCIATEDNO,FEETYPE,FEEGRADE");
return SetWmsRateDetail(strSql);
}
private static List<WmsRateDetail> SetWmsRateDetail(StringBuilder strSql)
{
var headList = new List<WmsRateDetail>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
WmsRateDetail data = new WmsRateDetail();
#region Set DB data to Object
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//惟一编号
data.ASSOCIATEDNO = (reader["ASSOCIATEDNO"] == null ? "" : Convert.ToString(reader["ASSOCIATEDNO"]));//关联号
data.CUSTOMERNAME = (reader["CUSTOMERNAME"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME"]));//客户名称
data.FEETYPE = (reader["FEETYPE"] == null ? 0 : Convert.ToInt32(reader["FEETYPE"]));//费用类别
data.FEEGRADE = (reader["FEEGRADE"] == null ? 0 : Convert.ToInt32(reader["FEEGRADE"]));//计费等级
if (reader["STARTBILLINGDATE"] != null && reader["STARTBILLINGDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["STARTBILLINGDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["STARTBILLINGDATE"].ToString().Trim() != "")
{
data.STARTBILLINGDATE = Convert.ToDateTime(reader["STARTBILLINGDATE"]);//开始计费日期
}
if (reader["ENDBILLINGDATE"] != null && reader["ENDBILLINGDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["ENDBILLINGDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["ENDBILLINGDATE"].ToString().Trim() != "")
{
data.ENDBILLINGDATE = Convert.ToDateTime(reader["ENDBILLINGDATE"]);//结束计费日期
}
data.FEESCALE = (reader["FEESCALE"] == null ? 0 : Convert.ToInt32(reader["FEESCALE"]));//计费区间
data.FEEUNIT = (reader["FEEUNIT"] == null ? "" : Convert.ToString(reader["FEEUNIT"]));//计费单位
data.FEEPRICE = (reader["FEEPRICE"] == null ? 0 : Convert.ToDecimal(reader["FEEPRICE"]));//计费单价
data.GOODSPFSL = (reader["GOODSPFSL"] == null ? 0 : Convert.ToDecimal(reader["GOODSPFSL"]));//出库量
data.OUTFEE = (reader["OUTFEE"] == null ? 0 : Convert.ToDecimal(reader["OUTFEE"]));//仓储费
data.REMARK = (reader["REMARK"] == null ? "" : Convert.ToString(reader["REMARK"]));//备注
data.CREATEUSER = (reader["CREATEUSER"] == null ? "" : Convert.ToString(reader["CREATEUSER"]));//创建人
if (reader["CREATETIME"] != null && reader["CREATETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["CREATETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["CREATETIME"].ToString().Trim() != "")
{
data.CREATETIME = Convert.ToDateTime(reader["CREATETIME"]);//创建时间
}
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//最后一次操作人
if (reader["MODIFIEDTIME"] != null && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFIEDTIME"].ToString().Trim() != "")
{
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//最后一次操作时间
}
data.WMSOUTGID = (reader["WMSOUTGID"] == null ? "" : Convert.ToString(reader["WMSOUTGID"]));//WMSOUTGID
data.FEETYPENAME = (reader["FEETYPENAME"] == null ? "" : Convert.ToString(reader["FEETYPENAME"]));//WMSOUTGID
#endregion
headList.Add(data);
}
reader.Close();
reader.Dispose();
}
return headList;
}
#endregion
#region 费用入账//需求编号SR2017073000001
public static DBResult setislock(string gids,bool bEIP, string outType,string strUserID, string strCompanyID, string strDEPTNAME, string strSHOWNAME)
{
DBResult result = new DBResult();
if (gids.Trim() == "")
{
result.Success = false;
result.Message = "没有输入任何需要修改的数据";
}
gids = "'" + gids.Trim().Replace(",", "','") + "'";
#region 费用入账
Database db = DatabaseFactory.CreateDatabase();
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{//根据出库GID查询出库费用有多少出库明细就产生多少出库费用
var strSql = new StringBuilder();
strSql.Append("select o.IsDetail AS ISDETAIL,d.inbsno as INBSNO,o.gid as OUTGID,o.bsno as OUTNO,o.ASSOCIATEDNO AS ASSOCIATEDNO, ");
strSql.Append(" o.ARCLIENTWMSOUT as ARCLIENTWMSOUT,isnull(d.GOODSOUTFEE,0) AS GOODSOUTFEE_OUT,");
strSql.Append(" o.TRUCKNAME as TRUCKNAME_OUT,isnull(d.GOODSOUTFEEAP,0) AS GOODSOUTFEEAP_OUT,");
strSql.Append(" isnull(d.ARFEE,0) AS ARFEE_OUT,isnull(d.ARFEE_2,0) AS ARFEE_2_OUT,d.GID OUTDEGID");
strSql.Append(" from wms_out o inner join wms_out_detail d on o.bsno = d.outbsno ");
strSql.Append(" where o.gid in (" + gids + ") and o.ISLOCK=0");
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
int i = 0;
int existVal = 0;
while (reader.Read())
{
WmsOutFeeModel outFee = new WmsOutFeeModel();
outFee.OUTGID = Convert.ToString(reader["OUTGID"]);
outFee.OUTNO = Convert.ToString(reader["OUTNO"]);
outFee.ASSOCIATEDNO = Convert.ToString(reader["ASSOCIATEDNO"]);
outFee.ARCLIENTWMSOUT = Convert.ToString(reader["ARCLIENTWMSOUT"]);
outFee.TRUCKNAME_OUT = Convert.ToString(reader["TRUCKNAME_OUT"]);
outFee.GOODSOUTFEE_OUT = float.Parse(reader["GOODSOUTFEE_OUT"].ToString());
outFee.GOODSOUTFEEAP_OUT = float.Parse(reader["GOODSOUTFEEAP_OUT"].ToString());
outFee.ARFEE_OUT = float.Parse(reader["ARFEE_OUT"].ToString());
outFee.ARFEE_2_OUT = float.Parse(reader["ARFEE_2_OUT"].ToString());
outFee.linenum = i++;
outFee.BSNO = outFee.OUTGID;//默认是wms_out的GID
outFee.ISDETAIL = Convert.ToString(reader["ISDETAIL"]);
outFee.INBSNO = Convert.ToString(reader["INBSNO"]);
if (GetFeeConfig(outType, outFee.INBSNO))
outFee.BSNO = outFee.ASSOCIATEDNO;
outFee.OUTDEGID = Convert.ToString(reader["OUTDEGID"]);
#region 插入 应收仓储费 GOODSOUTFEE_OUT
string sSQL = "";
if (outFee.GOODSOUTFEE_OUT > 0)
{
sSQL =
"insert into ch_fee(GID,BSNO,FEETYPE,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,AMOUNT,EXCHANGERATE,CURRENCY,COMMISSIONRATE,FEEFRT,REMARK,ISADVANCEDPAY,ENTEROPERATOR,ENTERDATE,FEESTATUS,WMSOUTBSNO,LINENUM,[TAXRATE],[NOTAXAMOUNT],[TAX],[ORDERSETTLEMENT],[TAXUNITPRICE],[ORDERINVSETTLEMENT],MODIFIEDUSER,MODIFIEDTIME,CARGO_GID) "
+ " values(newid() ,'" + outFee.BSNO + "',1,'仓储费','" + outFee.ARCLIENTWMSOUT + "','单票','" + outFee.GOODSOUTFEE_OUT + "',1,'" + outFee.GOODSOUTFEE_OUT + "',1,'RMB',0,'PP','“出库明细单'+'" + outFee.OUTNO + "'+'”中的仓储费',0,'" + strUserID +"',getdate(),1,'" + outFee.OUTGID + "',0,0,'" + outFee.GOODSOUTFEE_OUT + "',0,0,'" + outFee.GOODSOUTFEE_OUT + "',0,'" + strUserID + "', getdate(),'"+ outFee.OUTDEGID + "')";
existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
}
#endregion
#region 插入 应付仓储费 GOODSOUTFEEAP_OUT
if (outFee.GOODSOUTFEEAP_OUT > 0)
{
sSQL = "insert into ch_fee(GID,BSNO,FEETYPE,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,AMOUNT,EXCHANGERATE,CURRENCY,COMMISSIONRATE,FEEFRT,REMARK,ISADVANCEDPAY,ENTEROPERATOR,ENTERDATE,FEESTATUS,WMSOUTBSNO,LINENUM,[TAXRATE],[NOTAXAMOUNT],[TAX],[ORDERSETTLEMENT],[TAXUNITPRICE],[ORDERINVSETTLEMENT],MODIFIEDUSER,MODIFIEDTIME,CARGO_GID) "
+ " values(newid() ,'" + outFee.BSNO + "',2,'仓储费','" + outFee.TRUCKNAME_OUT + "','单票','" + outFee.GOODSOUTFEEAP_OUT + "',1,'" + outFee.GOODSOUTFEEAP_OUT + "',1,'RMB',0,'PP','“出库明细单'+'" + outFee.OUTNO + "'+'”中的仓储费',0,'" + strUserID +"',getdate(),1,'" + outFee.OUTGID + "',0,0,'" + outFee.GOODSOUTFEEAP_OUT + "',0,0,'" + outFee.GOODSOUTFEEAP_OUT + "',0,'" + strUserID + "', getdate(),'" + outFee.OUTDEGID + "')";
existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
}
#endregion
#region 插入 铅封费 ARFEE_OUT
if (outFee.ARFEE_OUT > 0)
{
sSQL = "insert into ch_fee(GID,BSNO,FEETYPE,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,AMOUNT,EXCHANGERATE,CURRENCY,COMMISSIONRATE,FEEFRT,REMARK,ISADVANCEDPAY,ENTEROPERATOR,ENTERDATE,FEESTATUS,WMSOUTBSNO,LINENUM,[TAXRATE],[NOTAXAMOUNT],[TAX],[ORDERSETTLEMENT],[TAXUNITPRICE],[ORDERINVSETTLEMENT],MODIFIEDUSER,MODIFIEDTIME) "
+ " values(newid() ,'" + outFee.BSNO + "',1,'铅封费','" + outFee.ARCLIENTWMSOUT + "','单票','" + outFee.ARFEE_OUT + "',1,'" + outFee.ARFEE_OUT + "',1,'RMB',0,'PP','“出库明细单'+'" + outFee.OUTNO + "'+'”中的铅封费',0,'" + strUserID +
"',getdate(),1,'" + outFee.OUTGID + "',0,0,'" + outFee.ARFEE_OUT + "',0,0,'" + outFee.ARFEE_OUT + "',0,'" + strUserID + "', getdate())";
existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
}
#endregion
#region 插入 过磅费 ARFEE_2_OUT
if (outFee.ARFEE_2_OUT > 0)
{
sSQL = "insert into ch_fee(GID,BSNO,FEETYPE,FEENAME,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,AMOUNT,EXCHANGERATE,CURRENCY,COMMISSIONRATE,FEEFRT,REMARK,ISADVANCEDPAY,ENTEROPERATOR,ENTERDATE,FEESTATUS,WMSOUTBSNO,LINENUM,[TAXRATE],[NOTAXAMOUNT],[TAX],[ORDERSETTLEMENT],[TAXUNITPRICE],[ORDERINVSETTLEMENT],MODIFIEDUSER,MODIFIEDTIME) "
+ " values(newid() ,'" + outFee.BSNO + "',1,'过磅费','" + outFee.ARCLIENTWMSOUT + "','单票','" + outFee.ARFEE_2_OUT + "',1,'" + outFee.ARFEE_2_OUT + "',1,'RMB',0,'PP','“出库明细单'+'" + outFee.OUTNO + "'+'”中的过磅费',0,'" + strUserID +"',getdate(),1,'" + outFee.OUTGID + "',0,0,'" + outFee.ARFEE_2_OUT + "',0,0,'" + outFee.ARFEE_2_OUT + "',0,'" + strUserID + "', getdate())";
existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL, null);
}
#endregion
}
reader.Close();
#region 出库明细表数据锁定
string ssSQL = "";
ssSQL = "update wms_out_detail set ISLOCK=1,LOCKUSER='" + strUserID + "',LOCKTIME=getdate() where ISLOCK=0 and OUTBSNO in (select bsno from wms_out where GID in (" + gids + "))";
#endregion
existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, ssSQL.ToString(), null);
#region 出库主表数据锁定
ssSQL = "update wms_out set ISLOCK=1,LOCKUSER='" + strUserID + "',LOCKTIME=getdate() where ISLOCK=0 and gid in (" + gids + ")";
#endregion
existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, ssSQL.ToString(), null);
sqlTran.Commit();
#region 送货单状态更改
if (bEIP)
{
StringBuilder strEIPSql = new StringBuilder();
strEIPSql.Append("update EIP_Stockup set BSSTATUS='5' where BSNO in (" + gids + ")");
Database dbEIP = DatabaseFactory.CreateDatabase("EIP");
dbEIP.ExecuteNonQuery(CommandType.Text, strEIPSql.ToString());
}
#endregion
}
}
catch (Exception)
{
sqlTran.Rollback();
result.Success = false;
result.Message = "操作出现错误,请重试或联系系统管理员";
return result;
}
finally
{
SqlHelper.CloseConnection();
sqlTran.Dispose();
}
}
#endregion
result.Success = true;
result.Message = "操作成功!(注意如果用户权限不够,将不予以入账!)";
return result;
}
#endregion
#region 取消入账
public static DBResult setnotlock(string gids, bool bEIP, string strUserID, string strCompanyID, string strDEPTNAME)
{
DBResult result = new DBResult();
if (gids.Trim() == "")
{
result.Success = false;
result.Message = "没有输入任何需要修改的数据";
}
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
gids = "'" + gids.Trim().Replace(",", "','") + "'";
#region 判断【ch_fee】中的费用状态是否允许取消入账
string sSQL = "select count(*) iCount from ch_fee WITH(NOLOCK) where WMSOUTBSNO in(" + gids + ") and FEESTATUS<>1";
int iCount = int.Parse(T_ALL_DA.GetStrSQL("iCount", sSQL));
if (iCount != 0)
{
result.Success = false;
result.Message = "有“已提交的费用”,不允许取消入账,请重新操作!";
return result;
}
#endregion
#region 取消入账
Database db = DatabaseFactory.CreateDatabase();
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
#region 删除ch_fee
sSQL = "delete from ch_fee where WMSOUTBSNO in (" + gids + ")";
#endregion
int existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL.ToString(), null);
#region 删除明细表
sSQL = "update wms_out_detail set ISLOCK=0,LOCKUSER='" + strUserID + "',LOCKTIME=getdate() where ISLOCK=1 and OUTBSNO in (select bsno from wms_out where gid in (" + gids + "))";
#endregion
existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL.ToString(), null);
#region 删除主表
sSQL = "update wms_out set ISLOCK=0,LOCKUSER='" + strUserID + "',LOCKTIME=getdate() where ISLOCK=1 and gid in (" + gids + ")";
#endregion
existVal = SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sSQL.ToString(), null);
sqlTran.Commit();
#region 送货单状态更改
if (bEIP)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("update EIP_Stockup set BSSTATUS='4' where BSNO in (" + gids + ")");
Database dbEIP = DatabaseFactory.CreateDatabase("EIP");
dbEIP.ExecuteNonQuery(CommandType.Text, strSql.ToString());
}
#endregion
}
catch (Exception)
{
sqlTran.Rollback();
result.Success = false;
result.Message = "取消入账出现错误,请重试或联系系统管理员";
return result;
}
finally
{
SqlHelper.CloseConnection();
sqlTran.Dispose();
}
}
#endregion
result.Success = true;
result.Message = "取消入账数据成功";
return result;
}
#endregion
//
#region 生成装卸费,陆运费
public static bool CreateCost(string OutBsno,string OutType, string userid, out string msg)
{
//判断该出库单是否已生成过费用
Database db = DatabaseFactory.CreateDatabase();
string check = @"SELECT count(*) from ch_fee where WMSOUTBSNO = (select top 1 gid from wms_out where BSNO= '" + OutBsno + "') and REMARK = '出库生成费用' ";
if (Convert.ToInt32(db.ExecuteScalar(CommandType.Text, check)) > 0)
{
msg = "已经生成过费用,不允许重复生成!";
return false;
}
string sql = @"select o.ASSOCIATEDNO as ASSOCIATEDNO,o.GID AS OUTGID,w.INBSNO AS INBSNO, w.GID AS OUTDEGID,w.TRUCKNO,w.ZHUANGXIEFEI,w.ZHUANGXIEGONGID,(select name from wms_stevedores where gid = w.zhuangxiegongid and DELFLAG = 0) as ZHUANGXIEGONG,w.LOADERFEE,o.ARCLIENTWMSOUT from wms_out_detail w inner join wms_out o on o.bsno=w.outbsno where w.outbsno = '" + OutBsno + "'";
List<CostModel> list = new List<CostModel>();
bool rst = false;
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
{
while (reader.Read())
{
CostModel s = new CostModel();
s.OUTGID = reader["OUTGID"].ToString();
s.OUTDEGID = reader["OUTDEGID"].ToString();
s.BSNO = s.OUTGID;
s.INBSNO = reader["INBSNO"].ToString();
if (GetFeeConfig(OutType,s.INBSNO))
s.BSNO = reader["ASSOCIATEDNO"].ToString();
s.TRUCKNO = reader["TRUCKNO"].ToString();
s.ZhuangXieFei = float.Parse(reader["ZHUANGXIEFEI"].ToString());
s.ZHUANGXIEGONGID = reader["ZHUANGXIEGONG"].ToString();
s.LOADERFEE = float.Parse(reader["LOADERFEE"].ToString());
s.ARCLIENT = reader["ARCLIENTWMSOUT"].ToString();
list.Add(s);
}
}
using (SqlTransaction sqlTran = SqlHelper.BeginTransaction(SqlHelper.ConnectionStringLocalTransaction))
{
try
{
foreach (var cm in list)
{
for (int i = 0; i < 3; i++)
{
string feeName = "";
float feeValue;
string feeCustomerName = "";
string feeType = "";
switch (i)
{
/*
case 0:
feeName = "陆运费";
feeValue = cm.LUYUNFEI;
break;
case 1:
feeName = "掉头费";
feeValue = cm.DIAOTOUFEI;
break;
case 2:
feeName = "修洗箱费";
feeValue = cm.XIUXIXIANGFEI;
break;
case 3:
feeName = "吊装费";
feeValue = cm.DIAOZHUANGFEI;
break;
*/
case 0:
feeName = "装卸费";
feeValue = cm.ZhuangXieFei;
feeCustomerName = cm.ZHUANGXIEGONGID;
feeType = "2";
break;
case 1:
feeName = "出库装卸费";
feeValue = cm.LOADERFEE;
feeCustomerName = cm.ARCLIENT;
feeType = "1";
break;
default:
feeName = "";
feeValue = 0;
break;
}
if (feeValue != 0)
{
StringBuilder sb = new StringBuilder();
sb.Append(@"insert into ch_fee (GID,BSNO,FEETYPE,FEENAME,REMARK,CUSTOMERTYPE,CUSTOMERNAME,UNIT,UNITPRICE,QUANTITY,");
sb.Append(@"AMOUNT,CURRENCY,EXCHANGERATE,FEESTATUS,NOTAXAMOUNT,TAXUNITPRICE,WMSOUTBSNO,ENTEROPERATOR) ");
sb.Append(@" VALUES(");
sb.Append("'" + Guid.NewGuid() + "',");//GID
sb.Append("'" + cm.BSNO + "',");//BSNO
sb.Append("'" + feeType + "', ");//FEETYPE
sb.Append("'" + feeName + "',");//FEENAME
sb.Append("'出库装卸费用',");//REMARK
sb.Append("'" + "车队" + "',");//CUSTOMERTYPE
sb.Append("'" + feeCustomerName + "',");//CUSTOMERNAME
sb.Append("'" + "单票" + "',");//UNIT
sb.Append(feeValue + ",");//UNITPRICE
sb.Append("1" + ",");//QUANTITY
sb.Append(feeValue + ",");//AMOUNT
sb.Append("'" + "RMB" + "',");//CURRENCY
sb.Append("1" + ",");//EXCHANGERATE
sb.Append("1" + ",");//FEESTATUS
sb.Append(feeValue + ",");//NOTAXAMOUNT
sb.Append(feeValue + ",");//TAXUNITPRICE
sb.Append("'" + cm.OUTGID + "',");//WMSOUTBSNO
sb.Append("'" + userid + "'");//ENTEROPERATOR
sb.Append(")");
SqlHelper.ExecuteNonQuery(sqlTran, CommandType.Text, sb.ToString(), null);
}
}
}
sqlTran.Commit();
msg = "生成成功!";
rst = true;
}
catch (Exception)
{
msg = "生成失败!";
sqlTran.Rollback();
rst = false;
}
finally
{
SqlHelper.CloseConnection();
sqlTran.Dispose();
}
}
return rst;
}
#endregion
#region 清库配置信息
static public string GetSysDeStockConfig(string userid)
{
string sql = "select PARAMVALUE from sys_param_set where PARAMNAME = 'OverStock' ";
Database db = DatabaseFactory.CreateDatabase();
string value = "0";
var rst = db.ExecuteScalar(CommandType.Text, sql);
if (rst != null && rst != DBNull.Value && rst.ToString() != "")
{
value = rst.ToString();
}
return value;
}
#endregion
#region 权限范围
public static string GetRangDAStr(string tb, string userid, string username, string companyid)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modWmsOutList' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
string AUTHORITYID = "";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
operaterange = Convert.ToString(reader["OPERATERANGE"]);
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "1=2";
}
else if (visiblerange == "3")
{
str = " (WMSOP='" + username + "' OR CREATEUSER='" + userid + "')";
}
else if (visiblerange == "2")
{
if (tb == "index")
{
var rangeDa = new RangeDA();
var deptid = rangeDa.GetDEPTGID(userid);
str = " (WMSOP in (select showname from vw_user where deptgid='" + deptid + "') OR CREATEUSER in (select userid from vw_user where deptgid='" + deptid + "'))";
//var userstr = new StringBuilder();
//userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
//Database userdb = DatabaseFactory.CreateDatabase();
//using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
//{
// str = "";
// while (reader.Read())
// {
// if (str == "")
// {
// str = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.FRCUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
// }
// else
// {
// str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.FRCUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
// };
// }
// str = str + ")";
// reader.Close();
//}
}
else
{
str = " UPPER(CORPID)='" + companyid + "'";
}
}
else if (visiblerange == "5")
{
if (tb == "index")
{
var userstr = new StringBuilder();
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
}
else
{
str = str + " or Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " UPPER(Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "6")
{
if (tb == "index")
{
var userstr = new StringBuilder();
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (WMSOP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CREATEUSER='" + Convert.ToString(reader["OPID"]) + "' ";
}
else
{
str = str + " or WMSOP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR CREATEUSER='" + Convert.ToString(reader["OPID"]) + "'";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " UPPER(Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(Corpid)='" + companyid + "'";
}
return str;
}
public static string GetImpRangDAStr(string tb, string userid, string username, string companyid)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE,AUTHORITYID ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modWmsList' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
string AUTHORITYID = "";
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
visiblerange = Convert.ToString(reader["VISIBLERANGE"]);
operaterange = Convert.ToString(reader["OPERATERANGE"]);
AUTHORITYID = Convert.ToString(reader["AUTHORITYID"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "1=2";
}
else if (visiblerange == "3")
{
str = " (WMSOP='" + username + "')";
}
else if (visiblerange == "2")
{
if (tb == "index")
{
var rangeDa = new RangeDA();
var deptid = rangeDa.GetDEPTGID(userid);
str = " (WMSOP in (select showname from vw_user where deptgid='" + deptid + "') )";
//var userstr = new StringBuilder();
//userstr.Append(" select SHOWNAME from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "')");
//Database userdb = DatabaseFactory.CreateDatabase();
//using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
//{
// str = "";
// while (reader.Read())
// {
// if (str == "")
// {
// str = " (B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.FRCUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
// }
// else
// {
// str = str + " or B.OP='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.SALE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.CUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.DOC='" + Convert.ToString(reader["SHOWNAME"]) + "' OR B.FRCUSTSERVICE='" + Convert.ToString(reader["SHOWNAME"]) + "'";
// };
// }
// str = str + ")";
// reader.Close();
//}
}
else
{
str = " UPPER(CORPID)='" + companyid + "'";
}
}
else if (visiblerange == "5")
{
if (tb == "index")
{
var userstr = new StringBuilder();
userstr.Append(" select COMPANYID from user_authority_range_company where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
}
else
{
str = str + " or Corpid='" + Convert.ToString(reader["COMPANYID"]) + "'";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " UPPER(Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "6")
{
if (tb == "index")
{
var userstr = new StringBuilder();
userstr.Append(" select OPID,(select SHOWNAME from [user] where GID=user_authority_range_op.OPID) SHOWNAME from user_authority_range_op where userid='" + userid + "' and AUTHORITYID='" + AUTHORITYID + "' and VISIBLERANGE=1");
Database userdb = DatabaseFactory.CreateDatabase();
using (IDataReader reader = userdb.ExecuteReader(CommandType.Text, userstr.ToString()))
{
str = "";
while (reader.Read())
{
if (str == "")
{
str = " (WMSOP='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
}
else
{
str = str + " or WMSOP='" + Convert.ToString(reader["SHOWNAME"]) + "' ";
};
}
str = str + ")";
reader.Close();
}
}
else
{
str = " UPPER(Corpid)='" + companyid + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(Corpid)='" + companyid + "'";
}
return str;
}
#endregion
#region 查询明细表 良通捷运
static public List<VwWmsDetail_BoxModels> GetDetailList_Box(string opStatus, string strCondition, string userid, string usercode, string companyid)
{
var strSql = new StringBuilder();
if (opStatus == "edit")
{
string sTableName = "VW_WMS_DETAIL";
strSql.Append("SELECT *,ISBONDEDNAME=(case when ISBONDED=1 then '是' else '否' end)");
strSql.Append(" from " + sTableName + " WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" order by CUSTOMERNAME,BLNO,WMSNO,WMSDATE,BSNO_OUT");
return SetDetail_Box(strSql);
}
else{
string sTableName = "VW_WMS_DETAIL";
strSql.Append("SELECT *,ISBONDEDNAME=(case when ISBONDED=1 then '是' else '否' end)");
strSql.Append(" from " + sTableName + " WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" order by CUSTOMERNAME,BLNO,WMSNO,WMSDATE,BSNO_OUT");
//return SetDetail_Box(strSql);
var _r = SetDetail_Box(strSql);
var result = new List<VwWmsDetail_BoxModels>();
//如果是新增 需要从中去除其他出库明细的内容
//去除方式如果GID_OUT不为空 将其设为空 并递减显示的件数
for (var _i = 0; _i < _r.Count; _i++) {
if (string.IsNullOrWhiteSpace(_r[_i].GID_OUT))
{
result.Add(_r[_i]);
}
else {
var newitem = _r[_i];
newitem.GID_OUT = "";
newitem.NID = newitem.GID;
//newitem.GOODSSTOCK = newitem.GOODSSTOCK - newitem.GOODSPFSL_OUT;
newitem.GOODSPFSL_OUT = 0;
newitem.OUTBSNO_OUT = "";
if(newitem.GOODSSTOCK>0)
result.Add(newitem);
}
}
return result;
}
}
/* GetDetailList_box_needtoout
static public List<VwWmsDetailModels> GetDetailList_box(string opStatus, string strCondition, string userid, string usercode, string companyid)
{
var strSql = new StringBuilder();
string sTableName = "VW_WMS_DETAIL_NULL";
if (opStatus == "edit")
{
sTableName = "VW_WMS_DETAIL";
}
strSql.Append("SELECT *,ISBONDEDNAME=(case when ISBONDED=1 then '是' else '否' end)");
strSql.Append(" from " + sTableName + " WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" order by CUSTOMERNAME,BLNO,WMSNO,WMSDATE,BSNO_OUT");
return SetDetail(strSql);
}
*/
private static List<VwWmsDetail_BoxModels> SetDetail_Box(StringBuilder strSql)
{
var headList = new List<VwWmsDetail_BoxModels>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
VwWmsDetail_BoxModels data = new VwWmsDetail_BoxModels();
#region Set DB data to Object
data.PICIHAO = (reader["PICIHAO"] == null ? "" : Convert.ToString(reader["PICIHAO"]));//批次号
data.NID = (reader["NID"] == null ? "" : Convert.ToString(reader["NID"]));//NID
data.GID = (reader["GID"] == null ? "" : Convert.ToString(reader["GID"]));//GID
data.ASSOCIATEDNO = (reader["ASSOCIATEDNO"] == null ? "" : Convert.ToString(reader["ASSOCIATEDNO"]));//ASSOCIATEDNO
data.BSNO = (reader["BSNO"] == null ? "" : Convert.ToString(reader["BSNO"]));//BSNO
data.BLNO = (reader["BLNO"] == null ? "" : Convert.ToString(reader["BLNO"]));//BLNO
data.CONTRACTNO = (reader["CONTRACTNO"] == null ? "" : Convert.ToString(reader["CONTRACTNO"]));//CONTRACTNO
data.STORAGENAME = (reader["STORAGENAME"] == null ? "" : Convert.ToString(reader["STORAGENAME"]));//STORAGENAME
data.GOODSNAME = (reader["GOODSNAME"] == null ? "" : Convert.ToString(reader["GOODSNAME"]));//GOODSNAME
data.GOODSMODEL = (reader["GOODSMODEL"] == null ? "" : Convert.ToString(reader["GOODSMODEL"]));//GOODSMODEL
data.GOODSPACK = (reader["GOODSPACK"] == null ? 0 : Convert.ToDecimal(reader["GOODSPACK"]));//GOODSPACK
data.CHARGEUNIT = (reader["CHARGEUNIT"] == null ? "" : Convert.ToString(reader["CHARGEUNIT"]));//CHARGEUNIT
data.GOODSRKSL = (reader["GOODSRKSL"] == null ? 0 : Convert.ToDecimal(reader["GOODSRKSL"]));//GOODSRKSL
data.GOODSSTOCK = (reader["GOODSSTOCK"] == null ? 0 : Convert.ToDecimal(reader["GOODSSTOCK"]));//GOODSSTOCK
data.FREESTORAGEPERIOD = (reader["FREESTORAGEPERIOD"] == null ? 0 : Convert.ToInt32(reader["FREESTORAGEPERIOD"]));//FREESTORAGEPERIOD
data.ISLOCK = (reader["ISLOCK"] == null ? 0 : Convert.ToInt32(reader["ISLOCK"]));//ISLOCK
if (reader["LOCKTIME"] != null && reader["LOCKTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["LOCKTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["LOCKTIME"].ToString().Trim() != "")
{
data.LOCKTIME = Convert.ToDateTime(reader["LOCKTIME"]);//LOCKTIME
}
data.LOCKUSER = (reader["LOCKUSER"] == null ? "" : Convert.ToString(reader["LOCKUSER"]));//LOCKUSER
data.ISDELETE = (reader["ISDELETE"] == null ? false : Convert.ToBoolean(reader["ISDELETE"]));//ISDELETE
if (reader["DELETETIME"] != null && reader["DELETETIME"].ToString().Trim().IndexOf("0001") < 0 && reader["DELETETIME"].ToString().Trim().IndexOf("1900") < 0 && reader["DELETETIME"].ToString().Trim() != "")
{
data.DELETETIME = Convert.ToDateTime(reader["DELETETIME"]);//DELETETIME
}
data.DELETEUSER = (reader["DELETEUSER"] == null ? "" : Convert.ToString(reader["DELETEUSER"]));//DELETEUSER
data.MODIFIEDUSER = (reader["MODIFIEDUSER"] == null ? "" : Convert.ToString(reader["MODIFIEDUSER"]));//MODIFIEDUSER
if (reader["MODIFIEDTIME"] != null && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("0001") < 0 && reader["MODIFIEDTIME"].ToString().Trim().IndexOf("1900") < 0 && reader["MODIFIEDTIME"].ToString().Trim() != "")
{
data.MODIFIEDTIME = Convert.ToDateTime(reader["MODIFIEDTIME"]);//MODIFIEDTIME
}
data.GID_OUT = (reader["GID_OUT"] == null ? "" : Convert.ToString(reader["GID_OUT"]));//GID_OUT
data.ASSOCIATEDNO_OUT = (reader["ASSOCIATEDNO_OUT"] == null ? "" : Convert.ToString(reader["ASSOCIATEDNO_OUT"]));//ASSOCIATEDNO_OUT
data.INBSNO_OUT = (reader["INBSNO_OUT"] == null ? "" : Convert.ToString(reader["INBSNO_OUT"]));//INBSNO_OUT
data.OUTBSNO_OUT = (reader["OUTBSNO_OUT"] == null ? "" : Convert.ToString(reader["OUTBSNO_OUT"]));//OUTBSNO_OUT
data.BSNO_OUT = (reader["BSNO_OUT"] == null ? "" : Convert.ToString(reader["BSNO_OUT"]));//BSNO_OUT
data.CLIENTGID_OUT = (reader["CLIENTGID_OUT"] == null ? "" : Convert.ToString(reader["CLIENTGID_OUT"]));//CLIENTGID_OUT
data.CLIENTCODE_OUT = (reader["CLIENTCODE_OUT"] == null ? "" : Convert.ToString(reader["CLIENTCODE_OUT"]));//CLIENTCODE_OUT
data.CUSTOMERNAME_OUT = (reader["CUSTOMERNAME_OUT"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME_OUT"]));//CUSTOMERNAME_OUT
data.DODATE_OUT = (reader["DODATE_OUT"] == null ? "" : Convert.ToString(reader["DODATE_OUT"]));//DODATE_OUT
data.STORAGECODE_OUT = (reader["STORAGECODE_OUT"] == null ? "" : Convert.ToString(reader["STORAGECODE_OUT"]));//STORAGECODE_OUT
data.STORAGENAME_OUT = (reader["STORAGENAME_OUT"] == null ? "" : Convert.ToString(reader["STORAGENAME_OUT"]));//STORAGENAME_OUT
data.AREACODE_OUT = (reader["AREACODE_OUT"] == null ? "" : Convert.ToString(reader["AREACODE_OUT"]));//AREACODE_OUT
data.AREANAME_OUT = (reader["AREANAME_OUT"] == null ? "" : Convert.ToString(reader["AREANAME_OUT"]));//AREANAME_OUT
data.GOODSCODE_OUT = (reader["GOODSCODE_OUT"] == null ? "" : Convert.ToString(reader["GOODSCODE_OUT"]));//GOODSCODE_OUT
data.GOODSNAME_OUT = (reader["GOODSNAME_OUT"] == null ? "" : Convert.ToString(reader["GOODSNAME_OUT"]));//GOODSNAME_OUT
data.GOODSTYPE_OUT = (reader["GOODSTYPE_OUT"] == null ? "" : Convert.ToString(reader["GOODSTYPE_OUT"]));//GOODSTYPE_OUT
data.GOODSMODEL_OUT = (reader["GOODSMODEL_OUT"] == null ? "" : Convert.ToString(reader["GOODSMODEL_OUT"]));//GOODSMODEL_OUT
data.GOODSSTANDARD_OUT = (reader["GOODSSTANDARD_OUT"] == null ? "" : Convert.ToString(reader["GOODSSTANDARD_OUT"]));//GOODSSTANDARD_OUT
data.GOODSPACK_OUT = (reader["GOODSPACK_OUT"] == null ? "" : Convert.ToString(reader["GOODSPACK_OUT"]));//GOODSPACK_OUT
data.CHARGEUNIT_OUT = (reader["CHARGEUNIT_OUT"] == null ? "" : Convert.ToString(reader["CHARGEUNIT_OUT"]));//CHARGEUNIT_OUT
data.GOODSPFSL_OUT = (reader["GOODSPFSL_OUT"] == null ? 0 : Convert.ToDecimal(reader["GOODSPFSL_OUT"]));//GOODSPFSL_OUT
data.TRUCKNO_OUT = (reader["TRUCKNO_OUT"] == null ? "" : Convert.ToString(reader["TRUCKNO_OUT"]));//TRUCKNO_OUT
data.CREATEUSER_OUT = (reader["CREATEUSER_OUT"] == null ? "" : Convert.ToString(reader["CREATEUSER_OUT"]));//CREATEUSER_OUT
if (reader["CREATETIME_OUT"] != null && reader["CREATETIME_OUT"].ToString().Trim().IndexOf("0001") < 0 && reader["CREATETIME_OUT"].ToString().Trim().IndexOf("1900") < 0 && reader["CREATETIME_OUT"].ToString().Trim() != "")
{
data.CREATETIME_OUT = Convert.ToDateTime(reader["CREATETIME_OUT"]);//CREATETIME_OUT
}
data.REMARK_OUT = (reader["REMARK_OUT"] == null ? "" : Convert.ToString(reader["REMARK_OUT"]));//REMARK_OUT
data.GOODSPACKPFSL_OUT = (reader["GOODSPACKPFSL_OUT"] == null ? 0 : Convert.ToDecimal(reader["GOODSPACKPFSL_OUT"]));//GOODSPACKPFSL_OUT
data.ARFEE = (reader["ARFEE"] == null ? 0 : Convert.ToDecimal(reader["ARFEE"]));//ARFEE
data.APFEE = (reader["APFEE"] == null ? 0 : Convert.ToDecimal(reader["APFEE"]));//APFEE
data.ARFEE_OUT = (reader["ARFEE_OUT"] == null ? 0 : Convert.ToDecimal(reader["ARFEE_OUT"]));//ARFEE_OUT
data.ARFEE_2_OUT = (reader["ARFEE_2_OUT"] == null ? 0 : Convert.ToDecimal(reader["ARFEE_2_OUT"]));//ARFEE_2_OUT需求编号SR2017073000001
data.APFEE_OUT = (reader["APFEE_OUT"] == null ? 0 : Convert.ToDecimal(reader["APFEE_OUT"]));//APFEE_OUT
data.GOODSOUTFEE_OUT = (reader["GOODSOUTFEE_OUT"] == null ? 0 : Convert.ToDecimal(reader["GOODSOUTFEE_OUT"]));//GOODSOUTFEE_OUT
data.GOODSOUTFEEAP_OUT = (reader["GOODSOUTFEEAP_OUT"] == null ? 0 : Convert.ToDecimal(reader["GOODSOUTFEEAP_OUT"]));//GOODSOUTFEEAP_OUT
data.WMSNO = (reader["WMSNO"] == null ? "" : Convert.ToString(reader["WMSNO"]));//WMSNO
data.WMSDATE = (reader["WMSDATE"] == null ? "" : Convert.ToString(reader["WMSDATE"]));//WMSDATE
data.CUSTOMERNAME = (reader["CUSTOMERNAME"] == null ? "" : Convert.ToString(reader["CUSTOMERNAME"]));//CUSTOMERNAME
data.WMSOP = (reader["WMSOP"] == null ? "" : Convert.ToString(reader["WMSOP"]));//WMSOP
data.STOREMAN = (reader["STOREMAN"] == null ? "" : Convert.ToString(reader["STOREMAN"]));//STOREMAN
data.GOODSPACKSTOCK = (reader["GOODSPACKSTOCK"] == null ? 0 : Convert.ToDecimal(reader["GOODSPACKSTOCK"]));//GOODSPACKSTOCK
data.TRUCKNAME = (reader["TRUCKNAME"] == null ? "" : Convert.ToString(reader["TRUCKNAME"]));//TRUCKNAME
if (reader["STARTBILLINGDATE"] != null && reader["STARTBILLINGDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["STARTBILLINGDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["STARTBILLINGDATE"].ToString().Trim() != "")
{
data.STARTBILLINGDATE = Convert.ToDateTime(reader["STARTBILLINGDATE"]);//STARTBILLINGDATE
}
data.CUSTOMNO = (reader["CUSTOMNO"] == null ? "" : Convert.ToString(reader["CUSTOMNO"]));//CUSTOMNO
data.CUSTNO = (reader["CUSTNO"] == null ? "" : Convert.ToString(reader["CUSTNO"]));//CUSTNO
data.GOODSSTANDARD = (reader["GOODSSTANDARD"] == null ? "" : Convert.ToString(reader["GOODSSTANDARD"]));//GOODSSTANDARD
data.CORPID = (reader["CORPID"] == null ? "" : Convert.ToString(reader["CORPID"]));//CORPID
data.GOODSPACKACTUAL = (reader["GOODSPACKACTUAL"] == null ? 0 : Convert.ToDecimal(reader["GOODSPACKACTUAL"]));//GOODSPACKACTUAL
data.GOODSRKSLACTUAL = (reader["GOODSRKSLACTUAL"] == null ? 0 : Convert.ToDecimal(reader["GOODSRKSLACTUAL"]));//GOODSRKSLACTUAL
data.CLIENTNAMEOLD = (reader["CLIENTNAMEOLD"] == null ? "" : Convert.ToString(reader["CLIENTNAMEOLD"]));//CLIENTNAMEOLD
data.ISCHANGE = (reader["ISCHANGE"] == null ? false : Convert.ToBoolean(reader["ISCHANGE"]));//ISCHANGE
data.ISCHANGE_OUT = (reader["ISCHANGE_OUT"] == null ? false : Convert.ToBoolean(reader["ISCHANGE_OUT"]));//ISCHANGE_OUT
data.WMSGID = (reader["WMSGID"] == null ? "" : Convert.ToString(reader["WMSGID"]));//WMSGID
data.OUTGID = (reader["OUTGID"] == null ? "" : Convert.ToString(reader["OUTGID"]));//OUTGID
data.OUTREMARK = (reader["OUTREMARK"] == null ? "" : Convert.ToString(reader["OUTREMARK"]));//OUTREMARK
data.GOODSNAMEID = (reader["GOODSNAMEID"] == null ? "" : Convert.ToString(reader["GOODSNAMEID"]));//品名gid
data.WHS_CODE = (reader["WHS_CODE"] == null ? "" : Convert.ToString(reader["WHS_CODE"]));//库别
data.AREANAME = (reader["AREANAME"] == null ? "" : Convert.ToString(reader["AREANAME"]));//储位
data.BZTCHNO = (reader["BZTCHNO"] == null ? "" : Convert.ToString(reader["BZTCHNO"]));//电子账册号
data.GOODNO = (reader["GOODNO"] == null ? "" : Convert.ToString(reader["GOODNO"]));//料号
data.ACCDATE = (reader["ACCDATE"] == null ? "" : Convert.ToString(reader["ACCDATE"]));//会计期间
data.FEESTATUSREF = (reader["FEESTATUSREF"] == null ? "" : Convert.ToString(reader["FEESTATUSREF"]));//费用状态
data.ACCDATE_OUT = (reader["ACCDATE_OUT"] == null ? "" : Convert.ToString(reader["ACCDATE_OUT"]));//会计期间_OUT
if (reader["FEESTATUS"] != DBNull.Value) {
data.FEESTATUS = Convert.ToBoolean(reader["FEESTATUS"]);
}
//data.FEESTATUS = (reader["FEESTATUS"] == null ? false : Convert.ToBoolean(reader["FEESTATUS"]));//费用状态_OUT
data.FEESTATUSREF_OUT = (reader["FEESTATUSREF_OUT"] == null ? "" : Convert.ToString(reader["FEESTATUSREF_OUT"]));//费用状态_OUT
data.GOODSSLICE = (reader["GOODSSLICE"] == null ? 0 : Convert.ToDecimal(reader["GOODSSLICE"]));//包装件数//需求编号SR2017061800001-7
data.ISLOCK2 = (reader["ISLOCK2"] == null ? 0 : Convert.ToInt32(reader["ISLOCK2"]));//需求编号SR2017061400006-1
//data.ISBONDED = (reader["ISBONDED"] == null ? 0 : Convert.ToInt32(reader["ISBONDED"]));//需求编号SR2017061900001-1
//data.ISBONDEDNAME = (reader["ISBONDEDNAME"] == null ? "" : Convert.ToString(reader["ISBONDEDNAME"]));//需求编号SR2017062600003
data.GOODSNUM = (reader["GOODSNUM"] == null ? 0 : Convert.ToDecimal(reader["GOODSNUM"]));//完税件数
data.WeiWanShui = (reader["WeiWanShui"] == null ? 0 : Convert.ToDecimal(reader["WeiWanShui"]));//未完税件数//需求编号SR2017062200002
if (data.ISBONDED == 0)
{
data.GOODSNUM = 0;//是否保税SR2017062600003
data.WeiWanShui = 0;//是否保税SR2017062600003
}
data.GOODSSLICE_OUT = (reader["GOODSSLICE_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSSLICE_OUT"]));//需求编号SR2017071100001
data.TRUCKTYPE_OUT = (reader["TRUCKTYPE_OUT"] == null ? "" : Convert.ToString(reader["TRUCKTYPE_OUT"]));//需求编号SR2017073000001
data.ZHUANGXIEGONGID_OUT = (reader["ZHUANGXIEGONGID_OUT"] == null ? "" : Convert.ToString(reader["ZHUANGXIEGONGID_OUT"]));//需求编号SR2017073000001
data.TRUCKKGS_OUT = (reader["TRUCKKGS_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["TRUCKKGS_OUT"]));//需求编号SR2017073000001
data.QianFengNO = (reader["QianFengNO"] == null ? "" : Convert.ToString(reader["QianFengNO"]));//需求编号SR2017073000001
data.ARCLIENTWMSOUT = (reader["ARCLIENTWMSOUT"] == null ? "" : Convert.ToString(reader["ARCLIENTWMSOUT"]));//需求编号SR2017073000001
data.ARCLIENT = (reader["ARCLIENT"] == null ? "" : Convert.ToString(reader["ARCLIENT"]));//需求编号SR2017073000001
data.TRUCKNAME_OUT = (reader["TRUCKNAME_OUT"] == null ? "" : Convert.ToString(reader["TRUCKNAME_OUT"]));//需求编号SR2017073000001
data.GOODSPACKPFSL_OUT_2 = (reader["GOODSPACKPFSL_OUT"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSPACKPFSL_OUT"]));//需求编号SR2017073000001
if (reader["OLDCUSTFEEDATE"] != DBNull.Value && reader["OLDCUSTFEEDATE"].ToString().Trim().IndexOf("0001") < 0 && reader["OLDCUSTFEEDATE"].ToString().Trim().IndexOf("1900") < 0 && reader["OLDCUSTFEEDATE"].ToString().Trim() != "")
{
data.OLDCUSTFEEDATE = Convert.ToDateTime(reader["OLDCUSTFEEDATE"]);//需求编号SR2017073000001
}
if (reader["STARTBILLINGDATEAP"] != DBNull.Value && reader["STARTBILLINGDATEAP"].ToString().Trim().IndexOf("0001") < 0 && reader["STARTBILLINGDATEAP"].ToString().Trim().IndexOf("1900") < 0 && reader["STARTBILLINGDATEAP"].ToString().Trim() != "")
{
data.STARTBILLINGDATEAP = Convert.ToDateTime(reader["STARTBILLINGDATEAP"]);//需求编号SR2017073000001
}
data.CHIMA1 = (reader["CHIMA1"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["CHIMA1"]));//CHIMA1
data.CHIMA2 = (reader["CHIMA2"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["CHIMA2"]));//CHIMA2
data.GOODSKGS = (reader["GOODSKGS"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["GOODSKGS"]));//GOODSKGS
data.ZHONGLIANG2 = (reader["ZHONGLIANG2"] == DBNull.Value ? 0 : Convert.ToDecimal(reader["ZHONGLIANG2"]));//ZHONGLIANG2
data.COUNTRY = (reader["COUNTRY"] == null ? "" : Convert.ToString(reader["COUNTRY"]));//COUNTRY
data.COUNTRYID = (reader["COUNTRYID"] == null ? "" : Convert.ToString(reader["COUNTRYID"]));//COUNTRYID
data.CNTRNO = (reader["CNTRNO"] == null ? "" : Convert.ToString(reader["CNTRNO"]));//COUNTRYID
data.AREACODE = (reader["AREACODE"] == null ? "" : Convert.ToString(reader["AREACODE"]));//COUNTRYID
#endregion
headList.Add(data);
}
reader.Close();
reader.Dispose();
}
return headList;
}
static public VwWmsDetailModels GetData_Box(string condition, string companyid, string userid)
{
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(userid);
var strSql = new StringBuilder();
strSql.Append("SELECT *,ISBONDEDNAME=(case when ISBONDED=1 then '是' else '否' end),(select GOODSCKQSTOCK from wms_out_detail where gid = gid_out) GOODSCKQSTOCK ");
strSql.Append(" from VW_WMS_DETAIL WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" and " + condition);
}
strSql.Append(" order by CUSTOMERNAME,BLNO,WMSNO,WMSDATE,BSNO_OUT");
var list = SetDetail(strSql);
if (list.Count > 0)
return list[0];
return new VwWmsDetailModels();
}
static public string GetDataListStr_Box(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT NID as 出库明细GID,CUSTOMERNAME as 客户名称,STORAGENAME as 所属仓库,BLNO as 提单号,WMSNO as 入库单号,WMSDATE as 入库时间,GOODSNAME as 品名,GOODSMODEL as 单位,GOODSSTANDARD as 规格,GOODSPACKSTOCK as 剩余件数,WeiWanShui as 未完税件数,(case when ISBONDED=1 then GOODSNUM else 0 end) as 完税件数,(case when ISBONDED=1 then WeiWanShui else 0 end) as 未完税件数,GOODSPACKPFSL_OUT as 出库件数,GOODSSLICE_OUT as 出库包装件数,REMARK_OUT as 明细备注,OUTREMARK as 出库备注,OUTBSNO_OUT as 出库单号,DODATE_OUT as 出库日期,WHS_CODE as 库别,AREANAME as 储位,BZTCHNO as 电子账册号,GOODNO as 料号,ACCDATE_OUT as 会计期间,是否保税业务=(case when ISBONDED=1 then '是' else '否' end),TRUCKTYPE_OUT as 车辆类型,ZHUANGXIEGONGID_OUT as 装卸工,TRUCKKGS_OUT as 平均重量,QianFengNO as 铅封号,ARCLIENTWMSOUT as 应收仓储客户,ARCLIENT as 应收出库客户,TRUCKNAME_OUT as 应付客户");//,GOODSSTOCK as 剩余库存//需求编号SR2017061800001-7、SR2017062200002、SR2017071100001、SR2017071300002-2//需求编号SR2017073000001
strSql.Append(" from VW_WMS_DETAIL WITH(NOLOCK) where 1=1");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" order by CUSTOMERNAME,BLNO,WMSNO,WMSDATE,BSNO_OUT");
return strSql.ToString();
}
#endregion
#region 费用是否关联海运进口
static public bool GetFeeConfig(string outType,string InBsno)
{
//费用是否关联海运进口,系统参数
string sql = "select PARAMVALUE from sys_param_set where gid = '617FA649-45D9-489D-ADE9-D1E96D10D111' ";
Database db = DatabaseFactory.CreateDatabase();
string valueSys = "0";
var rstSys = db.ExecuteScalar(CommandType.Text, sql);
if (rstSys != null && rstSys != DBNull.Value && rstSys.ToString() != "")
{
valueSys = rstSys.ToString();
}
//入库时,入库单是否关联了进口单据
if (outType == "StockOut")
{
sql = "select count(*) from wms where GID like '" + InBsno + "' and GID=ASSOCIATEDNO ";
}
if (outType == "StockOutDetail" )
{
sql = "select count(w.gid) from wms w inner join wms_in wi on w.GID=wi.ASSOCIATEDNO where wi.GID like '" + InBsno + "' and w.GID=w.ASSOCIATEDNO ";
}
string valuePara = "0";
var rstPara = db.ExecuteScalar(CommandType.Text, sql);
if (rstPara != null && rstPara != DBNull.Value && rstPara.ToString() != "")
{
valuePara = rstPara.ToString();
}
if ((valueSys == "1") && (valuePara == "0"))
{
return true;
}
else
{
return false;
}
}
#endregion
}
}