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.
219 lines
8.1 KiB
C#
219 lines
8.1 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.Areas.TruckMng.Models;
|
|
using DSWeb.Areas.TruckMng.Models.MsWlTyreAcc;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
|
|
|
|
namespace DSWeb.Areas.TruckMng.DAL.MsWlTyreAcc
|
|
{
|
|
public partial class MsWlTyreAccDAL
|
|
{
|
|
#region Inquery DataList
|
|
|
|
static public List<Models.MsWlTyreAcc.MsWlTyreAcc> GetDataList(string strCondition, string userid, string usercode, string orgcode, string sort = null)
|
|
{
|
|
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,TruckNo,");
|
|
strSql.Append("(select TruckSpec from tMsWlTruck where TruckNo=tMsWlTyreAcc.TruckNo) as TruckNo_Ref");
|
|
strSql.Append(",PluCode,");
|
|
strSql.Append("(select PluName from tMsTruckPlu where PluCode=tMsWlTyreAcc.PluCode) as PluCode_Ref");
|
|
strSql.Append(",Spec,TyreType,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99013 and EnumValueID=tMsWlTyreAcc.TyreType) as TyreType_Ref");
|
|
strSql.Append(",TyrePos,");
|
|
strSql.Append("(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=99015 and EnumValueID=tMsWlTyreAcc.TyrePos) as TyrePos_Ref");
|
|
strSql.Append(",PcNo,PlanMil,UseDate,RoofDate,RealMil,ScrapDate,ScrapMil");
|
|
strSql.Append(",YkMil,OrgCode,Remark");
|
|
strSql.Append(" from tMsWlTyreAcc ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
var sortstring = DatasetSort.Getsortstring(sort);
|
|
if (!string.IsNullOrEmpty(sortstring))
|
|
{
|
|
strSql.Append(" order by " + sortstring);
|
|
}
|
|
else {
|
|
strSql.Append(" order by SerialNo");
|
|
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public Models.MsWlTyreAcc.MsWlTyreAcc 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.MsWlTyreAcc.MsWlTyreAcc();
|
|
}
|
|
|
|
|
|
private static List<Models.MsWlTyreAcc.MsWlTyreAcc> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<Models.MsWlTyreAcc.MsWlTyreAcc>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
Models.MsWlTyreAcc.MsWlTyreAcc data = new Models.MsWlTyreAcc.MsWlTyreAcc();
|
|
#region Set DB data to Object
|
|
data.SerialNo = Convert.ToDecimal(reader["SerialNo"]);
|
|
data.TruckNo = Convert.ToString(reader["TruckNo"]);
|
|
data.TruckNo_Ref = Convert.ToString(reader["TruckNo_Ref"]);
|
|
data.PluCode = Convert.ToString(reader["PluCode"]);
|
|
data.PluCode_Ref = Convert.ToString(reader["PluCode_Ref"]);
|
|
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.PcNo = Convert.ToString(reader["PcNo"]);
|
|
data.PlanMil = Convert.ToDecimal(reader["PlanMil"]);
|
|
data.UseDate = Convert.ToString(reader["UseDate"]);
|
|
data.RoofDate = Convert.ToString(reader["RoofDate"]);
|
|
data.RealMil = Convert.ToDecimal(reader["RealMil"]);
|
|
data.ScrapDate = Convert.ToString(reader["ScrapDate"]);
|
|
data.ScrapMil = Convert.ToDecimal(reader["ScrapMil"]);
|
|
data.YkMil = Convert.ToDecimal(reader["YkMil"]);
|
|
data.OrgCode = Convert.ToString(reader["OrgCode"]);
|
|
data.Remark = Convert.ToString(reader["Remark"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
internal static List<MsWlTyreAccRefMsWlTruck> 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<MsWlTyreAccRefMsWlTruck>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var data = new MsWlTyreAccRefMsWlTruck();
|
|
|
|
#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")
|
|
{
|
|
str = " UPPER(OrgCode)='" + orgcode + "'";
|
|
}
|
|
else
|
|
{
|
|
str = " UPPER(OrgCode)='" + orgcode + "'";
|
|
}
|
|
|
|
}
|
|
else if (visiblerange == "1")
|
|
{
|
|
str = " UPPER(OrgCode)='" + orgcode + "'";
|
|
}
|
|
|
|
return str;
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|