|
|
|
|
using System;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using DSWeb.Areas.TruckMng.Models.MsWlTyreScrap;
|
|
|
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
|
using DSWeb.EntityDA;
|
|
|
|
|
|
|
|
|
|
namespace DSWeb.Areas.TruckMng.DAL.MsWlTyreScrap
|
|
|
|
|
{
|
|
|
|
|
public partial class MsWlTyreScrapDAL
|
|
|
|
|
{
|
|
|
|
|
#region Inquery DataList
|
|
|
|
|
|
|
|
|
|
static public List<Models.MsWlTyreScrap.MsWlTyreScrap> GetDataList(string strCondition, string userid, string usercode, string orgcode)
|
|
|
|
|
{
|
|
|
|
|
var rangstr = GetRangDAStr("", 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("SerialNo,OrgCode,");
|
|
|
|
|
strSql.Append("(select CodeAndName from vMsTruckOrg where OrgCode=tMsWlTyreScrap.OrgCode) as OrgCode_Ref");
|
|
|
|
|
strSql.Append(",TruckNo,");
|
|
|
|
|
strSql.Append("(select TruckSpec from tMsWlTruck where TruckNo=tMsWlTyreScrap.TruckNo) as TruckNo_Ref");
|
|
|
|
|
strSql.Append(",PcNo,PluCode,");
|
|
|
|
|
strSql.Append("(select BarCode from tMsTruckPlu where PluCode=tMsWlTyreScrap.PluCode) as PluCode_Ref");
|
|
|
|
|
strSql.Append(",PluName,Spec,TyreType,");
|
|
|
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99013 and EnumValueID=tMsWlTyreScrap.TyreType) as TyreType_Ref");
|
|
|
|
|
strSql.Append(",TyrePos,");
|
|
|
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99015 and EnumValueID=tMsWlTyreScrap.TyrePos) as TyrePos_Ref");
|
|
|
|
|
strSql.Append(",RealMil,ScrapDate,ScrapReason,Remark");
|
|
|
|
|
strSql.Append(" from tMsWlTyreScrap ");
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + strCondition);
|
|
|
|
|
}
|
|
|
|
|
return SetData(strSql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static public Models.MsWlTyreScrap.MsWlTyreScrap GetData(string condition, string userid, string usercode, string orgcode)
|
|
|
|
|
{
|
|
|
|
|
var list = GetDataList(condition,userid,usercode,orgcode);
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
|
return list[0];
|
|
|
|
|
|
|
|
|
|
return new Models.MsWlTyreScrap.MsWlTyreScrap();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static List<Models.MsWlTyreScrap.MsWlTyreScrap> SetData(StringBuilder strSql)
|
|
|
|
|
{
|
|
|
|
|
var headList = new List<Models.MsWlTyreScrap.MsWlTyreScrap>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
Models.MsWlTyreScrap.MsWlTyreScrap data = new Models.MsWlTyreScrap.MsWlTyreScrap();
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
data.SerialNo = Convert.ToDecimal(reader["SerialNo"]);
|
|
|
|
|
data.OrgCode = Convert.ToString(reader["OrgCode"]);
|
|
|
|
|
data.OrgCode_Ref = Convert.ToString(reader["OrgCode_Ref"]);
|
|
|
|
|
data.TruckNo = Convert.ToString(reader["TruckNo"]);
|
|
|
|
|
data.TruckNo_Ref = Convert.ToString(reader["TruckNo_Ref"]);
|
|
|
|
|
data.PcNo = Convert.ToString(reader["PcNo"]);
|
|
|
|
|
data.PluCode = Convert.ToString(reader["PluCode"]);
|
|
|
|
|
data.PluCode_Ref = Convert.ToString(reader["PluCode_Ref"]);
|
|
|
|
|
data.PluName = Convert.ToString(reader["PluName"]);
|
|
|
|
|
data.Spec = Convert.ToString(reader["Spec"]);
|
|
|
|
|
data.TyreType = Convert.ToString(reader["TyreType"]);
|
|
|
|
|
data.TyreType_Ref = Convert.ToString(reader["TyreType_Ref"]);
|
|
|
|
|
data.TyrePos = Convert.ToString(reader["TyrePos"]);
|
|
|
|
|
data.TyrePos_Ref = Convert.ToString(reader["TyrePos_Ref"]);
|
|
|
|
|
data.RealMil = Convert.ToDecimal(reader["RealMil"]);
|
|
|
|
|
data.ScrapDate = Convert.ToString(reader["ScrapDate"]);
|
|
|
|
|
data.ScrapReason = Convert.ToString(reader["ScrapReason"]);
|
|
|
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
|
|
|
#endregion
|
|
|
|
|
headList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
return headList;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
|
|
|
|
|
|
internal static List<MsWlTyreScrapRefMsTruckOrg> GetOrgCodeList()
|
|
|
|
|
{
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" OrgCode,CodeAndName,OrgCode + '-' + CodeAndName as CodeAndName");
|
|
|
|
|
strSql.Append(" from vMsTruckOrg");
|
|
|
|
|
|
|
|
|
|
var dataList = new List<MsWlTyreScrapRefMsTruckOrg>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
var data = new MsWlTyreScrapRefMsTruckOrg();
|
|
|
|
|
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
|
|
|
|
|
data.OrgCode = Convert.ToString(reader["OrgCode"]);
|
|
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
dataList.Add(data);
|
|
|
|
|
}
|
|
|
|
|
reader.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dataList;
|
|
|
|
|
}
|
|
|
|
|
internal static List<MsWlTyreScrapRefMsWlTruck> GetTruckNoList(string userid, string usercode, string orgcode)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var rangstr = GetRangDAStr("", userid, usercode, orgcode);
|
|
|
|
|
|
|
|
|
|
var strSql = new StringBuilder();
|
|
|
|
|
strSql.Append("SELECT ");
|
|
|
|
|
strSql.Append(" TruckNo,TruckSpec,TruckNo + '-' + TruckSpec as CodeAndName");
|
|
|
|
|
strSql.Append(" from tMsWlTruck");
|
|
|
|
|
if (!string.IsNullOrEmpty(rangstr))
|
|
|
|
|
{
|
|
|
|
|
strSql.Append(" where " + rangstr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dataList = new List<MsWlTyreScrapRefMsWlTruck>();
|
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
|
|
|
{
|
|
|
|
|
while (reader.Read())
|
|
|
|
|
{
|
|
|
|
|
var data = new MsWlTyreScrapRefMsWlTruck();
|
|
|
|
|
|
|
|
|
|
#region Set DB data to Object
|
|
|
|
|
|
|
|
|
|
data.TruckNo = Convert.ToString(reader["TruckNo"]);
|
|
|
|
|
data.TruckSpec = Convert.ToString(reader["TruckSpec"]);
|
|
|
|
|
data.CodeAndName = Convert.ToString(reader["CodeAndName"]);
|
|
|
|
|
|
|
|
|
|
#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]='modTruckPj' 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
|
|
|
|
|
}
|
|
|
|
|
}
|