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.

472 lines
14 KiB
C#

using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.MsPrice;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using System.Web.Mvc;//ContentResult
using DSWeb.TruckMng.Helper.Repository;//ModelObjectRepository
using DSWeb.MvcShipping.Helper;
using DSWeb.Areas.CommMng.DAL;//使用获取权限子句
using DSWeb.Areas.SysMng.DAL.SysTask;
namespace DSWeb.Areas.MvcShipping.DAL.MsPrice
{
public class MsPriceContractDAL
{
#region 运价合约 头表/明细表 查询
static public List<MsPrice_Contract_mb> GetDataList (int start,int limit, string strCondition,string USERID,out int count, string sort = "" )
{
var strSql = "";
MsPrice_Contract_mb qo = new MsPrice_Contract_mb();
strSql = qo.getSQL(start,limit, strCondition,USERID,out count, sort);
return SetData(strSql);
}
public static MsPrice_Contract_mb GetData(string condition, string USERID)
{
var _count = 0;
var dataList = GetDataList(0,1,condition, USERID, out _count);
var result = new MsPrice_Contract_mb();
if (dataList.Count > 0)
{
result = dataList[0];
}
else {
result.getDef(USERID);
}
return result;
}
public static string getHeadListStr(string condition)
{
MsPrice_Contract_mb qo = new MsPrice_Contract_mb();
var result = qo.getSQL_all(0, 999, condition);
return result;
}
public static string getBodyListStr(string condition)
{
string result = MsPrice_Contract_Detailmb.getSQL() ;
if (!string.IsNullOrWhiteSpace(condition)) {
result += condition;
}
return result;
}
private static List<MsPrice_Contract_mb> SetData(string strSql)
{
var headList = new List<MsPrice_Contract_mb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsPrice_Contract_mb data = new MsPrice_Contract_mb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public List<MsPrice_Contract_Detailmb> GetBodyList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by SEQUENCE ");
}
return SetBodyData(strSql);
}
private static List<MsPrice_Contract_Detailmb> SetBodyData(StringBuilder strSql)//, List<HcUtility.Core.Fieldmb> fieldlist
{
var headList = new List<MsPrice_Contract_Detailmb>();
Database db = DatabaseFactory.CreateDatabase();
string sql = getBodyListStr(strSql.ToString());
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsPrice_Contract_Detailmb data = new MsPrice_Contract_Detailmb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
#region 运输路径
public static string getWayListStr(string condition) {
string result = MsPrice_Contract_Waymb.getSQL();
if (!string.IsNullOrWhiteSpace(condition))
{
result += condition;
}
return result;
}
static public List<MsPrice_Contract_Waymb> GetWayList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by PODLOAD,PORTDISCHARGE,VIA ");
}
return SetWayData(strSql);
}
private static List<MsPrice_Contract_Waymb> SetWayData(StringBuilder strSql)//, List<HcUtility.Core.Fieldmb> fieldlist
{
var headList = new List<MsPrice_Contract_Waymb>();
Database db = DatabaseFactory.CreateDatabase();
string sql = getWayListStr(strSql.ToString());
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsPrice_Contract_Waymb data = new MsPrice_Contract_Waymb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 目的港免箱期
public static string getPortDetentionStr(string condition)
{
string result = MsPrice_Contract_PortDetentionmb.getSQL();
if (!string.IsNullOrWhiteSpace(condition))
{
result += condition;
}
return result;
}
static public List<MsPrice_Contract_PortDetentionmb> GetPortDetentionList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by ID ");
}
return SetPortDetentionData(strSql);
}
private static List<MsPrice_Contract_PortDetentionmb> SetPortDetentionData(StringBuilder strSql)//, List<HcUtility.Core.Fieldmb> fieldlist
{
var headList = new List<MsPrice_Contract_PortDetentionmb>();
Database db = DatabaseFactory.CreateDatabase();
string sql = getPortDetentionStr(strSql.ToString());
using (IDataReader reader = db.ExecuteReader(CommandType.Text, sql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsPrice_Contract_PortDetentionmb data = new MsPrice_Contract_PortDetentionmb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#endregion
}
public class MsQuotationDAL
{
#region 报价 头表/明细表 查询
static public List<MsQuotationmb> GetDataList(int start, int limit, string strCondition, string USERID, string sort = "")
{
var strSql = "";
MsQuotationmb qo = new MsQuotationmb();
strSql = qo.getSQL(start, limit, strCondition, USERID, sort);
return SetData(strSql);
}
static public List<MsQuotationmb> GetSmallDataList(int start, int limit, string strCondition,string mblno, string USERID, string sort = "")
{
var strSql = "";
MsQuotationmb qo = new MsQuotationmb();
strSql = qo.getSQL_Small(start, limit, strCondition,mblno, USERID, sort);
return SetData(strSql);
}
public static MsQuotationmb GetData(string condition, string USERID)
{
var _count = 0;
var dataList = GetDataList(0, 1, condition, USERID, "");
var result = new MsQuotationmb();
if (dataList.Count > 0)
{
result = dataList[0];
}
else
{
result.getDef(USERID);
}
return result;
}
public static string getHeadListStr(string condition)
{
MsQuotationmb qo = new MsQuotationmb();
var result = qo.getSQL_all(0, 9999, condition);
return result;
}
public static string getBodyListStr(string condition)
{
string result = MsQuotation_Detailmb.getSQL();
if (!string.IsNullOrWhiteSpace(condition))
{
result += condition;
}
return result;
}
/// <summary>
/// 20200812 分箱型产生报价查询语句
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public static string getBodyListStr_Fen( string condition, string[] ctntype)
{
string result = MsQuotation_Detailmb.getSQL(condition,ctntype);
return result;
}
private static List<MsQuotationmb> SetData(string strSql)
{
var headList = new List<MsQuotationmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsQuotationmb data = new MsQuotationmb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
static public List<MsQuotation_Detailmb> GetBodyList(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append(MsQuotation_Detailmb.getSQL());
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by PORTDISCHARGE,CTN02,CTN12,CTN22,CTN32,CTN42 ");
}
return SetBodyData(strSql);
}
private static List<MsQuotation_Detailmb> SetBodyData(StringBuilder strSql)//, List<HcUtility.Core.Fieldmb> fieldlist
{
var headList = new List<MsQuotation_Detailmb>();
Database db = DatabaseFactory.CreateDatabase();
//string sql = getBodyListStr(strSql.ToString());
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsQuotation_Detailmb data = new MsQuotation_Detailmb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static List<MsQuotation_ZaFeiListmb> GetZaFeiDataList(string condition) {
var strSql = "";
strSql = MsQuotation_ZaFeiListmb.getSQL(condition);
return SetZaFeiData(strSql);
}
private static List<MsQuotation_ZaFeiListmb> SetZaFeiData(string strSql)
{
var headList = new List<MsQuotation_ZaFeiListmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsQuotation_ZaFeiListmb data = new MsQuotation_ZaFeiListmb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 报价表子表 提单号关联表
public static List<MsQuotation_MblnoListmb> GetMblnoList(string strCondition) {
var strSql = "";
//MsQuotation_MblnoListmb qo = new MsQuotation_MblnoListmb();
strSql = MsQuotation_MblnoListmb.getSQL(strCondition);
return SetMblnoListData(strSql);
}
private static List<MsQuotation_MblnoListmb> SetMblnoListData(string strSql)
{
var headList = new List<MsQuotation_MblnoListmb>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql))
{
while (reader.Read())
{
////根据字段名设定同名属性值
MsQuotation_MblnoListmb data = new MsQuotation_MblnoListmb();
data.SetExtendValue(reader);
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
}
}