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.
518 lines
26 KiB
C#
518 lines
26 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.Areas.TruckMng.Models.MsWlBs;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
namespace DSWeb.Areas.TruckMng.DAL.MsWlBs
|
|
{
|
|
public partial class MsWlBsDAL
|
|
{
|
|
#region 主表
|
|
|
|
static public List<MsWlBsHead> GetDataList(string condition, string userid, string usercode, string orgcode,string sort=null)
|
|
{
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
condition = condition + " and " + rangstr;
|
|
}
|
|
else
|
|
{
|
|
condition = rangstr;
|
|
}
|
|
}
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("BillNo,LrDate,JzDate,UserCode,UserName,OrgCode,OrgName");
|
|
strSql.Append(",LogisticsNo,CustCode,CustName,CustName+'-'+BillNo as CustName_Ref");
|
|
//strSql.Append("(select CustName from vMsTruckClient where CustCode=tMsWlBsHead.CustCode) as CustName_Ref");
|
|
strSql.Append(",CustDate,VoyVeg,");
|
|
strSql.Append("(select VoyName from vMsTruckVoyInfo where VoyCode=tMsWlBsHead.VoyVeg) as VoyVeg_Ref");
|
|
strSql.Append(",EtDate,EndPortDate,MblNo,SalesCode,");
|
|
strSql.Append("(select top 1 UserName from vMsTruckUser where UserCode=tMsWlBsHead.SalesCode) as SalesCode_Ref");
|
|
strSql.Append(",SalesName,DispatchCode,");
|
|
strSql.Append("(select top 1 UserName from vMsTruckUser where UserCode=tMsWlBsHead.DispatchCode) as DispatchCode_Ref");
|
|
strSql.Append(",DispatchName,SendYardCode,");
|
|
strSql.Append("(select top 1 CustName from vMsTruckClient where CustCode=tMsWlBsHead.SendYardCode) as SendYardCode_Ref");
|
|
strSql.Append(",SendYardName,RtnYardCode,RtnYard,DstArea,DetiNation,DetiLinkTel,DetiLinkMan");
|
|
strSql.Append(",Remark,BsType,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99025 and EnumValueID=tMsWlBsHead.BsType) as BsType_Ref");
|
|
strSql.Append(",BillStatus,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99026 and EnumValueID=tMsWlBsHead.BillStatus) as BillStatus_Ref");
|
|
strSql.Append(",BsStatus,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99029 and EnumValueID=tMsWlBsHead.BsStatus) as BsStatus_Ref");
|
|
strSql.Append(",FeeStatus,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99027 and EnumValueID=tMsWlBsHead.FeeStatus) as FeeStatus_Ref");
|
|
strSql.Append(",GId, convert(bigint ,TimeMark) as TimeMark");
|
|
strSql.Append(",CustLikeManCode,CustLikeManName,CustTel");
|
|
strSql.Append(",NeadLoadDate,NeedArriveDate,BillRises1");
|
|
|
|
strSql.Append(",FeeOpStatus,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99035 and EnumValueID=tMsWlBsHead.FeeOpStatus) as FeeOpStatus_Ref");
|
|
strSql.Append(",VoyVegSe,GoodsName");
|
|
strSql.Append(",(case when ((select count(*) from tMsWlPcHead where RefBillNo=tMsWlBsHead.BillNo)+(select count(*) from BS_PC_Status where BS_BILLNO=tMsWlBsHead.BillNo))>0 then 0 else 1 end) pctype");//0派车 1未派车 用来对应费用颜色1录入状态无色 0审核通过绿色
|
|
strSql.Append(",dbo.f_bs_truckNo(billno) TruckNo,dbo.F_BSCTN(GId) CtnInfo");
|
|
strSql.Append(",tMsWlBsHead.PKGS,tMsWlBsHead.KINDPKGS,tMsWlBsHead.KGS,tMsWlBsHead.CBM");
|
|
strSql.Append(",PC.PKGS PCPKGS,PC.KGS PCKGS,PC.CBM PCCBM,LoadPlace,FactoryAddr");
|
|
strSql.Append(",TRANSSTATUS,ORDERNO,CONTRACTNO,TEMPLATENAME,ISFEE,PORTLOAD");
|
|
|
|
strSql.Append(" from tMsWlBsHead ");
|
|
strSql.Append(" left join (select RefBillNoSe,sum(isnull(GOODSCOUNT,0)) PKGS,sum(isnull(CBM,0)) CBM,sum(isnull(Ton,0)) KGS FROM tMsWlPcHead GROUP BY RefBillNoSe ) PC ON (PC.RefBillNoSe=tMsWlBsHead.BillNo)");
|
|
|
|
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 LrDate desc ");
|
|
|
|
}
|
|
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public List<MsWlBsHead> GetAuditDataList(string condition, string isaudit, string userid, string usercode, string orgcode, string sort = null)
|
|
{
|
|
|
|
var rangstr = GetRangDAStr("index", userid, usercode, orgcode);
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("BillNo,LrDate,JzDate,UserCode,UserName,OrgCode,OrgName");
|
|
strSql.Append(",LogisticsNo,CustCode,CustName,CustName+'-'+BillNo as CustName_Ref");
|
|
//strSql.Append("(select CustName from vMsTruckClient where CustCode=tMsWlBsHead.CustCode) as CustName_Ref");
|
|
strSql.Append(",CustDate,VoyVeg,");
|
|
strSql.Append("(select VoyName from vMsTruckVoyInfo where VoyCode=tMsWlBsHead.VoyVeg) as VoyVeg_Ref");
|
|
strSql.Append(",EtDate,EndPortDate,MblNo,SalesCode,");
|
|
strSql.Append("(select top 1 UserName from vMsTruckUser where UserCode=tMsWlBsHead.SalesCode) as SalesCode_Ref");
|
|
strSql.Append(",SalesName,DispatchCode,");
|
|
strSql.Append("(select top 1 UserName from vMsTruckUser where UserCode=tMsWlBsHead.DispatchCode) as DispatchCode_Ref");
|
|
strSql.Append(",DispatchName,SendYardCode,");
|
|
strSql.Append("(select top 1 CustName from vMsTruckClient where CustCode=tMsWlBsHead.SendYardCode) as SendYardCode_Ref");
|
|
strSql.Append(",SendYardName,RtnYardCode,RtnYard,DstArea,DetiNation,DetiLinkTel,DetiLinkMan");
|
|
strSql.Append(",Remark,BsType,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99025 and EnumValueID=tMsWlBsHead.BsType) as BsType_Ref");
|
|
strSql.Append(",BillStatus,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99026 and EnumValueID=tMsWlBsHead.BillStatus) as BillStatus_Ref");
|
|
strSql.Append(",BsStatus,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99029 and EnumValueID=tMsWlBsHead.BsStatus) as BsStatus_Ref");
|
|
strSql.Append(",FeeStatus,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99027 and EnumValueID=tMsWlBsHead.FeeStatus) as FeeStatus_Ref");
|
|
strSql.Append(",GId, convert(bigint ,TimeMark) as TimeMark");
|
|
strSql.Append(",CustLikeManCode,CustLikeManName,CustTel");
|
|
strSql.Append(",NeadLoadDate,NeedArriveDate,BillRises1");
|
|
|
|
strSql.Append(",FeeOpStatus,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99035 and EnumValueID=tMsWlBsHead.FeeOpStatus) as FeeOpStatus_Ref");
|
|
strSql.Append(",VoyVegSe,GoodsName");
|
|
strSql.Append(",(case when ((select count(*) from tMsWlPcHead where RefBillNo=tMsWlBsHead.BillNo)+(select count(*) from BS_PC_Status where BS_BILLNO=tMsWlBsHead.BillNo))>0 then 0 else 1 end) pctype");//0派车 1未派车 用来对应费用颜色1录入状态无色 0审核通过绿色
|
|
strSql.Append(",dbo.f_bs_truckNo(billno) TruckNo,dbo.F_BSCTN(GId) CtnInfo");
|
|
strSql.Append(",tMsWlBsHead.PKGS,tMsWlBsHead.KINDPKGS,tMsWlBsHead.KGS,tMsWlBsHead.CBM");
|
|
strSql.Append(",PC.PKGS PCPKGS,PC.KGS PCKGS,PC.CBM PCCBM,LoadPlace,FactoryAddr");
|
|
strSql.Append(",TRANSSTATUS,ORDERNO,CONTRACTNO,TEMPLATENAME,ISFEE,PORTLOAD");
|
|
|
|
strSql.Append(" from tMsWlBsHead ");
|
|
strSql.Append(" left join (select RefBillNoSe,sum(isnull(GOODSCOUNT,0)) PKGS,sum(isnull(CBM,0)) CBM,sum(isnull(Ton,0)) KGS FROM tMsWlPcHead GROUP BY RefBillNoSe ) PC ON (PC.RefBillNoSe=tMsWlBsHead.BillNo)");
|
|
strSql.Append(" left join workflow_using wu on wu.bsno=tMsWlBsHead.BillNo where 1=1 ");
|
|
if (isaudit == "3")
|
|
strSql.Append(" and dbo.[GetUsingStep](wu.WORKFLOWID,wu.currentid,'" + userid + "',wu.stepno)>0 ");
|
|
else if (isaudit == "2")
|
|
{
|
|
strSql.Append(" and tMsWlBsHead.TRANSSTATUS='审核通过' ");// AND I.BILLNO IN (select distinct billno from workflow_do where auditor='" + userid + "' ) ");
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
strSql.Append(" and " + rangstr);
|
|
}
|
|
}
|
|
else if (isaudit == "1")
|
|
{
|
|
strSql.Append(" and tMsWlBsHead.TRANSSTATUS='提交审核' ");// AND I.BILLNO IN (select distinct billno from workflow_do where auditor='" + userid + "' ) ");
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
strSql.Append(" and " + rangstr);
|
|
}
|
|
}
|
|
else if (isaudit == "")
|
|
{
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
{
|
|
strSql.Append(" and " + rangstr);
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(condition))
|
|
{
|
|
strSql.Append(" and " + condition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else
|
|
{
|
|
|
|
strSql.Append(" order by LrDate desc ");
|
|
|
|
}
|
|
|
|
return SetData(strSql);
|
|
}
|
|
|
|
|
|
private static List<MsWlBsHead> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<MsWlBsHead>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsWlBsHead data = new MsWlBsHead();
|
|
#region Set DB data to Object
|
|
data.BillNo = Convert.ToString(reader["BillNo"]);
|
|
if (reader["LrDate"] != DBNull.Value)
|
|
data.LrDate = Convert.ToDateTime(reader["LrDate"]);
|
|
if (reader["JzDate"] != DBNull.Value)
|
|
data.JzDate = Convert.ToDateTime(reader["JzDate"]);
|
|
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.LogisticsNo = Convert.ToString(reader["LogisticsNo"]);
|
|
data.CustCode = Convert.ToString(reader["CustCode"]);
|
|
data.CustName = Convert.ToString(reader["CustName"]);
|
|
data.CustName_Ref = Convert.ToString(reader["CustName_Ref"]);
|
|
data.CustDate = Convert.ToString(reader["CustDate"]);
|
|
data.VoyVeg = Convert.ToString(reader["VoyVeg"]);
|
|
data.VoyVeg_Ref = Convert.ToString(reader["VoyVeg_Ref"]);
|
|
data.EtDate = Convert.ToString(reader["EtDate"]);
|
|
data.EndPortDate = Convert.ToString(reader["EndPortDate"]);
|
|
data.MblNo = Convert.ToString(reader["MblNo"]);
|
|
data.SalesCode = Convert.ToString(reader["SalesCode"]);
|
|
data.SalesCode_Ref = Convert.ToString(reader["SalesCode_Ref"]);
|
|
data.SalesName = Convert.ToString(reader["SalesName"]);
|
|
data.DispatchCode = Convert.ToString(reader["DispatchCode"]);
|
|
data.DispatchCode_Ref = Convert.ToString(reader["DispatchCode_Ref"]);
|
|
data.DispatchName = Convert.ToString(reader["DispatchName"]);
|
|
data.SendYardCode = Convert.ToString(reader["SendYardCode"]);
|
|
data.SendYardCode_Ref = Convert.ToString(reader["SendYardCode_Ref"]);
|
|
data.SendYardName = Convert.ToString(reader["SendYardName"]);
|
|
data.RtnYardCode = Convert.ToString(reader["RtnYardCode"]);
|
|
data.RtnYard = Convert.ToString(reader["RtnYard"]);
|
|
data.LoadPlace = Convert.ToString(reader["LoadPlace"]);
|
|
data.FactoryAddr = Convert.ToString(reader["FactoryAddr"]);
|
|
|
|
data.DstArea = Convert.ToString(reader["DstArea"]);
|
|
data.DetiNation = Convert.ToString(reader["DetiNation"]);
|
|
data.DetiLinkTel = Convert.ToString(reader["DetiLinkTel"]);
|
|
data.DetiLinkMan = Convert.ToString(reader["DetiLinkMan"]);
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
data.BsType = Convert.ToString(reader["BsType"]);
|
|
data.BsType_Ref = Convert.ToString(reader["BsType_Ref"]);
|
|
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.BsStatus = Convert.ToString(reader["BsStatus"]);
|
|
data.BsStatus_Ref = Convert.ToString(reader["BsStatus_Ref"]);
|
|
data.GId = Convert.ToString(reader["GId"]);
|
|
data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
|
|
|
|
data.CustLikeManCode = Convert.ToString(reader["CustLikeManCode"]);
|
|
data.CustLikeManName = Convert.ToString(reader["CustLikeManName"]);
|
|
data.CustTel = Convert.ToString(reader["CustTel"]);
|
|
|
|
data.NeadLoadDate = Convert.ToString(reader["NeadLoadDate"]);
|
|
data.NeedArriveDate = Convert.ToString(reader["NeedArriveDate"]);
|
|
|
|
data.BillRises1 = Convert.ToString(reader["BillRises1"]);
|
|
|
|
data.FeeOpStatus = Convert.ToString(reader["FeeOpStatus"]);
|
|
data.FeeOpStatus_Ref = Convert.ToString(reader["FeeOpStatus_Ref"]);
|
|
|
|
data.VoyVegSe = Convert.ToString(reader["VoyVegSe"]);
|
|
data.GoodsName = Convert.ToString(reader["GoodsName"]);
|
|
data.PcType = Convert.ToString(reader["PcType"]);
|
|
data.TruckNo = Convert.ToString(reader["TruckNo"]);
|
|
data.CtnInfo = Convert.ToString(reader["CtnInfo"]);
|
|
if (reader["PKGS"] != DBNull.Value)
|
|
data.PKGS = Convert.ToDecimal(reader["PKGS"]);
|
|
if (reader["KGS"] != DBNull.Value)
|
|
data.KGS = Convert.ToDecimal(reader["KGS"]);
|
|
if (reader["CBM"] != DBNull.Value)
|
|
data.CBM = Convert.ToDecimal(reader["CBM"]);
|
|
data.KINDPKGS = Convert.ToString(reader["KINDPKGS"]);
|
|
if (reader["PCPKGS"] != DBNull.Value)
|
|
data.PCPKGS = Convert.ToDecimal(reader["PCPKGS"]);
|
|
if (reader["PCKGS"] != DBNull.Value)
|
|
data.PCKGS = Convert.ToDecimal(reader["PCKGS"]);
|
|
if (reader["PCCBM"] != DBNull.Value)
|
|
data.PCCBM = Convert.ToDecimal(reader["PCCBM"]);
|
|
|
|
data.NPKGS = data.PKGS - data.PCPKGS;
|
|
data.NKGS = data.KGS - data.PCKGS;
|
|
data.NCBM = data.CBM - data.PCCBM;
|
|
data.TRANSSTATUS = Convert.ToString(reader["TRANSSTATUS"]);
|
|
data.ORDERNO = Convert.ToString(reader["ORDERNO"]);
|
|
data.CONTRACTNO = Convert.ToString(reader["CONTRACTNO"]);
|
|
data.TEMPLATENAME = Convert.ToString(reader["TEMPLATENAME"]);
|
|
data.ISFEE = Convert.ToString(reader["ISFEE"]);
|
|
data.PORTLOAD = Convert.ToString(reader["PORTLOAD"]);
|
|
|
|
|
|
#endregion
|
|
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
return headList;
|
|
}
|
|
|
|
static public MsWlBsHead GetHeadDataByBillNo(string billno, string userid, string usercode, string orgcode)
|
|
{
|
|
MsWlBsHead data = null;
|
|
var list = GetDataList(" BillNo='" + billno + "'",userid,usercode,orgcode);
|
|
if (list.Count > 0)
|
|
data = list[0];
|
|
|
|
if (data == null)
|
|
{
|
|
data = new MsWlBsHead();
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 明细表
|
|
|
|
static public List<MsWlBsFixed> GetBodyList(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=tMsWlBsFixed.CreditDebit) as CreditDebit_Ref");
|
|
strSql.Append(",FeeTypeCode,");
|
|
strSql.Append("(select Name from vMsTruckFeeType where FeeCode=tMsWlBsFixed.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=tMsWlBsFixed.FeeStatus) as FeeStatus_Ref");
|
|
strSql.Append(",SubmitDate,Auditoperator,AuditDate,AuditStatus");
|
|
strSql.Append(" from tMsWlBsFixed ");
|
|
|
|
if (strCondition.Trim() != String.Empty)
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetBodyData(strSql);
|
|
}
|
|
|
|
private static List<MsWlBsFixed> SetBodyData(StringBuilder strSql)
|
|
{
|
|
var bodyList = new List<MsWlBsFixed>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
MsWlBsFixed data = new MsWlBsFixed();
|
|
#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 参照部分
|
|
|
|
|
|
public static string GetRangDAStr(string tb, string userid, string usercode, string orgcode)
|
|
{
|
|
string str = "";
|
|
if (userid == "")
|
|
{
|
|
return str;
|
|
}
|
|
else
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" VISIBLERANGE,OPERATERANGE ");
|
|
strSql.Append(" from VW_User_Authority ");
|
|
strSql.Append(" where [NAME]='modTruckBs' 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 = " (UserCode='" + usercode + "' or DispatchCode='" + usercode + "')";
|
|
}
|
|
else if (visiblerange == "3")
|
|
{
|
|
if (tb == "index")
|
|
{
|
|
str = " (UserCode='" + usercode + "' or DispatchCode='"+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 + "'))"
|
|
+ " or DispatchCode 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;
|
|
}
|
|
}
|
|
|
|
|
|
internal static Boolean GetBsIsPrint(string billno,string Gid)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT count(B.Gid) as RecCount ");
|
|
strSql.Append(" from ch_fee B left join vMsWlPcHeadPrint A on A.Gid=B.BsNo where ");
|
|
strSql.Append(" B.FeeStatus in (1,2,6) and A.Gid=B.BsNo and A.RefBillNo='" + billno + "' or B.bsno='" + Gid + "'");
|
|
var Rcount = 0;
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
|
|
#region Set DB data to Object
|
|
Rcount = Convert.ToInt16(reader["RecCount"]);
|
|
#endregion
|
|
}
|
|
reader.Close();
|
|
}
|
|
if (Rcount==0) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 托单录入判断提单号是否可用
|
|
/// </summary>
|
|
/// <param name="mblno"></param>
|
|
/// <returns></returns>
|
|
public static bool checkMBLNOValid (string mblno,string billno) {
|
|
string sqlcheck = @"SELECT [PARAMVALUE] FROM [sys_param_set] WHERE GID = '6244A649-45D9-489D-ADE9-D1E96D10D111'";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
int flag = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sqlcheck));
|
|
|
|
bool isHasOrder = checkMBLNOHasOrder(mblno,billno);
|
|
bool result = false;
|
|
if (flag==0)
|
|
{
|
|
result = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
result = !isHasOrder;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断提单号下是否已经存在托单
|
|
/// </summary>
|
|
/// <param name="mblno"></param>
|
|
/// <returns></returns>
|
|
private static bool checkMBLNOHasOrder (string mblno,string billno) {
|
|
string sql = "SELECT count(*) FROM tMsWlBsHead where MblNo = '" + mblno + "' and BillNo<>'"+billno+"'";
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
int flag = Convert.ToInt32(db.ExecuteScalar(CommandType.Text, sql));
|
|
if (flag>0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|