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/TruckMng/DAL/MsWlBulkPc/MsWlBulkPcDAL.cs

615 lines
28 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.TruckMng.Models.MsWlBulkPc;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.EntityDA;
namespace DSWeb.Areas.TruckMng.DAL.MsWlBulkPc
{
public partial class MsWlBulkPcDAL
{
#region 主表
static public List<MsWlPcHead> 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("p.BillNo,p.LrDate,p.JzDate,p.UserCode,p.UserName,p.OrgCode,p.OrgName");
strSql.Append(",p.TruckNo,");
strSql.Append("(select TruckNo from tMsWlTruck where TruckNo=p.TruckNo) as TruckNo_Ref");
strSql.Append(",DrvCode,oilticketno");//DrvName,
strSql.Append(",(select DrvName from tMsWlDriver where DrvCode=p.Drvcode) as DrvName");
strSql.Append(",(select DrvName from tMsWlDriver where DrvCode=p.Drvcode) as DrvName_Ref");
strSql.Append(",p.Mobile,dbo.trimdate(p.ExpDate) ExpDate,p.DstArea,p.DetiNation,p.FactoryAddr,p.LinkTel,p.LinkMan");
strSql.Append(",p.RatedMil,p.RatedFuel,p.FuelQty,p.RealMil,p.RealFuel,p.NoLoadMil,p.OverLoadMil");
strSql.Append(",p.Ton,p.AroundTon,p.LoadCount,p.ArriveDate,p.DdCode,");
strSql.Append("(select CodeAndName from vMsTruckUser where UserCode=p.DdCode) as DdCode_Ref");
strSql.Append(",p.DdName,p.ReturnDate,p.Remark,p.BillStatus,");
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99026 and EnumValueID=p.BillStatus) as BillStatus_Ref");
strSql.Append(",p.FeeStatus");
strSql.Append(",(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99027 and EnumValueID=p.FeeStatus) as FeeStatus_Ref");
strSql.Append(",p.GId,p.TotalMil,convert(bigint ,p.TimeMark) as TimeMark,p.PcBillType,p.ACCDATE");
strSql.Append(",(select sum(TransTotal) from tMsWlBulkPound where BillNo = p.BillNo) TransTotal ");
strSql.Append(" from tMsWlPcHead p");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
strSql.Append(" order by p.LrDate desc ");
return SetData(strSql);
}
private static List<MsWlPcHead> SetData(StringBuilder strSql)
{
var headList = new List<MsWlPcHead>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWlPcHead data = new MsWlPcHead();
#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.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.DrvName_Ref = Convert.ToString(reader["DrvName_Ref"]);
data.Mobile = Convert.ToString(reader["Mobile"]);
data.ExpDate = Convert.ToString(reader["ExpDate"]);
data.DstArea = Convert.ToString(reader["DstArea"]);
data.DetiNation = Convert.ToString(reader["DetiNation"]);
data.FactoryAddr = Convert.ToString(reader["FactoryAddr"]);
data.LinkTel = Convert.ToString(reader["LinkTel"]);
data.LinkMan = Convert.ToString(reader["LinkMan"]);
data.RatedMil = Convert.ToDecimal(reader["RatedMil"]);
data.RatedFuel = Convert.ToDecimal(reader["RatedFuel"]);
data.FuelQty = Convert.ToDecimal(reader["FuelQty"]);
data.RealMil = Convert.ToDecimal(reader["RealMil"]);
data.RealFuel = Convert.ToDecimal(reader["RealFuel"]);
data.NoLoadMil = Convert.ToDecimal(reader["NoLoadMil"]);
data.OverLoadMil = Convert.ToDecimal(reader["OverLoadMil"]);
data.Ton = Convert.ToDecimal(reader["Ton"]);
data.AroundTon = Convert.ToDecimal(reader["AroundTon"]);
data.LoadCount = Convert.ToDecimal(reader["LoadCount"]);
data.ArriveDate = Convert.ToString(reader["ArriveDate"]);
data.DdCode = Convert.ToString(reader["DdCode"]);
data.DdCode_Ref = Convert.ToString(reader["DdCode_Ref"]);
data.DdName = Convert.ToString(reader["DdName"]);
data.ReturnDate = Convert.ToString(reader["ReturnDate"]);
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.GId = Convert.ToString(reader["GId"]);
data.TotalMil = Convert.ToDecimal(reader["TotalMil"]);
data.TimeMark = Convert.ToDecimal(reader["TimeMark"]);
data.PcBillType = Convert.ToString(reader["PcBillType"]);
data.OilticketNO = Convert.ToString(reader["OilticketNO"]);
data.ACCDATE = Convert.ToString(reader["ACCDATE"]);
data.TransTotal = Convert.ToString(reader["TransTotal"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public MsWlPcHead GetHeadDataByBillNo(string billno, string userid, string usercode, string orgcode)
{
MsWlPcHead data = null;
var list = GetDataList(" BillNo='" + billno + "'",userid,usercode,orgcode);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new MsWlPcHead();
}
return data;
}
#endregion
#region 明细表
static public List<MsWlBulkPound> GetBodyList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("BillNo,SerialNo,BulkBillNo,GId,CustCode,");
strSql.Append("(select CodeAndName from vMsTruckClient where CustCode=tMsWlBulkPound.CustCode) as CustCode_Ref");
strSql.Append(",CustName,PayCustCode,");
strSql.Append("(select CodeAndName from vMsTruckClient where CustCode=tMsWlBulkPound.PayCustCode) as PayCustCode_Ref");
strSql.Append(",PayCustName,TransPrice,ClsName,PackSpec,DepartureDate,DepartureTime,LoadPlace,UnLoadPlace");
strSql.Append(",PlanOverLoadMil,PlanNoLoadMil,PlanLoadCount,OverLoadMil,NoLoadMil,LoadCount,Weight");
strSql.Append(",TransTotal,TruckNo,DrvName,WorkTime,UnLoadCount,RatedFuel,TonMil,HeapWeight,OneMil");
strSql.Append(" from tMsWlBulkPound ");
if (strCondition.Trim() != String.Empty)
{
strSql.Append(" where " + strCondition);
}
return SetBodyData(strSql);
}
private static List<MsWlBulkPound> SetBodyData(StringBuilder strSql)
{
var bodyList = new List<MsWlBulkPound>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWlBulkPound data = new MsWlBulkPound();
#region Set DB data to Object
data.BillNo = Convert.ToString(reader["BillNo"]);
data.SerialNo = Convert.ToDecimal(reader["SerialNo"]);
data.BulkBillNo = Convert.ToString(reader["BulkBillNo"]);
data.GId = Convert.ToString(reader["GId"]);
data.CustCode = Convert.ToString(reader["CustCode"]);
data.CustCode_Ref = Convert.ToString(reader["CustCode_Ref"]);
data.CustName = Convert.ToString(reader["CustName"]);
data.PayCustCode = Convert.ToString(reader["PayCustCode"]);
data.PayCustCode_Ref = Convert.ToString(reader["PayCustCode_Ref"]);
data.PayCustName = Convert.ToString(reader["PayCustName"]);
data.TransPrice = Convert.ToDecimal(reader["TransPrice"]);
data.ClsName = Convert.ToString(reader["ClsName"]);
data.PackSpec = Convert.ToString(reader["PackSpec"]);
data.DepartureDate = Convert.ToString(reader["DepartureDate"]);
data.DepartureTime = Convert.ToString(reader["DepartureTime"]);
data.LoadPlace = Convert.ToString(reader["LoadPlace"]);
data.UnLoadPlace = Convert.ToString(reader["UnLoadPlace"]);
data.PlanOverLoadMil = Convert.ToDecimal(reader["PlanOverLoadMil"]);
data.PlanNoLoadMil = Convert.ToDecimal(reader["PlanNoLoadMil"]);
data.PlanLoadCount = Convert.ToDecimal(reader["PlanLoadCount"]);
data.OverLoadMil = Convert.ToDecimal(reader["OverLoadMil"]);
data.NoLoadMil = Convert.ToDecimal(reader["NoLoadMil"]);
data.LoadCount = Convert.ToDecimal(reader["LoadCount"]);
data.Weight = Convert.ToDecimal(reader["Weight"]);
data.TransTotal = Convert.ToDecimal(reader["TransTotal"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.DrvName = Convert.ToString(reader["DrvName"]);
data.WorkTime = Convert.ToString(reader["WorkTime"]);
data.UnLoadCount = Convert.ToDecimal(reader["UnLoadCount"]);
data.RatedFuel = Convert.ToDecimal(reader["RatedFuel"]);
data.TonMil = Convert.ToDecimal(reader["TonMil"]);
data.HeapWeight = Convert.ToDecimal(reader["HeapWeight"]);
data.OneMil = Convert.ToDecimal(reader["OneMil"]);
#endregion
bodyList.Add(data);
}
reader.Close();
}
return bodyList;
}
#endregion
static public List<MsWlBulkQueryPound> GetDataQueryList(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("b.BillNo,b.SerialNo,b.BulkBillNo,b.GId,b.CustCode,");
strSql.Append("b.CustName,");
strSql.Append("b.TransPrice,b.ClsName,b.DepartureDate,b.DepartureTime,b.LoadPlace,b.UnLoadPlace");
strSql.Append(",b.PlanOverLoadMil,b.PlanNoLoadMil,b.PlanLoadCount,b.OverLoadMil,b.NoLoadMil,b.LoadCount,b.Weight");
strSql.Append(",b.TransTotal,p.TruckNo,p.DrvName,b.WorkTime,b.UnLoadCount,b.RatedFuel,b.TonMil,b.HeapWeight,b.OneMil");
strSql.Append(",p.UserCode,p.UserName,p.OrgCode,p.OrgName,dbo.trimdate(p.ExpDate) ExpDate,h.Vessel");
strSql.Append(" from tMsWlBulkPound b left join tMsWlPcHead p on (p.BillNo=b.BillNo)");
strSql.Append(" left join tMsWlBulkHead h on (h.BillNo=b.BulkBillNo)");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
return SetQueryData(strSql);
}
private static List<MsWlBulkQueryPound> SetQueryData(StringBuilder strSql)
{
var headList = new List<MsWlBulkQueryPound>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
MsWlBulkQueryPound data = new MsWlBulkQueryPound();
#region Set DB data to Object
data.BillNo = Convert.ToString(reader["BillNo"]);
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.DrvName = Convert.ToString(reader["DrvName"]);
data.ExpDate = Convert.ToString(reader["ExpDate"]);
data.CustCode = Convert.ToString(reader["CustCode"]);
data.CustName = Convert.ToString(reader["CustName"]);
data.TransPrice = Convert.ToDecimal(reader["TransPrice"]);
data.ClsName = Convert.ToString(reader["ClsName"]);
data.DepartureDate = Convert.ToString(reader["DepartureDate"]);
data.DepartureTime = Convert.ToString(reader["DepartureTime"]);
data.LoadPlace = Convert.ToString(reader["LoadPlace"]);
data.UnLoadPlace = Convert.ToString(reader["UnLoadPlace"]);
data.PlanOverLoadMil = Convert.ToDecimal(reader["PlanOverLoadMil"]);
data.PlanNoLoadMil = Convert.ToDecimal(reader["PlanNoLoadMil"]);
data.PlanLoadCount = Convert.ToDecimal(reader["PlanLoadCount"]);
data.OverLoadMil = Convert.ToDecimal(reader["OverLoadMil"]);
data.NoLoadMil = Convert.ToDecimal(reader["NoLoadMil"]);
data.LoadCount = Convert.ToDecimal(reader["LoadCount"]);
data.Weight = Convert.ToDecimal(reader["Weight"]);
data.TransTotal = Convert.ToDecimal(reader["TransTotal"]);
data.TruckNo = Convert.ToString(reader["TruckNo"]);
data.DrvName = Convert.ToString(reader["DrvName"]);
data.WorkTime = Convert.ToString(reader["WorkTime"]);
data.UnLoadCount = Convert.ToDecimal(reader["UnLoadCount"]);
data.RatedFuel = Convert.ToDecimal(reader["RatedFuel"]);
data.TonMil = Convert.ToDecimal(reader["TonMil"]);
data.HeapWeight = Convert.ToDecimal(reader["HeapWeight"]);
data.Vessel = Convert.ToString(reader["Vessel"]);
data.OneMil = Convert.ToDecimal(reader["OneMil"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#region 参照部分
internal static List<MsWlPcHeadRefMsWlTruck> GetTruckNoList(string userid, string usercode, string orgcode)
{
var rangstr = GetRangDAStr2("", 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<MsWlPcHeadRefMsWlTruck>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWlPcHeadRefMsWlTruck();
#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<MsWlPcHeadRefMsWlDriver> GetDrvNameList(string userid, string usercode, string orgcode)
{
var rangstr = GetRangDAStr2("", userid, usercode, orgcode);
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" DrvCode,DrvName");
strSql.Append(" from tMsWlDriver");
if (!string.IsNullOrEmpty(rangstr))
{
strSql.Append(" where " + rangstr);
}
var dataList = new List<MsWlPcHeadRefMsWlDriver>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWlPcHeadRefMsWlDriver();
#region Set DB data to Object
data.DrvCode = Convert.ToString(reader["DrvCode"]);
data.DrvName = Convert.ToString(reader["DrvName"]);
data.CodeAndName = data.DrvCode + "-" + data.DrvName;
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
#endregion
public static List<MsWlBulkPoundRefMsWlBulkHead> GetBulkBillNoList(string userid, string usercode, string orgcode)
{
var rangstr = GetRangDAStr2("index2", userid, usercode, orgcode);
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append(" BillNo");
strSql.Append(" from tMsWlBulkHead");
strSql.Append(" where BillStatus<>'9'");
if (!string.IsNullOrEmpty(rangstr))
{
strSql.Append(" and " + rangstr);
}
var dataList = new List<MsWlBulkPoundRefMsWlBulkHead>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var data = new MsWlBulkPoundRefMsWlBulkHead();
#region Set DB data to Object
data.BillNo = Convert.ToString(reader["BillNo"]);
#endregion
dataList.Add(data);
}
reader.Close();
}
return dataList;
}
internal static decimal GetTruckFuel(string truckNo, decimal overmil, decimal ton, decimal mil, decimal unloadcount)
{
var strSql = new StringBuilder();
strSql.Append("select UnloadFuel,BasisFuel,TonMilFuel ");
strSql.Append(" from tMsWlTruck ");
strSql.Append(" where TruckNo='{0}' ");
var sql = strSql.ToString();
sql = string.Format(sql, truckNo);
decimal BasisFuel = 0;
decimal unloadfuel = 0;
decimal TonMilFuel = 0;
decimal total = 0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
{
while (reader.Read())
{
unloadfuel = Convert.ToDecimal(reader["UnloadFuel"]);
BasisFuel = Convert.ToDecimal(reader["BasisFuel"]);
TonMilFuel = Convert.ToDecimal(reader["TonMilFuel"]);
break;
}
reader.Close();
}
total = decimal.Round(((overmil+mil) * BasisFuel / 100) + (unloadfuel * unloadcount)+ton*TonMilFuel, 2);
return total;
}
public static string GetRangDAStr2(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]='modTruckBulk' 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 + "' or DdCode='" + usercode + "')";
}
else if (tb == "index2")
{
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 + "'))"
+ " or DdCode 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 if (tb == "index2")
{
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;
}
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]='modTruckBulk' 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 = " (p.UserCode='" + usercode + "' or p.DdCode='" + usercode + "')";
}
else if (tb == "index2")
{
str = " p.UserCode='" + usercode + "'";
}
else
{
str = " UPPER(p.OrgCode)='" + orgcode + "'";
}
}
else if (visiblerange == "2")
{
if (tb == "index")
{
var rangeDa = new RangeDA();
var companyid = rangeDa.GetCORPID(userid);
var deptname = rangeDa.GetDEPTNAME(userid);
str = " (p.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 p.DdCode 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 if (tb == "index2")
{
var rangeDa = new RangeDA();
var companyid = rangeDa.GetCORPID(userid);
var deptname = rangeDa.GetDEPTNAME(userid);
str = " p.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(p.OrgCode)='" + orgcode + "'";
}
}
else if (visiblerange == "1")
{
str = " UPPER(p.OrgCode)='" + orgcode + "'";
}
return str;
}
}
}