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.

1435 lines
76 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.TruckMng.Models.MsWlPc;
using DSWeb.Areas.TruckMng.Models.MsWlDjPc;
using DSWeb.TruckMng.Comm.Cookie;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
using DSWeb.Areas.CommMng.Models;
namespace DSWeb.Areas.TruckMng.DAL.MsWl_LKPC
{
public partial class MsWl_LKPCDAL
{
#region 主表
static public List<MsWl_LKPCHead> GetDataList(string strCondition, string userid, string usercode, string orgcode)
{
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
if (!string.IsNullOrEmpty(rangstr))
{
if (!string.IsNullOrEmpty(strCondition))
{
strCondition = strCondition + " and " + rangstr;
}
else
{
strCondition = rangstr;
}
}
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BillNo,LrDate,JzDate,UserCode,UserName,OrgCode,OrgName");
strSql.Append(",TruckNo,");
strSql.Append("(select TruckNo from tMsWlTruck where TruckNo=tMsWlPcHead.TruckNo) as TruckNo_Ref");
strSql.Append(",DrvCode,");
strSql.Append("(select DrvName from tMsWlDriver where DrvCode=tMsWlPcHead.DrvCode) as DrvCode_Ref");
strSql.Append(",DrvName,Mobile,dbo.trimdate(ExpDate) ExpDate");
strSql.Append(",DetiNation,FactoryAddr,LinkTel,LinkMan,RatedMil");
strSql.Append(",RatedFuel,FuelQty,RealMil,RealFuel,NoLoadMil,OverLoadMil,Ton");
strSql.Append(",AroundTon,LoadCount,ArriveDate,DdCode,");
strSql.Append("(select CodeAndName from vMsTruckUser where UserCode=tMsWlPcHead.DdCode) as DdCode_Ref");
strSql.Append(",DdName,ReturnDate,RefBillNo,Remark");
strSql.Append(",BillStatus");
strSql.Append(",RefBillNoSe,(select Name from tMsWl_LK_LINE where gid=RefBillNoSe) DstArea");
strSql.Append(
",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99026 and EnumValueID=tMsWlPcHead.BillStatus) as BillStatus_Ref");
strSql.Append(",FeeStatus,");
strSql.Append(
"(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99027 and EnumValueID=tMsWlPcHead.FeeStatus) as FeeStatus_Ref");
strSql.Append(",GId,TotalMil, convert(bigint ,TimeMark) as TimeMark,LoadPlace,LoadFuel,NoLoadFuel,BsType,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99025 and EnumValueID=tMsWlPcHead.BsType) as BsType_Ref");
strSql.Append(",ArriveTime,ReturnTime");
//strSql.Append(",NeadLoadDate,NeedArriveDate");
strSql.Append(",BillRises1,ChangedMil,ChangedFuel,ChangedReson");
strSql.Append(",FeeOpStatus,");
strSql.Append(
"(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99035 and EnumValueID=tMsWlPcHead.FeeOpStatus) as FeeOpStatus_Ref");
strSql.Append(",RunTimes,PcBillType");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99046 and EnumValueID=tMsWlPcHead.PcBillType) as PcBillType_Ref");
strSql.Append(",ISPC,ISBACK,ACCDATE");
strSql.Append(" from tMsWlPcHead ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetData(strSql);
}
private static List<MsWl_LKPCHead> SetData(StringBuilder strSql)
{
var headList = new List<MsWl_LKPCHead>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWl_LKPCHead data = new MsWl_LKPCHead();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.BillNo = Convert.ToString(reader["BillNo"]);
if (reader["LrDate"] != DBNull.Value)
data.LrDate = Convert.ToDateTime(reader["LrDate"]);
data.UserCode = Convert.ToString(reader["UserCode"]);
data.UserName = Convert.ToString(reader["UserName"]);
data.OrgCode = Convert.ToString(reader["OrgCode"]);
data.OrgName = Convert.ToString(reader["OrgName"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
//data.TruckNo_Ref = Convert.ToString(reader["TruckNo_Ref"]);
data.DrvCode = Convert.ToString(reader["DrvCode"]);
data.DrvName = Convert.ToString(reader["DrvName"]);
data.Mobile = Convert.ToString(reader["Mobile"]);
data.ExpDate = Convert.ToString(reader["ExpDate"]);
data.NoLoadMil = Convert.ToDecimal(reader["NoLoadMil"]);
data.OverLoadMil = Convert.ToDecimal(reader["OverLoadMil"]);
data.TotalMil = Convert.ToDecimal(reader["TotalMil"]);
data.Ton = Convert.ToDecimal(reader["Ton"]);
data.DdCode = Convert.ToString(reader["DdCode"]);
data.DdCode_Ref = Convert.ToString(reader["DdCode_Ref"]);
data.DdName = Convert.ToString(reader["DdName"]);
data.RefBillNo = Convert.ToString(reader["RefBillNo"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.BillStatus = Convert.ToString(reader["BillStatus"]);
data.BillStatus_Ref = Convert.ToString(reader["BillStatus_Ref"]);
data.FeeStatus = Convert.ToString(reader["FeeStatus"]);
//data.FeeStatus_Ref = Convert.ToString(reader["FeeStatus_Ref"]);
data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
data.PcBillType = Convert.ToString(reader["PcBillType"]);
data.PcBillType_Ref = Convert.ToString(reader["PcBillType_Ref"]);
data.RefBillNoSe = Convert.ToString(reader["RefBillNoSe"]);
data.DstArea = Convert.ToString(reader["DstArea"]);
data.LoadCount = Convert.ToDecimal(reader["LoadCount"]);
data.AroundTon = Convert.ToDecimal(reader["AroundTon"]);
data.ISPC = Convert.ToDecimal(reader["ISPC"]);
data.ISBACK = Convert.ToDecimal(reader["ISBACK"]);
data.RatedFuel = Convert.ToDecimal(reader["RatedFuel"]);
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public MsWl_LKPCHead GetHeadDataByBillNo(string billno, string userid, string usercode, string orgcode)
{
MsWl_LKPCHead data = null;
var list = GetDataList(" BillNo='" + billno + "'",userid,usercode,orgcode);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new MsWl_LKPCHead();
}
return data;
}
#endregion
#region 从表 商品信息
static public List<MsWl_LK_Cargomb> GetCargoList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append(" select c.GID,c.SEQUENCE,c.PC_BILLNO,c.CARGOINFO_GID,I.CARGONAME CARGO_NAME,I.CARGOTYPE CargoType ");
strSql.Append(" ,c.PalletCount,c.CargoCount,c.[WEIGHT],c.POINT_GID,P.NAME,P.[ADDRESS],P.CONTACTER,P.TEL,C.Remark ");
strSql.Append(" ,I.BOXCOUNT,(I.BOXCOUNT*I.WEIGHT)/1000 BOXWEIGHT,P.AREA ");
strSql.Append(" from tMsWl_LK_Cargo C ");
strSql.Append(" left join tMsWl_LK_CargoInfo I on I.gid=c.CARGOINFO_GID ");
strSql.Append(" left join tMsWl_LK_Point P on P.gid=c.POINT_GID ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" Order by C.SEQUENCE,P.NAME,I.CARGONAME ");
return SetCargoData(strSql);
}
private static List<MsWl_LK_Cargomb> SetCargoData(StringBuilder strSql)
{
var headList = new List<MsWl_LK_Cargomb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWl_LK_Cargomb data = new MsWl_LK_Cargomb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.PC_BILLNO = Convert.ToString(reader["PC_BILLNO"]);
data.CARGOINFO_GID = Convert.ToString(reader["CARGOINFO_GID"]);
data.CARGO_NAME = Convert.ToString(reader["CARGO_NAME"]);
data.CargoType = Convert.ToString(reader["CargoType"]);
data.PalletCount = Convert.ToString(reader["PalletCount"]);
data.CargoCount = Convert.ToString(reader["CargoCount"]);
data.WEIGHT = Convert.ToString(reader["WEIGHT"]);
data.POINT_GID = Convert.ToString(reader["POINT_GID"]);
data.NAME = Convert.ToString(reader["NAME"]);
data.ADDRESS = Convert.ToString(reader["ADDRESS"]);
data.CONTACTER = Convert.ToString(reader["CONTACTER"]);
data.TEL = Convert.ToString(reader["TEL"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.BOXCOUNT = Convert.ToString(reader["BOXCOUNT"]);
data.BOXWEIGHT = Convert.ToString(reader["BOXWEIGHT"]);
data.AREA = Convert.ToString(reader["AREA"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#region 在统计表中的
static public List<MsWl_LK_CargoRPTmb> GetCargoRPTList ( string strCondition )
{
var strSql = new StringBuilder();
strSql.Append(" select * from ( ");
strSql.Append(" select c.GID,c.SEQUENCE,c.PC_BILLNO,c.CARGOINFO_GID,I.CARGONAME CARGO_NAME,I.CARGOTYPE CargoType ");
strSql.Append(" ,c.PalletCount,c.CargoCount,c.[WEIGHT],c.POINT_GID,P.NAME,P.[ADDRESS],P.CONTACTER,P.TEL,C.Remark ");
strSql.Append(" ,I.BOXCOUNT,I.BOXWEIGHT,P.AREA ,h.DdName,h.DrvName,dbo.trimdate(h.ExpDate) ExpDate,h.TruckNo ");
strSql.Append(" ,case h.PcBillType when 4 then '崂矿_干线运输' when 5 then '崂矿_分拨运输' else '' end PcBillType_Ref ");
strSql.Append(" from tMsWl_LK_Cargo C ");
strSql.Append(" left join tMsWl_LK_CargoInfo I on I.gid=c.CARGOINFO_GID ");
strSql.Append(" left join tMsWl_LK_Point P on P.gid=c.POINT_GID ");
strSql.Append(" left join tMsWlPcHead H on H.billno=c.PC_BILLNO ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
//strSql.Append(" Order by C.SEQUENCE,P.NAME,I.CARGONAME ");
strSql.Append(" union all ");
strSql.Append(" select '','','合计','','','' ");
strSql.Append(" ,sum(isnull(c.PalletCount,0)) ,sum(isnull(c.CargoCount,0)) ");
strSql.Append(" ,sum(isnull(c.[WEIGHT],0)),'','','','','','' ");
strSql.Append(" ,0,0,'' ,'','','','' ");
strSql.Append(" ,'' PcBillType_Ref ");
strSql.Append(" from tMsWl_LK_Cargo C ");
strSql.Append(" left join tMsWl_LK_CargoInfo I on I.gid=c.CARGOINFO_GID ");
strSql.Append(" left join tMsWl_LK_Point P on P.gid=c.POINT_GID ");
strSql.Append(" left join tMsWlPcHead H on H.billno=c.PC_BILLNO ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" )t Order by t.PC_BILLNO,t.ExpDate,t.NAME ");
return SetCargoRPTData(strSql);
}
private static List<MsWl_LK_CargoRPTmb> SetCargoRPTData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_CargoRPTmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWl_LK_CargoRPTmb data = new MsWl_LK_CargoRPTmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.PC_BILLNO = Convert.ToString(reader["PC_BILLNO"]);
data.CARGOINFO_GID = Convert.ToString(reader["CARGOINFO_GID"]);
data.CARGO_NAME = Convert.ToString(reader["CARGO_NAME"]);
data.CargoType = Convert.ToString(reader["CargoType"]);
data.PalletCount = Convert.ToString(reader["PalletCount"]);
data.CargoCount = Convert.ToString(reader["CargoCount"]);
data.WEIGHT = Convert.ToString(reader["WEIGHT"]);
data.POINT_GID = Convert.ToString(reader["POINT_GID"]);
data.NAME = Convert.ToString(reader["NAME"]);
data.ADDRESS = Convert.ToString(reader["ADDRESS"]);
data.CONTACTER = Convert.ToString(reader["CONTACTER"]);
data.TEL = Convert.ToString(reader["TEL"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.BOXCOUNT = Convert.ToString(reader["BOXCOUNT"]);
data.BOXWEIGHT = Convert.ToString(reader["BOXWEIGHT"]);
data.AREA = Convert.ToString(reader["AREA"]);
data.DdName = Convert.ToString(reader["DdName"]);
data.ExpDate = Convert.ToString(reader["ExpDate"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.DrvName = Convert.ToString(reader["DrvName"]);
data.PcBillType_Ref = Convert.ToString(reader["PcBillType_Ref"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#endregion
#region 从表 商品变动信息
static public List<MsWl_LK_CargoDomb> GetCargoDoList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append(" select D.GID,D.PC_BILLNO,D.CARGO_GID,I.CargoName CARGO_NAME,D.CARGOINFO_GID,D.INNUM,D.OUTNUM,dbo.trimdate(D.DODATE) DODATE,D.Remark,D.SEQUENCE,I.CargoType ");
strSql.Append(" ,D.POINT_GID,P.NAME POINT_NAME ");
strSql.Append(" from tMsWl_LK_CargoDo D ");
strSql.Append(" left join tMsWl_LK_CargoInfo I on I.gid=D.CARGOINFO_GID ");
strSql.Append(" left join tMsWl_LK_Point P on P.gid=D.POINT_GID ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" Order by D.SEQUENCE,I.CARGONAME ");
return SetCargoDoData(strSql);
}
private static List<MsWl_LK_CargoDomb> SetCargoDoData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_CargoDomb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWl_LK_CargoDomb data = new MsWl_LK_CargoDomb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.PC_BILLNO = Convert.ToString(reader["PC_BILLNO"]);
data.CARGO_GID = Convert.ToString(reader["CARGO_GID"]);
data.CARGO_NAME = Convert.ToString(reader["CARGO_NAME"]);
data.CARGOINFO_GID = Convert.ToString(reader["CARGOINFO_GID"]);
data.CargoType = Convert.ToString(reader["CargoType"]);
data.INNUM = Convert.ToString(reader["INNUM"]);
data.OUTNUM = Convert.ToString(reader["OUTNUM"]);
data.DODATE = Convert.ToString(reader["DODATE"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.POINT_GID = Convert.ToString(reader["POINT_GID"]);
data.POINT_NAME = Convert.ToString(reader["POINT_NAME"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 商品变动信息 给统计报表的版本
static public List<MsWl_LK_CargoDoRPTmb> GetCargoDoRPTList ( string strCondition )
{
var strSql = new StringBuilder();
strSql.Append(" select * from ( ");
strSql.Append(" select D.GID,D.PC_BILLNO,D.CARGO_GID,I.CargoName CARGO_NAME,D.CARGOINFO_GID,D.INNUM,D.OUTNUM,dbo.trimdate(D.DODATE) DODATE,D.Remark,D.SEQUENCE,I.CargoType ");
strSql.Append(" ,D.POINT_GID,P.NAME POINT_NAME ,h.DdName,h.DrvName,dbo.trimdate(h.ExpDate) ExpDate,h.TruckNo ");
strSql.Append(" ,case h.PcBillType when 4 then '崂矿_干线运输' when 5 then '崂矿_分拨运输' else '' end PcBillType_Ref ");
strSql.Append(" from tMsWl_LK_CargoDo D ");
strSql.Append(" left join tMsWl_LK_CargoInfo I on I.gid=D.CARGOINFO_GID ");
strSql.Append(" left join tMsWl_LK_Point P on P.gid=D.POINT_GID ");
strSql.Append(" left join tMsWlPcHead H on H.billno=D.PC_BILLNO ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
/*
strSql.Append(" union all ");
strSql.Append(" select '','合计','',I.CargoName CARGO_NAME,D.CARGOINFO_GID,D.INNUM,D.OUTNUM,dbo.trimdate(D.DODATE) DODATE,D.Remark,D.SEQUENCE,I.CargoType ");
strSql.Append(" ,D.POINT_GID,P.NAME POINT_NAME ,h.DdName,h.DrvName,dbo.trimdate(h.ExpDate) ExpDate,h.TruckNo ");
strSql.Append(" ,case h.PcBillType when 4 then '崂矿_干线运输' when 5 then '崂矿_分拨运输' else '' end PcBillType_Ref ");
strSql.Append(" from tMsWl_LK_CargoDo D ");
strSql.Append(" left join tMsWl_LK_CargoInfo I on I.gid=D.CARGOINFO_GID ");
strSql.Append(" left join tMsWl_LK_Point P on P.gid=D.POINT_GID ");
strSql.Append(" left join tMsWlPcHead H on H.billno=D.PC_BILLNO ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}*/
strSql.Append(" )t Order by PC_BILLNO,POINT_NAME ");
return SetCargoDoRPTData(strSql);
}
private static List<MsWl_LK_CargoDoRPTmb> SetCargoDoRPTData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_CargoDoRPTmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWl_LK_CargoDoRPTmb data = new MsWl_LK_CargoDoRPTmb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.PC_BILLNO = Convert.ToString(reader["PC_BILLNO"]);
data.CARGO_GID = Convert.ToString(reader["CARGO_GID"]);
data.CARGO_NAME = Convert.ToString(reader["CARGO_NAME"]);
data.CARGOINFO_GID = Convert.ToString(reader["CARGOINFO_GID"]);
data.CargoType = Convert.ToString(reader["CargoType"]);
data.INNUM = Convert.ToString(reader["INNUM"]);
data.OUTNUM = Convert.ToString(reader["OUTNUM"]);
data.DODATE = Convert.ToString(reader["DODATE"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.POINT_GID = Convert.ToString(reader["POINT_GID"]);
data.POINT_NAME = Convert.ToString(reader["POINT_NAME"]);
data.DdName = Convert.ToString(reader["DdName"]);
data.ExpDate = Convert.ToString(reader["ExpDate"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.DrvName = Convert.ToString(reader["DrvName"]);
data.PcBillType_Ref = Convert.ToString(reader["PcBillType_Ref"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 商品变动汇总
static public List<MsWl_LK_CargoDoRPT2mb> GetCargoDoRPT_EXPDATE ( string strCondition )
{
var strSql = new StringBuilder();
/*
strSql.Append(" select case h.PcBillType when 4 then '崂矿_干线运输' when 5 then '崂矿_分拨运输' else '' end PcBillType_Ref ");
strSql.Append(" ,h.billno,h.ExpDate,h.DdName,h.TruckNo,h.DrvName,p.NAME ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,'1') '崂矿大_入',dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,'1') '崂矿大_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,'3') '山泉大_入',dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,'3') '山泉大_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,'258') '旧版矿泉_入',dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,'258') '旧版矿泉_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,'259') '旧版山泉_入',dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,'259') '旧版山泉_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,'260') 'VIP矿泉_入',dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,'260') 'VIP矿泉_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,'261') 'VIP山泉_入',dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,'261') 'VIP山泉_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='山泉桶_市内')) '山泉桶_市内_入' ");
strSql.Append(" ,dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='山泉桶_市内')) '山泉桶_市内_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='矿泉桶周边')) '矿泉桶_周边_入' ");
strSql.Append(" ,dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='矿泉桶_周边')) '矿泉桶_周边_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='矿泉桶_市内')) '矿泉桶_市内_入' ");
strSql.Append(" ,dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='矿泉桶_市内')) '矿泉桶_市内_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='山泉桶_周边')) '山泉桶_周边_入' ");
strSql.Append(" ,dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='山泉桶_周边')) '山泉桶_周边_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='交运托盘')) '交运托盘_入' ");
strSql.Append(" ,dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='交运托盘')) '交运托盘_出' ");
strSql.Append(" ,dbo.LK_CargoDo_In(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='交运围架')) '交运围架_入' ");
strSql.Append(" ,dbo.LK_CargoDo_Out(h.BillNo,c.Point_GID,(select gid from tMsWl_LK_CargoInfo where CARGONAME='交运围架')) '交运围架_出' ");
strSql.Append(" from tmswl_lk_cargodo C ");
strSql.Append(" left join tMsWlPcHead h on h.billno=c.pc_billno ");
strSql.Append(" left join tmswl_lk_point p on c.Point_GID=p.gid ");*/
strSql.Append(" select ExpDate,'' NAME,'' TRUCKNO,'' DRVNAME,count(distinct billno ) 车次 ");
strSql.Append(" ,sum(崂矿大_市内_入) 崂矿大_市内_入 ,sum(崂矿大_市内_出) 崂矿大_市内_出 ,sum(山泉大_市内_入) 山泉大_市内_入 ,sum(山泉大_市内_出) 山泉大_市内_出 ");
strSql.Append(" ,sum(旧版矿泉_市内_入) 旧版矿泉_市内_入 ,sum(旧版矿泉_市内_出) 旧版矿泉_市内_出 ,sum(旧版山泉_市内_入) 旧版山泉_市内_入 ,sum(旧版山泉_市内_出) 旧版山泉_市内_出 ");
strSql.Append(" ,sum(VIP矿泉_市内_入) VIP矿泉_市内_入 ,sum(VIP矿泉_市内_出) VIP矿泉_市内_出 ,sum(VIP山泉_市内_入) VIP山泉_市内_入 ,sum(VIP山泉_市内_出) VIP山泉_市内_出 ");
strSql.Append(" ,sum(崂矿大_周边_入) 崂矿大_周边_入 ,sum(崂矿大_周边_出) 崂矿大_周边_出 ,sum(山泉大_周边_入) 山泉大_周边_入 ,sum(山泉大_周边_出) 山泉大_周边_出 ");
strSql.Append(" ,sum(旧版矿泉_周边_入) 旧版矿泉_周边_入 ,sum(旧版矿泉_周边_出) 旧版矿泉_周边_出 ,sum(旧版山泉_周边_入) 旧版山泉_周边_入 ,sum(旧版山泉_周边_出) 旧版山泉_周边_出 ");
strSql.Append(" ,sum(VIP矿泉_周边_入) VIP矿泉_周边_入 ,sum(VIP矿泉_周边_出) VIP矿泉_周边_出 ,sum(VIP山泉_周边_入) VIP山泉_周边_入 ,sum(VIP山泉_周边_出) VIP山泉_周边_出 ");
strSql.Append(" ,sum(山泉桶_市内_入) 山泉桶_市内_入 ,sum(山泉桶_市内_出) 山泉桶_市内_出 ,sum(矿泉桶_周边_入) 矿泉桶_周边_入 ,sum(矿泉桶_周边_出) 矿泉桶_周边_出 ");
strSql.Append(" ,sum(矿泉桶_市内_入) 矿泉桶_市内_入 ,sum(矿泉桶_市内_出) 矿泉桶_市内_出 ,sum(山泉桶_周边_入) 山泉桶_周边_入 ,sum(山泉桶_周边_出) 山泉桶_周边_出 ");
strSql.Append(" ,sum(交运托盘_入) 交运托盘_入 ,sum(交运托盘_出) 交运托盘_出 ,sum(交运围架_入) 交运围架_入 ,sum(交运围架_出) 交运围架_出 ");
strSql.Append(" from VW_JYLK_RPT ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" group by expdate ");
//strSql.Append(" group by c.pc_billno,c.Point_GID,h.PcBillType,h.BillNo,h.ExpDate,h.DdName,h.TruckNo,h.DrvName,p.NAME ");
strSql.Append(" Order by expdate ");
return SetCargoDoRPT2Data(strSql);
}
static public List<MsWl_LK_CargoDoRPT2mb> GetCargoDoRPT_POINT ( string strCondition )
{
var strSql = new StringBuilder();
strSql.Append(" select '' ExpDate, NAME,'' TRUCKNO,'' DRVNAME,count(distinct billno ) 车次 ");
strSql.Append(" ,sum(崂矿大_市内_入) 崂矿大_市内_入 ,sum(崂矿大_市内_出) 崂矿大_市内_出 ,sum(山泉大_市内_入) 山泉大_市内_入 ,sum(山泉大_市内_出) 山泉大_市内_出 ");
strSql.Append(" ,sum(旧版矿泉_市内_入) 旧版矿泉_市内_入 ,sum(旧版矿泉_市内_出) 旧版矿泉_市内_出 ,sum(旧版山泉_市内_入) 旧版山泉_市内_入 ,sum(旧版山泉_市内_出) 旧版山泉_市内_出 ");
strSql.Append(" ,sum(VIP矿泉_市内_入) VIP矿泉_市内_入 ,sum(VIP矿泉_市内_出) VIP矿泉_市内_出 ,sum(VIP山泉_市内_入) VIP山泉_市内_入 ,sum(VIP山泉_市内_出) VIP山泉_市内_出 ");
strSql.Append(" ,sum(崂矿大_周边_入) 崂矿大_周边_入 ,sum(崂矿大_周边_出) 崂矿大_周边_出 ,sum(山泉大_周边_入) 山泉大_周边_入 ,sum(山泉大_周边_出) 山泉大_周边_出 ");
strSql.Append(" ,sum(旧版矿泉_周边_入) 旧版矿泉_周边_入 ,sum(旧版矿泉_周边_出) 旧版矿泉_周边_出 ,sum(旧版山泉_周边_入) 旧版山泉_周边_入 ,sum(旧版山泉_周边_出) 旧版山泉_周边_出 ");
strSql.Append(" ,sum(VIP矿泉_周边_入) VIP矿泉_周边_入 ,sum(VIP矿泉_周边_出) VIP矿泉_周边_出 ,sum(VIP山泉_周边_入) VIP山泉_周边_入 ,sum(VIP山泉_周边_出) VIP山泉_周边_出 ");
strSql.Append(" ,sum(山泉桶_市内_入) 山泉桶_市内_入 ,sum(山泉桶_市内_出) 山泉桶_市内_出 ,sum(矿泉桶_周边_入) 矿泉桶_周边_入 ,sum(矿泉桶_周边_出) 矿泉桶_周边_出 ");
strSql.Append(" ,sum(矿泉桶_市内_入) 矿泉桶_市内_入 ,sum(矿泉桶_市内_出) 矿泉桶_市内_出 ,sum(山泉桶_周边_入) 山泉桶_周边_入 ,sum(山泉桶_周边_出) 山泉桶_周边_出 ");
strSql.Append(" ,sum(交运托盘_入) 交运托盘_入 ,sum(交运托盘_出) 交运托盘_出 ,sum(交运围架_入) 交运围架_入 ,sum(交运围架_出) 交运围架_出 ");
strSql.Append(" from VW_JYLK_RPT ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" group by NAME ");
strSql.Append(" Order by NAME ");
return SetCargoDoRPT2Data(strSql);
}
static public List<MsWl_LK_CargoDoRPT2mb> GetCargoDoRPT_TRUCKNO ( string strCondition )
{
var strSql = new StringBuilder();
strSql.Append(" select '' ExpDate,'' NAME, TRUCKNO,'' DRVNAME,count(distinct billno ) 车次 ");
strSql.Append(" ,sum(崂矿大_市内_入) 崂矿大_市内_入 ,sum(崂矿大_市内_出) 崂矿大_市内_出 ,sum(山泉大_市内_入) 山泉大_市内_入 ,sum(山泉大_市内_出) 山泉大_市内_出 ");
strSql.Append(" ,sum(旧版矿泉_市内_入) 旧版矿泉_市内_入 ,sum(旧版矿泉_市内_出) 旧版矿泉_市内_出 ,sum(旧版山泉_市内_入) 旧版山泉_市内_入 ,sum(旧版山泉_市内_出) 旧版山泉_市内_出 ");
strSql.Append(" ,sum(VIP矿泉_市内_入) VIP矿泉_市内_入 ,sum(VIP矿泉_市内_出) VIP矿泉_市内_出 ,sum(VIP山泉_市内_入) VIP山泉_市内_入 ,sum(VIP山泉_市内_出) VIP山泉_市内_出 ");
strSql.Append(" ,sum(崂矿大_周边_入) 崂矿大_周边_入 ,sum(崂矿大_周边_出) 崂矿大_周边_出 ,sum(山泉大_周边_入) 山泉大_周边_入 ,sum(山泉大_周边_出) 山泉大_周边_出 ");
strSql.Append(" ,sum(旧版矿泉_周边_入) 旧版矿泉_周边_入 ,sum(旧版矿泉_周边_出) 旧版矿泉_周边_出 ,sum(旧版山泉_周边_入) 旧版山泉_周边_入 ,sum(旧版山泉_周边_出) 旧版山泉_周边_出 ");
strSql.Append(" ,sum(VIP矿泉_周边_入) VIP矿泉_周边_入 ,sum(VIP矿泉_周边_出) VIP矿泉_周边_出 ,sum(VIP山泉_周边_入) VIP山泉_周边_入 ,sum(VIP山泉_周边_出) VIP山泉_周边_出 ");
strSql.Append(" ,sum(山泉桶_市内_入) 山泉桶_市内_入 ,sum(山泉桶_市内_出) 山泉桶_市内_出 ,sum(矿泉桶_周边_入) 矿泉桶_周边_入 ,sum(矿泉桶_周边_出) 矿泉桶_周边_出 ");
strSql.Append(" ,sum(矿泉桶_市内_入) 矿泉桶_市内_入 ,sum(矿泉桶_市内_出) 矿泉桶_市内_出 ,sum(山泉桶_周边_入) 山泉桶_周边_入 ,sum(山泉桶_周边_出) 山泉桶_周边_出 ");
strSql.Append(" ,sum(交运托盘_入) 交运托盘_入 ,sum(交运托盘_出) 交运托盘_出 ,sum(交运围架_入) 交运围架_入 ,sum(交运围架_出) 交运围架_出 ");
strSql.Append(" from VW_JYLK_RPT ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" group by TRUCKNO ");
strSql.Append(" Order by TRUCKNO ");
return SetCargoDoRPT2Data(strSql);
}
static public List<MsWl_LK_CargoDoRPT2mb> GetCargoDoRPT_DRVNAME ( string strCondition )
{
var strSql = new StringBuilder();
strSql.Append(" select '' ExpDate,'' NAME,'' TRUCKNO, DRVNAME,count(distinct billno ) 车次 ");
strSql.Append(" ,sum(崂矿大_市内_入) 崂矿大_市内_入 ,sum(崂矿大_市内_出) 崂矿大_市内_出 ,sum(山泉大_市内_入) 山泉大_市内_入 ,sum(山泉大_市内_出) 山泉大_市内_出 ");
strSql.Append(" ,sum(旧版矿泉_市内_入) 旧版矿泉_市内_入 ,sum(旧版矿泉_市内_出) 旧版矿泉_市内_出 ,sum(旧版山泉_市内_入) 旧版山泉_市内_入 ,sum(旧版山泉_市内_出) 旧版山泉_市内_出 ");
strSql.Append(" ,sum(VIP矿泉_市内_入) VIP矿泉_市内_入 ,sum(VIP矿泉_市内_出) VIP矿泉_市内_出 ,sum(VIP山泉_市内_入) VIP山泉_市内_入 ,sum(VIP山泉_市内_出) VIP山泉_市内_出 ");
strSql.Append(" ,sum(崂矿大_周边_入) 崂矿大_周边_入 ,sum(崂矿大_周边_出) 崂矿大_周边_出 ,sum(山泉大_周边_入) 山泉大_周边_入 ,sum(山泉大_周边_出) 山泉大_周边_出 ");
strSql.Append(" ,sum(旧版矿泉_周边_入) 旧版矿泉_周边_入 ,sum(旧版矿泉_周边_出) 旧版矿泉_周边_出 ,sum(旧版山泉_周边_入) 旧版山泉_周边_入 ,sum(旧版山泉_周边_出) 旧版山泉_周边_出 ");
strSql.Append(" ,sum(VIP矿泉_周边_入) VIP矿泉_周边_入 ,sum(VIP矿泉_周边_出) VIP矿泉_周边_出 ,sum(VIP山泉_周边_入) VIP山泉_周边_入 ,sum(VIP山泉_周边_出) VIP山泉_周边_出 ");
strSql.Append(" ,sum(山泉桶_市内_入) 山泉桶_市内_入 ,sum(山泉桶_市内_出) 山泉桶_市内_出 ,sum(矿泉桶_周边_入) 矿泉桶_周边_入 ,sum(矿泉桶_周边_出) 矿泉桶_周边_出 ");
strSql.Append(" ,sum(矿泉桶_市内_入) 矿泉桶_市内_入 ,sum(矿泉桶_市内_出) 矿泉桶_市内_出 ,sum(山泉桶_周边_入) 山泉桶_周边_入 ,sum(山泉桶_周边_出) 山泉桶_周边_出 ");
strSql.Append(" ,sum(交运托盘_入) 交运托盘_入 ,sum(交运托盘_出) 交运托盘_出 ,sum(交运围架_入) 交运围架_入 ,sum(交运围架_出) 交运围架_出 ");
strSql.Append(" from VW_JYLK_RPT ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" group by DRVNAME ");
strSql.Append(" Order by DRVNAME ");
return SetCargoDoRPT2Data(strSql);
}
private static List<MsWl_LK_CargoDoRPT2mb> SetCargoDoRPT2Data ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_CargoDoRPT2mb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWl_LK_CargoDoRPT2mb data = new MsWl_LK_CargoDoRPT2mb();
#region Set DB data to Object
//data.PcBillType_Ref = Convert.ToString(reader["PcBillType_Ref"]);
//data.BillNo = Convert.ToString(reader["BillNo"]);
//data.DdName = Convert.ToString(reader["DdName"]);
data.ExpDate = Convert.ToString(reader["ExpDate"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.DrvName = Convert.ToString(reader["DrvName"]);
data.NAME = Convert.ToString(reader["NAME"]);
data.__ = Convert.ToString(reader["崂矿大_市内_入"]);
data.__ = Convert.ToString(reader["崂矿大_市内_出"]);
data.__ = Convert.ToString(reader["山泉大_市内_入"]);
data.__ = Convert.ToString(reader["山泉大_市内_出"]);
data.__ = Convert.ToString(reader["旧版矿泉_市内_入"]);
data.__ = Convert.ToString(reader["旧版矿泉_市内_出"]);
data.__ = Convert.ToString(reader["旧版山泉_市内_入"]);
data.__ = Convert.ToString(reader["旧版山泉_市内_出"]);
data.VIP__ = Convert.ToString(reader["VIP矿泉_市内_入"]);
data.VIP__ = Convert.ToString(reader["VIP矿泉_市内_出"]);
data.VIP__ = Convert.ToString(reader["VIP山泉_市内_入"]);
data.VIP__ = Convert.ToString(reader["VIP山泉_市内_出"]);
data.__ = Convert.ToString(reader["崂矿大_周边_入"]);
data.__ = Convert.ToString(reader["崂矿大_周边_出"]);
data.__ = Convert.ToString(reader["山泉大_周边_入"]);
data.__ = Convert.ToString(reader["山泉大_周边_出"]);
data.__ = Convert.ToString(reader["旧版矿泉_周边_入"]);
data.__ = Convert.ToString(reader["旧版矿泉_周边_出"]);
data.__ = Convert.ToString(reader["旧版山泉_周边_入"]);
data.__ = Convert.ToString(reader["旧版山泉_周边_出"]);
data.VIP__ = Convert.ToString(reader["VIP矿泉_周边_入"]);
data.VIP__ = Convert.ToString(reader["VIP矿泉_周边_出"]);
data.VIP__ = Convert.ToString(reader["VIP山泉_周边_入"]);
data.VIP__ = Convert.ToString(reader["VIP山泉_周边_出"]);
data.__ = Convert.ToString(reader["山泉桶_市内_入"]);
data.__ = Convert.ToString(reader["山泉桶_市内_出"]);
data.__ = Convert.ToString(reader["矿泉桶_市内_入"]);
data.__ = Convert.ToString(reader["矿泉桶_市内_出"]);
data.__ = Convert.ToString(reader["矿泉桶_周边_入"]);
data.__ = Convert.ToString(reader["矿泉桶_周边_出"]);
data.__ = Convert.ToString(reader["山泉桶_周边_入"]);
data.__ = Convert.ToString(reader["山泉桶_周边_出"]);
data._ = Convert.ToString(reader["交运托盘_入"]);
data._ = Convert.ToString(reader["交运托盘_出"]);
data._ = Convert.ToString(reader["交运围架_入"]);
data._ = Convert.ToString(reader["交运围架_出"]);
data. = Convert.ToString(reader["车次"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 站点信息
public static List<MsWl_LK_Pointmb> GetPointList ( string condition, string sort )
{
var strSql = new StringBuilder();
strSql.Append(" select P.GID,P.NAME,P.POINTTYPE,P.DESCRIPTION,P.ADDRESS,P.CONTACTER,P.TEL,P.Remark,P.INSERTED,P.SEQUENCE,P.AREA ");
//此处 每有一种商品就添加一列 获取tMsWl_LK_CargoDo当中 cargo_GID为空(手工填写)point_GID=GID的
strSql.Append(" ,isnull((select sum(isnull(outnum,0)-isnull(innum,0)) from tmswl_lk_cargodo where Point_GID=P.gid and CARGOINFO_GID in (select gid from tmswl_lk_cargoinfo where cargotype='托盘')),0) as 托盘");
strSql.Append(" ,isnull((select sum(isnull(outnum,0)-isnull(innum,0)) from tmswl_lk_cargodo where Point_GID=P.gid and CARGOINFO_GID in (select gid from tmswl_lk_cargoinfo where cargotype='围架')),0) as 围架");
strSql.Append(" from tMsWl_LK_Point P");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" where " + condition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by SEQUENCE,NAME ");
}
/*
var dbparams = new List<CustomDbParamter>();
var paramps_sSQL = new CustomDbParamter();
paramps_sSQL.ParameterName = "@sSQL";
paramps_sSQL.DbType = DbType.String;
paramps_sSQL.Direction = ParameterDirection.Input;
paramps_sSQL.Value = strSql.ToString();
dbparams.Add(paramps_sSQL);
var dbRptResult = PubSysDAL.GetMsSqlPrcDataSet("sMsExesqlQry", dbparams, "Result_Set");
var json = RptHelper.GetRptJsonResult(start, limit, dbRptResult, "Result_Set", true);
return new ContentResult() { Content = json };
*/
return SetPointData(strSql);
}
private static List<MsWl_LK_Pointmb> SetPointData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_Pointmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWl_LK_Pointmb();
#region Set DB data to Object
/* strSql.Append(" select P.GID,P.NAME,P.POINTTYPE,P.DESCRIPTION,P.ADDRESS,P.CONTACTER,P.TEL,P.Remark,P.INSERTED,P.SEQUENCE,P.AREA ");
strSql.Append(" ,isnull((select sum(outnum) from tmswl_lk_cargodo where Point_GID=P.gid and CARGOINFO_GID in (select gid from tmswl_lk_cargoinfo where cargotype='托盘')),0)");
strSql.Append(" -isnull((select sum(innum) from tmswl_lk_cargodo where Point_GID=P.gid and CARGOINFO_GID in (select gid from tmswl_lk_cargoinfo where cargotype='托盘')),0) as 托盘");
*/
data.GID = Convert.ToString(reader["GID"]);
data.NAME = Convert.ToString(reader["NAME"]);
data.POINTTYPE = Convert.ToString(reader["POINTTYPE"]);
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
data.ADDRESS = Convert.ToString(reader["ADDRESS"]);
data.CONTACTER = Convert.ToString(reader["CONTACTER"]);
data.TEL = Convert.ToString(reader["TEL"]);
data.Remark = Convert.ToString(reader["REMARK"]);
data.INSERTED = Convert.ToString(reader["INSERTED"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.AREA = Convert.ToString(reader["AREA"]);
data. = Convert.ToString(reader["托盘"]);
data. = Convert.ToString(reader["围架"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 商品基础信息
public static List<MsWl_LK_CargoInfomb> GetCargoInfoList ( string strCondition, string sort )
{
var strSql = new StringBuilder();
strSql.Append(" select GID,PARENT_GID,PARENT_NAME,PARENT_GID2,PARENT_NAME2,CARGOTYPE,CARGONAME,SPECIFICATION,[WEIGHT] ");
strSql.Append(" ,BOXCOUNT,BOXWEIGHT,STARTDATE,STARTNUM,Remark,INSERTED,Remain,AREA from V_LK_CargoInfo ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
return SetCargoInfoData(strSql);
}
private static List<MsWl_LK_CargoInfomb> SetCargoInfoData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_CargoInfomb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWl_LK_CargoInfomb();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.PARENT_GID = Convert.ToString(reader["PARENT_GID"]);
data.PARENT_NAME = Convert.ToString(reader["PARENT_NAME"]);
data.PARENT_GID2 = Convert.ToString(reader["PARENT_GID2"]);
data.PARENT_NAME2 = Convert.ToString(reader["PARENT_NAME2"]);
data.CARGOTYPE = Convert.ToString(reader["CARGOTYPE"]);
data.CARGONAME = Convert.ToString(reader["CARGONAME"]);
data.SPECIFICATION = Convert.ToString(reader["SPECIFICATION"]);
data.WEIGHT = Convert.ToString(reader["WEIGHT"]);
data.BOXCOUNT = Convert.ToString(reader["BOXCOUNT"]);
data.BOXWEIGHT = Convert.ToString(reader["BOXWEIGHT"]);
data.STARTDATE = Convert.ToString(reader["STARTDATE"]);
data.STARTNUM = Convert.ToString(reader["STARTNUM"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.INSERTED = Convert.ToString(reader["INSERTED"]);
data.Remain = Convert.ToString(reader["Remain"]);
data.AREA = Convert.ToString(reader["AREA"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static string GetBOXCOUNT ( string GID )
{
var _r = GetCargoInfoList(" GID='" + GID + "' ", "");
if ( _r.Count>0){
return _r[0].BOXCOUNT;
}else{
return "1";
}
}
public static string GetPALLETCOUNT ( CW_CARGO _C )
{
var _r = GetCargoInfoList(" GID='" + _C.Product + "' ", "");
if (_r.Count > 0)
{
var _p = Convert.ToDecimal(_C.DeliveryQuantity) / Convert.ToDecimal(_r[0].BOXCOUNT);
_p = decimal.Floor(_p + 0.999m);
return _p.ToString(); ;
}
else
{
return "1";
}
}
#endregion
#region 明细表 fixFee
static public List<MsWlPcFixed> GetFixBodyList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BillNo,SerialNo,CreditDebit,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99020 and EnumValueID=tMsWlPcFixed.CreditDebit) as CreditDebit_Ref");
strSql.Append(",FeeTypeCode,");
strSql.Append("(select Name from vMsTruckFeeType where FeeCode=tMsWlPcFixed.FeeTypeCode) as FeeTypeCode_Ref");
strSql.Append(",FeeTypeName,DistCount,Price,FsTotal,JsTotal,Remark,GId");
strSql.Append(",FeeStatus,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99024 and EnumValueID=tMsWlPcFixed.FeeStatus) as FeeStatus_Ref");
strSql.Append(",SubmitDate,Auditoperator,AuditDate,AuditStatus");
strSql.Append(" from tMsWlPcFixed ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
return SetFixBodyData(strSql);
}
private static List<MsWlPcFixed> SetFixBodyData(StringBuilder strSql)
{
var bodyList = new List<MsWlPcFixed>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWlPcFixed data = new MsWlPcFixed();
#region Set DB data to Object
data.BillNo = Convert.ToString(reader["BillNo"]);
data.SerialNo = Convert.ToDecimal(reader["SerialNo"]);
data.CreditDebit = Convert.ToString(reader["CreditDebit"]);
data.CreditDebit_Ref = Convert.ToString(reader["CreditDebit_Ref"]);
data.FeeTypeCode = Convert.ToString(reader["FeeTypeCode"]);
data.FeeTypeCode_Ref = Convert.ToString(reader["FeeTypeCode_Ref"]);
data.FeeTypeName = Convert.ToString(reader["FeeTypeName"]);
data.DistCount = Convert.ToDecimal(reader["DistCount"]);
data.Price = Convert.ToDecimal(reader["Price"]);
data.FsTotal = Convert.ToDecimal(reader["FsTotal"]);
data.JsTotal = Convert.ToDecimal(reader["JsTotal"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.GId = Convert.ToString(reader["GId"]);
data.FeeStatus = Convert.ToDecimal(reader["FeeStatus"]);
data.FeeStatus_Ref = Convert.ToString(reader["FeeStatus_Ref"]);
if (reader["SubmitDate"] != DBNull.Value)
data.SubmitDate = Convert.ToDateTime(reader["SubmitDate"]);
data.Auditoperator = Convert.ToString(reader["Auditoperator"]);
if (reader["AuditDate"] != DBNull.Value)
data.AuditDate = Convert.ToDateTime(reader["AuditDate"]);
data.AuditStatus = Convert.ToDecimal(reader["AuditStatus"]);
#endregion
bodyList.Add(data);
}
reader.Close();
}
return bodyList;
}
#endregion
#region 参照部分
internal static List<MsWlTruckRef> GetTruckNoList(string userid, string usercode, string orgcode)
{
var rangstr = GetRangDAStr("", userid, usercode, orgcode);
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" A.TruckNo,A.DrvCode,isnull((select Mobile from tMsWlDriver B where B.DrvCode=A.DrvCode),'') as Mobile");
strSql.Append(" from tMsWlTruck A");
if (!string.IsNullOrEmpty(rangstr))
{
strSql.Append(" where " + rangstr);
}
var dataList = new List<MsWlTruckRef>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWlTruckRef();
#region Set DB data to Object
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.DrvCode = Convert.ToString(reader["DrvCode"]);
data.Mobile = Convert.ToString(reader["Mobile"]);
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
internal static List<MsWlDriverRef> GetDrvNameList(string userid, string usercode, string orgcode)
{
var rangstr = GetRangDAStr("", userid, usercode, orgcode);
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" DrvCode,DrvName,Mobile");
strSql.Append(" from tMsWlDriver");
if (!string.IsNullOrEmpty(rangstr))
{
strSql.Append(" where " + rangstr);
}
var dataList = new List<MsWlDriverRef>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWlDriverRef();
#region Set DB data to Object
data.DrvCode = Convert.ToString(reader["DrvCode"]);
data.DrvName = Convert.ToString(reader["DrvName"]);
data.Mobile = Convert.ToString(reader["Mobile"]);
data.CodeAndName = data.DrvCode + "-" + Convert.ToString(reader["DrvName"]);
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
public static string GetRangDAStr(string tb, string userid, string usercode, string orgcode)
{
string str = "";
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
strSql.Append(" from VW_User_Authority ");
strSql.Append(" where [NAME]='modMsWl_LKPC' and USERID='" + userid + "' and ISDELETE=0");
string visiblerange = "4";
string operaterange = "4";
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"]);
break;
}
reader.Close();
}
if (visiblerange == "4")
{
str = "1=2";
}
else if (visiblerange == "3")
{
if (tb == "index")
{
str = " UserCode='" + usercode + "'";
}
else
{
str = " UPPER(OrgCode)='" + orgcode + "'";
}
}
else if (visiblerange == "2")
{
if (tb == "index")
{
var rangeDa = new RangeDA();
var companyid = rangeDa.GetCORPID(userid);
var deptname = rangeDa.GetDEPTNAME(userid);
str = " UserCode in (select codename from [user] where GID in (select USERID from user_company where COMPANYID='" + companyid + "') and GID in (select userid from user_baseinfo where DEPTNAME='" + deptname + "'))";
}
else
{
str = " UPPER(OrgCode)='" + orgcode + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(OrgCode)='" + orgcode + "'";
}
return str;
}
#endregion
#region 修改LineDetail
static public Resultmb AddLineDetail(string LINE_GID, string POINTGIDList)
{
var strSql = new StringBuilder();
var _count = 0;
var _Result = new Resultmb();
Database db = DatabaseFactory.CreateDatabase();
strSql.Append(" insert into tmswl_lk_linedetail select newid(),'" + LINE_GID + "',gid,'', 1,1 from tmswl_lk_point ");
strSql.Append(" where gid in(" + POINTGIDList + ")");
try
{
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
_Result.totalCount = _count;
}
catch (Exception ee)
{
_Result.Success = false;
_Result.Message = ee.Message;
}
return _Result;
}
static public Resultmb DelLineDetail(string LineDetailList)
{
var strSql = new StringBuilder();
var _count = 0;
var _Result = new Resultmb();
Database db = DatabaseFactory.CreateDatabase();
strSql.Append(" delete from tMsWl_LK_LineDetail where GID in(" + LineDetailList + ")");
try
{
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
_Result.totalCount = _count;
}
catch (Exception ee)
{
_Result.Success = false;
_Result.Message = ee.Message;
}
return _Result;
}
#endregion
#region 修改CargoDo
static public Resultmb MakeCargoDo(string CARGO_GID, string MAKETYPE,string IOType,string AREA)
{
var strSql = new StringBuilder();
var _count = 0;
var _Result = new Resultmb();
Database db = DatabaseFactory.CreateDatabase();
if (MAKETYPE == "" && IOType=="1")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,GID,CARGOINFO_GID,CARGOCOUNT,0,(select expdate from tmswlpchead where billno=PC_BILLNO) DODATE,'自动生成',sequence,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where gid='" + CARGO_GID + "' ");
}
if (MAKETYPE == "" && IOType == "2")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,GID,CARGOINFO_GID,0,CARGOCOUNT,(select expdate from tmswlpchead where billno=PC_BILLNO) DODATE,'自动生成',sequence,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where gid='" + CARGO_GID + "' ");
}
if (MAKETYPE == "Parent" && IOType == "1")
//原先为
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,'',(select top 1 parent_gid from tMsWl_LK_CargoInfo where gid= CARGOINFO_GID),CARGOCOUNT,0,(select expdate from tmswlpchead where billno=PC_BILLNO) DODATE,'自动生成',sequence,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where gid='" + CARGO_GID + "' ");
}
if (MAKETYPE == "Parent" && IOType == "2")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,'',(select top 1 parent_gid from tMsWl_LK_CargoInfo where gid= CARGOINFO_GID),0,CARGOCOUNT,(select expdate from tmswlpchead where billno=PC_BILLNO) DODATE,'自动生成',sequence,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where gid='" + CARGO_GID + "' ");
}
//
if (MAKETYPE == "Child" && IOType == "1")
{
//分拨 锁定返回 加空桶库存
if (AREA == "市内")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,GID,(select top 1 parent_GID from tMsWl_LK_CargoInfo C2 where C2.GID= CARGOINFO_GID),CARGOCOUNT,0,(select expdate from tmswlpchead where billno=PC_BILLNO) DODATE,'自动生成',sequence,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where gid='" + CARGO_GID + "' ");
}
if (AREA == "周边")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,GID,(select top 1 parent_GID2 from tMsWl_LK_CargoInfo C2 where C2.GID= CARGOINFO_GID),CARGOCOUNT,0,(select expdate from tmswlpchead where billno=PC_BILLNO) DODATE,'自动生成',sequence,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where gid='" + CARGO_GID + "' ");
}
}
if (MAKETYPE == "Child" && IOType == "2")
//干线 锁定派车 减去空桶库存
//根据市内和周边
{
if (AREA == "市内")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,GID,(select top 1 parent_GID from tMsWl_LK_CargoInfo C2 where C2.GID= CARGOINFO_GID),0,CARGOCOUNT,(select expdate from tmswlpchead where billno=PC_BILLNO) DODATE,'自动生成',sequence,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where gid='" + CARGO_GID + "' ");
}
if (AREA == "周边")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,GID,(select top 1 parent_GID2 from tMsWl_LK_CargoInfo C2 where C2.GID= CARGOINFO_GID),0,CARGOCOUNT,(select expdate from tmswlpchead where billno=PC_BILLNO) DODATE,'自动生成',sequence,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where gid='" + CARGO_GID + "' ");
}
}
strSql.Append(" delete from tmswl_lk_cargoDo where CARGOINFO_GID='' ");
try
{
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
_Result.totalCount = _count;
}
catch (Exception ee)
{
_Result.Success = false;
_Result.Message = ee.Message;
}
return _Result;
}
static public Resultmb DelCargoDo ( string CARGO_GID, string IOType )
{
var strSql = new StringBuilder();
var _count = 0;
var _Result = new Resultmb();
Database db = DatabaseFactory.CreateDatabase();
if (IOType == "1")//如果是取消返回 即取消入库信息
{
strSql.Append(" delete from tmswl_lk_cargoDo where CARGO_GID ='" + CARGO_GID + "' and INNUM>0");
/*
strSql.Append(" or ( CargoInfo_GID=(select top 1 gid from tmswl_lk_cargoInfo where CargoType='托盘')");
strSql.Append(" and PC_BILLNO in (select PC_BILLNO from tmswl_lk_cargo where gid='" + CARGO_GID + "') )) and INNUM>0");
* */
}
else {
strSql.Append(" delete from tmswl_lk_cargoDo where CARGO_GID ='" + CARGO_GID + "' and OUTNUM>0");
/*
strSql.Append(" or ( CargoInfo_GID=(select top 1 gid from tmswl_lk_cargoInfo where CargoType='托盘')");
strSql.Append(" and PC_BILLNO in (select PC_BILLNO from tmswl_lk_cargo where gid='" + CARGO_GID + "') )) and OUTNUM>0");
* */
}
try
{
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
_Result.totalCount = _count;
}
catch (Exception ee)
{
_Result.Success = false;
_Result.Message = ee.Message;
}
return _Result;
}
static public Resultmb LOCKPC(string PC_BILLNO, string LOCKType)
{
var strSql = new StringBuilder();
var _count = 0;
var _Result = new Resultmb();
Database db = DatabaseFactory.CreateDatabase();
strSql.Append(" update tmswlpchead set ISPC='" + LOCKType + "' where Billno ='" + PC_BILLNO + "'");
try
{
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
_Result.totalCount = _count;
}
catch (Exception ee)
{
_Result.Success = false;
_Result.Message = ee.Message;
}
return _Result;
}
static public Resultmb LOCKBACK(string PC_BILLNO, string LOCKType)
{
var strSql = new StringBuilder();
var _count = 0;
var _Result = new Resultmb();
Database db = DatabaseFactory.CreateDatabase();
strSql.Append(" update tmswlpchead set ISBACK='" + LOCKType + "' where Billno ='" + PC_BILLNO + "'");
try
{
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
_Result.totalCount = _count;
}
catch (Exception ee)
{
_Result.Success = false;
_Result.Message = ee.Message;
}
return _Result;
}
static public Resultmb MakeBoxDo ( string PC_BILLNO, string IOType )
{
var strSql = new StringBuilder();
var _count = 0;
var _Result = new Resultmb();
Database db = DatabaseFactory.CreateDatabase();
if (IOType == "1")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,GID,(select top 1 gid from tmswl_lk_cargoInfo where CargoType='托盘'),PalletCount,0,getdate(),'自动生成',0,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where PC_BILLNO='" + PC_BILLNO + "' group by PC_BILLNO,POINT_GID,GID,PalletCount");
}
if (IOType == "2")
{
strSql.Append(" insert into tmswl_lk_cargoDo (GID,PC_BILLNO,CARGO_GID,CARGOINFO_GID,INNUM,OUTNUM,DODATE,Remark,SEQUENCE,POINT_GID) ");
strSql.Append(" select newid(),PC_BILLNO,GID,(select top 1 gid from tmswl_lk_cargoInfo where CargoType='托盘'),0,PalletCount,getdate(),'自动生成',0,POINT_GID from tmswl_lk_cargo ");
strSql.Append(" where PC_BILLNO='" + PC_BILLNO + "' group by PC_BILLNO,POINT_GID,GID,PalletCount");
}
//strSql.Append(" delete from tmswl_lk_cargoDo where CARGOINFO_GID='' ");
try
{
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
_Result.totalCount = _count;
}
catch (Exception ee)
{
_Result.Success = false;
_Result.Message = ee.Message;
}
return _Result;
}
#endregion
#region 刺猬网下载信息 主表
static public List<MsWl_LK_MCHead> GetMCHeadList ( string condition,string sort )
{
var strSql = new StringBuilder();
strSql.Append(" SELECT ID,PcBillType,SheetCode,SupplierWareHouse,SupplierWareHouseName,State,StateName ");
strSql.Append(" ,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99046 and EnumValueID=PcBillType) PcBillType_Ref ");
strSql.Append(" ,dbo.trimdate(PreArrivalDate) PreArrivalDate,dbo.trimdate(PreDepartDate) PreDepartDate,Remark ");
strSql.Append(" from tMsWl_LK_MCHead ");
if (!string.IsNullOrEmpty(condition))
{
strSql.Append(" where " + condition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by PreArrivalDate,PreDepartDate,SheetCode ");
}
return SetMCHeadData(strSql);
}
private static List<MsWl_LK_MCHead> SetMCHeadData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_MCHead>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWl_LK_MCHead data = new MsWl_LK_MCHead();
#region Set DB data to Object
data.ID = Convert.ToString(reader["ID"]);
data.PcBillType = Convert.ToString(reader["PcBillType"]);
data.PcBillType_Ref = Convert.ToString(reader["PcBillType_Ref"]);
data.SheetCode = Convert.ToString(reader["SheetCode"]);
data.SupplierWareHouse = Convert.ToString(reader["SupplierWareHouse"]);
data.SupplierWareHouseName = Convert.ToString(reader["SupplierWareHouseName"]);
data.State = Convert.ToString(reader["State"]);
data.StateName = Convert.ToString(reader["StateName"]);
data.PreArrivalDate = Convert.ToString(reader["PreArrivalDate"]);
data.PreDepartDate = Convert.ToString(reader["PreDepartDate"]);
data.Remark = Convert.ToString(reader["Remark"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 刺猬网下载信息 从表 商品信息
static public List<MsWl_LK_MCCargo> GetMCCargoList ( string Condition )
{
var strSql = new StringBuilder();
strSql.Append(" select ID,SheetCode,SheetCode_Parent,SEQUENCE,PC_BILLNO ");
strSql.Append(" ,POINT_GID,(select name from tMsWl_LK_POINT where gid=POINT_GID) POINT_NAME ");
strSql.Append(" ,CARGOINFO_GID,(select cargoname from tMsWl_LK_CargoInfo where gid=CARGOINFO_GID) CARGO_NAME ");
strSql.Append(" ,PalletCount,CargoCount,isnull( (select sum(CargoCount) from tMsWl_LK_Cargo where ID=C.ID),0) CargoCount_Do,WEIGHT,Remark,StateName,SignInQuantity ");
strSql.Append(" ,isnull((select sum(outnum) from tmswl_lk_cargodo where Point_GID=C.Point_GID and CARGOINFO_GID in (select gid from tmswl_lk_cargoinfo where cargotype='托盘')),0)");
strSql.Append(" -isnull((select sum(innum) from tmswl_lk_cargodo where Point_GID=C.Point_GID and CARGOINFO_GID in (select gid from tmswl_lk_cargoinfo where cargotype='托盘')),0) as JDTP");
strSql.Append(" from tMsWl_LK_MCCargo C ");
if (!string.IsNullOrEmpty(Condition))
{
strSql.Append(" where " + Condition);
}
strSql.Append(" Order by SheetCode_Parent,SheetCode,POINT_GID,CARGOINFO_GID ");
return SetMCCargoData(strSql);
}
private static List<MsWl_LK_MCCargo> SetMCCargoData ( StringBuilder strSql )
{
var headList = new List<MsWl_LK_MCCargo>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWl_LK_MCCargo data = new MsWl_LK_MCCargo();
#region Set DB data to Object
data.ID = Convert.ToString(reader["ID"]);
data.SheetCode = Convert.ToString(reader["SheetCode"]);
data.SheetCode_Parent = Convert.ToString(reader["SheetCode_Parent"]);
data.SEQUENCE = Convert.ToString(reader["SEQUENCE"]);
data.PC_BILLNO = Convert.ToString(reader["PC_BILLNO"]);
data.POINT_GID = Convert.ToString(reader["POINT_GID"]);
data.POINT_NAME = Convert.ToString(reader["POINT_NAME"]);
data.CARGOINFO_GID = Convert.ToString(reader["CARGOINFO_GID"]);
data.CARGO_NAME = Convert.ToString(reader["CARGO_NAME"]);
data.PalletCount = Convert.ToString(reader["PalletCount"]);
data.CargoCount = Convert.ToString(reader["CargoCount"]);
data.CargoCount_Do = Convert.ToString(reader["CargoCount_Do"]);
data.WEIGHT = Convert.ToString(reader["JDTP"]);
data.Remark = Convert.ToString(reader["Remark"]);
data.StateName = Convert.ToString(reader["StateName"]);
data.SignInQuantity = Convert.ToString(reader["SignInQuantity"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region AddMCCargoToCargo 从刺猬网向派车商品明细加数据
static public int AddMCCargoToCargo(string BillNo, string IDList, string PcBillType)
{
var strSql = new StringBuilder();
if (PcBillType == "4")
{
strSql.Append(" insert into tmswl_lk_cargo (ID,GID,SEQUENCE,PC_BILLNO,CARGOINFO_GID,PalletCount,CargoCount,WEIGHT,POINT_GID,sheetcode) ");
strSql.Append(" select ID,newid(),sequence,'" + BillNo + "',CARGOINFO_GID,PalletCount ");
strSql.Append(" ,CargoCount-isnull( (select sum(CargoCount) from tMsWl_LK_Cargo where ID=tmswl_lk_mccargo.ID),0) CargoCount");
strSql.Append(" ,(select weight from tmswl_lk_cargoinfo where gid=CARGOINFO_GID)*CargoCount weight,POINT_GID,sheetcode ");
strSql.Append(" from tmswl_lk_mccargo where id in( " + IDList + ") ");
}
if (PcBillType == "5")
{
strSql.Append(" insert into tmswl_lk_cargo (ID,GID,SEQUENCE,PC_BILLNO,CARGOINFO_GID,PalletCount,CargoCount,WEIGHT,POINT_GID,sheetcode,AREA) ");
strSql.Append(" select ID,newid(),sequence,'" + BillNo + "' ");
strSql.Append(" ,case when CARGOINFO_GID in('1','258','259','260','261','3') then case (select area from tMsWl_LK_Point where gid=tmswl_lk_mccargo.POINT_GID) when '周边' then CARGOINFO_GID+'_zb' else CARGOINFO_GID end else CARGOINFO_GID end CARGOINFO_GID ");
strSql.Append(" ,PalletCount ,CargoCount-isnull( (select sum(CargoCount) from tMsWl_LK_Cargo where ID=tmswl_lk_mccargo.ID),0) CargoCount");
strSql.Append(" ,(select weight from tmswl_lk_cargoinfo where gid=CARGOINFO_GID)*CargoCount weight,POINT_GID,sheetcode,(select area from tMsWl_LK_Point where gid=tmswl_lk_mccargo.POINT_GID) AREA ");
strSql.Append(" from tmswl_lk_mccargo where id in( " + IDList + ") ");
}
var _count = 0;
Database db = DatabaseFactory.CreateDatabase();
_count = db.ExecuteNonQuery(CommandType.Text, strSql.ToString());
return _count;
}
#endregion
}
}