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.

172 lines
7.6 KiB
C#

10 months ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.Areas.Import.Models.CWAdvancePayment;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace DSWeb.Areas.Import.DAL.CW
{
public partial class CWAdvancePaymentDAL
{
#region GetDataList
static public List<CWAdvancePayment> GetDataList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append(" SELECT ap.gid,ap.linkgid,ap.billno,ap.CUSTOMERNAME,ap.currency,ap.amount,ap.doamount,ap.amount-ap.doamount REMAIN,ap.CREATEUSER, ");
strSql.Append(" dbo.trimdate(ap.CREATETIME) CREATETIME,ap.VOUCHERNO,ap.REMARK, ");
strSql.Append(" (select showname from [user] where gid=ap.createuser) CREATEUSERREF,ap.COMPANYID, ");
strSql.Append(" (select NAME from [company] where gid=ap.companyid) COMPANYREF, ");
strSql.Append(" ap.feetype,(select EnumValueName from tSysEnumValue where LangId=0 and EnumTypeID=21 and EnumValueID=ap.Feetype) FEETYPEREF, ");
strSql.Append(" case ISFINISH when 0 then '否' else '是' end ISFINISHREF ");
strSql.Append(" FROM ch_fee_advance_payment ap ");
strSql.Append(" where ap.isdelete=0 ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
strSql.Append(" union all ");
strSql.Append(" select 'zzzz','','zzzz','总计','',sum(amount),sum(doamount),sum(amount-doamount),'','','','','','','',0,'','' from ch_fee_advance_payment ap");
strSql.Append(" where ap.isdelete=0 ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
return SetData(strSql);
}
static public CWAdvancePayment GetData(string condition)
{
var list = GetDataList(condition);
if (list.Count > 0)
return list[0];
return new CWAdvancePayment();
}
private static List<CWAdvancePayment> SetData(StringBuilder strSql)
{
var headList = new List<CWAdvancePayment>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
CWAdvancePayment data = new CWAdvancePayment();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.LINKGID = Convert.ToString(reader["LINKGID"]);
data.BILLNO = Convert.ToString(reader["BILLNO"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
data.AMOUNT = Convert.ToString(reader["AMOUNT"]);
data.DOAMOUNT = Convert.ToString(reader["DOAMOUNT"]);
data.REMAIN = Convert.ToString(reader["REMAIN"]);
data.CREATEUSER = Convert.ToString(reader["CREATEUSER"]);
data.CREATETIME = Convert.ToString(reader["CREATETIME"]);
//data.SETTLEUSER = Convert.ToString(reader["SETTLEUSER"]);
//data.SETTLETIME = Convert.ToString(reader["SETTLETIME"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
//data.ISDELETE = Convert.ToString(reader["ISDELETE"]);
//data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]);
//data.DELETETIME = Convert.ToString(reader["DELETETIME"]);
//data.ISFINISH = Convert.ToString(reader["ISFINISH"]);
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
data.VOUCHERNO = Convert.ToString(reader["VOUCHERNO"]);
data.CREATEUSERREF = Convert.ToString(reader["CREATEUSERREF"]);
data.COMPANYREF = Convert.ToString(reader["COMPANYREF"]);
data.FEETYPE = Convert.ToString(reader["FEETYPE"]);
data.FEETYPEREF = Convert.ToString(reader["FEETYPEREF"]);
data.ISFINISHREF = Convert.ToString(reader["ISFINISHREF"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region GetBodyList
static public List<CWAdvancePaymentBody> GetBodyList(string strCondition)
{
var strSql = new StringBuilder();
strSql.Append(" SELECT apd.*, ");
strSql.Append(" (select showname from [user] where gid=apd.SETTLEUSER) SETTLEUSERREF, ");
strSql.Append(" (select NAME from [company] where gid=apd.companyid) COMPANYREF ");
strSql.Append(" FROM ch_fee_advance_payment_detail apd ");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" where BILLNO='" + strCondition+"'");
}
return SetBodyData(strSql);
}
static public CWAdvancePaymentBody GetBodyData(string condition)
{
var list = GetBodyList(condition);
if (list.Count > 0)
return list[0];
return new CWAdvancePaymentBody();
}
private static List<CWAdvancePaymentBody> SetBodyData(StringBuilder strSql)
{
var headList = new List<CWAdvancePaymentBody>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
CWAdvancePaymentBody data = new CWAdvancePaymentBody();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.LINKGID = Convert.ToString(reader["LINKGID"]);
data.BILLNO = Convert.ToString(reader["BILLNO"]);
data.SETTLELINKGID = Convert.ToString(reader["SETTLELINKGID"]);
data.SETTLEBILLNO = Convert.ToString(reader["SETTLEBILLNO"]);
data.FEETYPE = Convert.ToString(reader["FEETYPE"]);
data.CUSTOMERNAME = Convert.ToString(reader["CUSTOMERNAME"]);
data.CURRENCY = Convert.ToString(reader["CURRENCY"]);
data.DOAMOUNT = Convert.ToString(reader["DOAMOUNT"]);
data.SETTLEUSER = Convert.ToString(reader["SETTLEUSER"]);
data.SETTLETIME = Convert.ToString(reader["SETTLETIME"]);
data.REMARK = Convert.ToString(reader["REMARK"]);
data.ISDELETE = Convert.ToString(reader["ISDELETE"]);
data.DELETEUSER = Convert.ToString(reader["DELETEUSER"]);
data.DELETETIME = Convert.ToString(reader["DELETETIME"]);
data.COMPANYID = Convert.ToString(reader["COMPANYID"]);
data.VOUCHERNO = Convert.ToString(reader["VOUCHERNO"]);
data.SETTLEUSERREF = Convert.ToString(reader["SETTLEUSERREF"]);
data.COMPANYREF = Convert.ToString(reader["COMPANYREF"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
#endregion
}
}