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.
150 lines
5.6 KiB
C#
150 lines
5.6 KiB
C#
using System;
|
|
using System.Data;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using DSWeb.Areas.TruckMng.Models.MsMlieage;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
|
|
namespace DSWeb.Areas.TruckMng.DAL.MsMlieage
|
|
{
|
|
public partial class MsMlieageDAL
|
|
{
|
|
#region Inquery DataList
|
|
|
|
static public List<Models.MsMlieage.MsMlieage> GetDataList(string strCondition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("SerialNo,TruckNo,");
|
|
strSql.Append("(select TruckSpec from tMsWlTruck where TruckNo=tMsMlieage.TruckNo) as TruckNo_Ref");
|
|
strSql.Append(",RptDate,TotalMil,HeavyMileage,EmptyMileage,TransVolume,AroundTon");
|
|
strSql.Append(" from tMsMlieage ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
return SetData(strSql);
|
|
}
|
|
|
|
static public List<Models.MsMlieage.MsMlieageSum> GetDataListSum(string strCondition)
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append("TruckNo, sum(TotalMil) as TotalMil, sum(HeavyMileage) as HeavyMileage");
|
|
strSql.Append(",sum(EmptyMileage) as EmptyMileage, sum(TransVolume) as TransVolume, sum(AroundTon) as AroundTon");
|
|
strSql.Append(" from tMsMlieage ");
|
|
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" where " + strCondition);
|
|
}
|
|
strSql.Append(" group by TruckNo ");
|
|
return SetDataSum(strSql);
|
|
}
|
|
|
|
static public Models.MsMlieage.MsMlieage GetData(string condition)
|
|
{
|
|
var list = GetDataList(condition);
|
|
if (list.Count > 0)
|
|
return list[0];
|
|
|
|
return new Models.MsMlieage.MsMlieage();
|
|
}
|
|
|
|
|
|
private static List<Models.MsMlieage.MsMlieage> SetData(StringBuilder strSql)
|
|
{
|
|
var headList = new List<Models.MsMlieage.MsMlieage>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
Models.MsMlieage.MsMlieage data = new Models.MsMlieage.MsMlieage();
|
|
#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.RptDate = Convert.ToString(reader["RptDate"]);
|
|
data.TotalMil = Convert.ToDecimal(reader["TotalMil"]);
|
|
data.HeavyMileage = Convert.ToDecimal(reader["HeavyMileage"]);
|
|
data.EmptyMileage = Convert.ToDecimal(reader["EmptyMileage"]);
|
|
data.TransVolume = Convert.ToDecimal(reader["TransVolume"]);
|
|
data.AroundTon = Convert.ToDecimal(reader["AroundTon"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
|
|
private static List<Models.MsMlieage.MsMlieageSum> SetDataSum(StringBuilder strSql)
|
|
{
|
|
var headList = new List<Models.MsMlieage.MsMlieageSum>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
Models.MsMlieage.MsMlieageSum data = new Models.MsMlieage.MsMlieageSum();
|
|
#region Set DB data to Object
|
|
data.TruckNo = Convert.ToString(reader["TruckNo"]);
|
|
data.TotalMil = Convert.ToDecimal(reader["TotalMil"]);
|
|
data.HeavyMileage = Convert.ToDecimal(reader["HeavyMileage"]);
|
|
data.EmptyMileage = Convert.ToDecimal(reader["EmptyMileage"]);
|
|
data.TransVolume = Convert.ToDecimal(reader["TransVolume"]);
|
|
data.AroundTon = Convert.ToDecimal(reader["AroundTon"]);
|
|
#endregion
|
|
headList.Add(data);
|
|
}
|
|
reader.Close();
|
|
}
|
|
return headList;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 参照部分
|
|
|
|
internal static List<MsMlieageRefMsWlTruck> GetTruckNoList()
|
|
{
|
|
var strSql = new StringBuilder();
|
|
strSql.Append("SELECT ");
|
|
strSql.Append(" TruckNo,TruckSpec,TruckNo + '-' + TruckSpec as CodeAndName");
|
|
strSql.Append(" from tMsWlTruck");
|
|
|
|
var dataList = new List<MsMlieageRefMsWlTruck>();
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
while (reader.Read())
|
|
{
|
|
var data = new MsMlieageRefMsWlTruck();
|
|
|
|
#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;
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
}
|