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/MvcShipping/DAL/MsCodeFeeSetList/MsCodeFeeSetListDAL.cs

276 lines
13 KiB
C#

2 years ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
using DSWeb.MvcShipping.Models.MsCodeFeeSetList;
namespace DSWeb.MvcShipping.DAL.MsCodeFeeSetList
{
public class MsCodeFeeSetListDAL
{
static public List<CodeFeeSetList> GetDataList (string strCondition,int start,int limit,string sort = null )
{
var strSql = new StringBuilder();
strSql.Append(@"SELECT * from (SELECT row_number() over (");
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by A.CREATETIME DESC,A.GID");
}
strSql.Append(@") as num , ");
strSql.Append(@"A.GID,
A.FEECODE,
A.NAME,
A.DEFAULTCURR,
A.DESCRIPTION,
ISSEA,
ISAIR,
ISTRUCKING,
ISTRUCKINGFIXED,
ISWMS,
ISADVANCEDPAY,
DEFAULTUNIT,ISNULL((case A.DEFAULTUNIT
when 1 then '' when 2 then ''
when 3 then '' when 4 then ''
when 5 then 'TEU' when 6 then ''
when 7 then '' when 8 then ''
when 9 then '' when 10 then 'CBM'
when 11 then 'BILL' end),'') DEFAULTUNITREF,
DEFAULTDEBIT,ISNULL((case A.DEFAULTDEBIT
when 1 then '' when 2 then ''
when 3 then '' when 4 then ''
when 5 then '' when 6 then ''
when 7 then '' when 8 then ''
when 9 then '' when 10 then ''
when 11 then '' when 0 then '' end),'') DEFAULTDEBITREF,
DEFAULTCREDIT,ISNULL((case A.DEFAULTCREDIT
when 1 then '' when 2 then ''
when 3 then '' when 4 then ''
when 5 then '' when 6 then ''
when 7 then '' when 8 then ''
when 9 then '' when 10 then ''
when 11 then '' when 12 then ''
when 13 then '' when 0 then '' end),'') DEFAULTCREDITREF,A.CREATEUSER,
B.SHOWNAME as CREATEUSERREF,
A.CREATETIME ,
2 years ago
A.FEEGROUP,A.FEEFRT,A.TAXRATE,A.DUITYPE,A.GOODNAME,A.ISNOTPR,A.ISINVOICE,A.CUSTOMERNAME ");
2 years ago
strSql.Append(@"FROM code_fee as A
INNER JOIN [user] as B
ON A.CREATEUSER = B.GID ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where 1=1 and " + strCondition);
}
strSql.Append(@")as t ");
strSql.Append(string.Format("where t.num>={0} and t.num<={1} ",start,start+limit));
return SetData(strSql);
}
static public string GetDataListStr(string strCondition, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append(@"SELECT A.GID,
A.FEECODE,
A.NAME,
A.DEFAULTCURR,
A.DESCRIPTION,
ISSEA,
ISAIR,
ISTRUCKING,
ISTRUCKINGFIXED,
ISWMS,
ISADVANCEDPAY,
DEFAULTUNIT,ISNULL((case A.DEFAULTUNIT
when 1 then '' when 2 then ''
when 3 then '' when 4 then ''
when 5 then 'TEU' when 6 then ''
when 7 then '' when 8 then ''
when 9 then '' when 10 then 'CBM'
when 11 then 'BILL' end),'') DEFAULTUNITREF,
DEFAULTDEBIT,ISNULL((case A.DEFAULTDEBIT
when 1 then '' when 2 then ''
when 3 then '' when 4 then ''
when 5 then '' when 6 then ''
when 7 then '' when 8 then ''
when 9 then '' when 10 then ''
when 11 then '' when 0 then '' end),'') DEFAULTDEBITREF,
DEFAULTCREDIT,ISNULL((case A.DEFAULTCREDIT
when 1 then '' when 2 then ''
when 3 then '' when 4 then ''
when 5 then '' when 6 then ''
when 7 then '' when 8 then ''
when 9 then '' when 10 then ''
when 11 then '' when 12 then ''
when 13 then '' when 0 then '' end),'') DEFAULTCREDITREF,A.CREATEUSER,
B.SHOWNAME as CREATEUSERREF,
A.CREATETIME ,
2 years ago
A.FEEGROUP,A.FEEFRT,A.TAXRATE,A.DUITYPE,A.GOODNAME,A.ISNOTPR,A.ISINVOICE,A.CUSTOMERNAME ");
2 years ago
strSql.Append(@"FROM code_fee as A
INNER JOIN [user] as B
ON A.CREATEUSER = B.GID ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where 1=1 and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else
{
strSql.Append(" order by A.CREATETIME DESC,A.GID");
}
return strSql.ToString();
}
static public int getTotalCount ( string strCondition )
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select count(*) from code_fee as A inner join [user] as B on A.createuser=B.gid ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where 1=1 and " + strCondition);
}
int cnt=0;
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
cnt = Convert.ToInt32(reader[0]);
}
}
return cnt;
}
static public CodeFeeSetList GetData(string condition)
{
CodeFeeSetList data = null;
var list = GetDataList(condition,0,1);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new CodeFeeSetList();
}
return data;
}
private static List<CodeFeeSetList> SetData ( StringBuilder strSql )
{
var headList = new List<CodeFeeSetList>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
CodeFeeSetList data = new CodeFeeSetList();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.FEECODE = Convert.ToString(reader["FEECODE"]);
data.NAME = Convert.ToString(reader["NAME"]);
data.DESCRIPTION = Convert.ToString(reader["DESCRIPTION"]);
data.DEFAULTCURR = Convert.ToString(reader["DEFAULTCURR"]);
if (reader["ISSEA"] != DBNull.Value)
data.ISSEA = Convert.ToBoolean(reader["ISSEA"]);//状态
if (reader["ISAIR"] != DBNull.Value)
data.ISAIR = Convert.ToBoolean(reader["ISAIR"]);//状态
if (reader["ISTRUCKING"] != DBNull.Value)
data.ISTRUCKING = Convert.ToBoolean(reader["ISTRUCKING"]);//状态
if (reader["ISTRUCKINGFIXED"] != DBNull.Value)
data.ISTRUCKINGFIXED = Convert.ToBoolean(reader["ISTRUCKINGFIXED"]);//状态
if (reader["ISWMS"] != DBNull.Value)
data.ISWMS = Convert.ToBoolean(reader["ISWMS"]);//状态
if (reader["ISADVANCEDPAY"] != DBNull.Value)
data.ISADVANCEDPAY = Convert.ToBoolean(reader["ISADVANCEDPAY"]);//状态
2 years ago
if (reader["ISNOTPR"] != DBNull.Value)
data.ISNOTPR = Convert.ToBoolean(reader["ISNOTPR"]);//状态
2 years ago
if (reader["ISINVOICE"] != DBNull.Value)
data.ISINVOICE = Convert.ToBoolean(reader["ISINVOICE"]);//状态
2 years ago
data.DEFAULTUNIT = Convert.ToString(reader["DEFAULTUNIT"]);
data.DEFAULTDEBIT = Convert.ToString(reader["DEFAULTDEBIT"]);
data.DEFAULTCREDIT = Convert.ToString(reader["DEFAULTCREDIT"]);
data.DEFAULTUNITREF = Convert.ToString(reader["DEFAULTUNITREF"]);
data.DEFAULTDEBITREF = Convert.ToString(reader["DEFAULTDEBITREF"]);
data.DEFAULTCREDITREF = Convert.ToString(reader["DEFAULTCREDITREF"]);
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
data.FEEGROUP = Convert.ToString(reader["FEEGROUP"]);
data.FEEFRT = Convert.ToString(reader["FEEFRT"]);
data.TAXRATE = Convert.ToString(reader["TAXRATE"]);
data.DUITYPE = Convert.ToString(reader["DUITYPE"]);
2 years ago
data.GOODNAME = Convert.ToString(reader["GOODNAME"]);
2 years ago
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
2 years ago
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
public static bool GetFeeCount(string FEENAME)
{
var isfee = false;
var strSql = new StringBuilder();
strSql.Append("Select count(*) as count ");
strSql.Append(" from ch_fee ");
strSql.Append(" where FEENAME='" + FEENAME + "'");
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var evData = Convert.ToInt32(reader["count"]);
if (evData > 0) { isfee = true; };
}
reader.Close();
}
return isfee;
}
public static bool GetCodeFeeCount(string strCondition)
{
var isfee = false;
var strSql = new StringBuilder();
strSql.Append("Select count(*) as count ");
strSql.Append(" from code_fee ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where " + strCondition);
}
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
var evData = Convert.ToInt32(reader["count"]);
if (evData > 0) { isfee = true; };
}
reader.Close();
}
return isfee;
}
}
}