| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Data;
- using CoreFS.CA06;
- using DbHelp = Core.StlMes.Client.Sale.DbHelp;
- namespace Core.StlMes.Client.Sale.SaleFundMgt.FundDAL.FundPactAccountDAL
- {
-
- public class FundPactAccountDAL:BaseDAL.BaseDAL
- {
- public FundPactAccountDAL(OpeBase ob)
- : base(ob)
- {
- }
- private string SQL_STR_QUERY = @" select balancesubject,
- buyercode,
- secondaccount,
- pactno,
- round(totalmoney,3) totalmoney,
- round( leavemoney,3) leavemoney,
- pact_begindate,
- isinvoince,
- importor,
- importtime,
- updatetime
- from sel_fund_pact_account where 1 = 1 {0}";
- private string SQL_STR_INSERT = @" insert into sel_fund_pact_account ( balancesubject,
- buyercode,
- secondaccount,
- pactno,
- totalmoney,
- leavemoney,
- pact_begindate,
- isinvoince,
- importor,
- importtime,
- updatetime )
- values('{0}','{1}','{2}','{3}',{4},{5},'{6}','{7}','{8}',sysdate,
- sysdate)";
- private string SQL_STR_UPDATETOTALMONEY = @" update sel_fund_pact_account set totalmoney = totalmoney + {0} ,
- leavemoney = leavemoney + {0} , updatetime = sysdate
- where balancesubject = '{1}' and buyercode = '{2}' and secondaccount = '{3}' and pactno = '{4}' ";
- private string SQL_STR_UPDATELEAVEMONEY = @" update sel_fund_pact_account set
- leavemoney = leavemoney + {0} , updatetime =sysdate
- where balancesubject = '{1}' and buyercode = '{2}' and secondaccount = '{3}' and pactno = '{4}' ";
- private string SQL_STR_DELETE = @" delete from sel_fund_pact_account where 1 = 1 and balancesubject = '{0}' and buyercode = '{1}' and secondaccount = '{2}' and pactno = '{3}' ";
-
- /// <summary>
- /// 返回数据集
- /// </summary>
- /// <param name="sqlConditon"></param>
- /// <returns></returns>
- public DataSet GetSelFundPactAccount(string sqlConditon)
- {
- string sqlStr = string.Format(SQL_STR_QUERY, sqlConditon);
- return base.ExecuteReaderForSaleFund(sqlStr);
- }
- public DataSet GetSelFundPactAccount(string sqlConditon,Boolean isSetCaption)
- {
- DataSet ds = GetSelFundPactAccount(sqlConditon);
- if (isSetCaption)
- {
- base.SetDataSetCaption(ref ds,base.GetColumnNameAndCaption());
- }
- return ds;
- }
- /// <summary>
- /// 通过结算单位,客户名称,secondaccount 查找所有合同账户信息
- /// </summary>
- /// <param name="pact"></param>
- /// <returns></returns>
- public DataSet GetSelFundPactAccountByBalAndBuyercodeAndSecAccount(Model.SEL_FUND_PACT_ACCOUNT pact)
- {
- return GetSelFundPactAccount(base.GetSqlConditon(pact.BALANCESUBJECT,pact.BUYERCODE,pact.SECONDACCOUNT));
- }
- /// <summary>
- /// 通过结算单位,客户名称,secondaccount 查找所有合同账户信息
- /// </summary>
- /// <param name="balancesubject"></param>
- /// <param name="buyercode"></param>
- /// <param name="secondaccount"></param>
- /// <returns></returns>
- public DataSet GetSelFundPactAccountByBalAndBuyercodeAndSecAccount(string balancesubject,string buyercode,string secondaccount)
- {
- return GetSelFundPactAccount(base.GetSqlConditon(balancesubject, buyercode, secondaccount));
- }
- /// <summary>
- /// 通过结算单位,客户名称,secondaccount 查找所有合同账户信息
- /// </summary>
- /// <param name="bal"></param>
- /// <param name="buyercode"></param>
- /// <param name="secondaccount"></param>
- /// <returns></returns>
- public List<Model.SEL_FUND_PACT_ACCOUNT> GetSelFundPactAccountByBalanceAndSecAccount(string bal, string buyercode, string secondaccount)
- {
- return Model.SEL_FUND_PACT_ACCOUNT.GetSelFundPactAccountList(GetSelFundPactAccountByBalAndBuyercodeAndSecAccount(bal, buyercode, secondaccount));
- }
- public DataSet GetSelFundPactAccountByBalAndBuyercodeAndSecAccount(Model.SEL_FUND_PACT_ACCOUNT pact,Boolean isSetCaption)
- {
- return GetSelFundPactAccount(base.GetSqlConditon(pact.BALANCESUBJECT, pact.BUYERCODE, pact.SECONDACCOUNT), isSetCaption);
- }
- /// <summary>
- /// 通过结算单位,客户名称,secondaccount 查找所有合同账户信息,以实体返回
- /// </summary>
- /// <param name="pact"></param>
- /// <returns></returns>
- public List<Model.SEL_FUND_PACT_ACCOUNT> GetSelFundPactAccountModelListByBalAndBuyercodeAndSecAccount(Model.SEL_FUND_PACT_ACCOUNT pact)
- {
- return Model.SEL_FUND_PACT_ACCOUNT.GetSelFundPactAccountList(GetSelFundPactAccountByBalAndBuyercodeAndSecAccount(pact));
- }
- /// <summary>
- /// 通过结算单位,客户名称,secondaccount,合同号 查找所有合同账户信息
- /// </summary>
- /// <param name="pact"></param>
- /// <returns></returns>
- public DataSet GetSelFundPactAccountByBalanceAndBuyerCodeAndSecAndPactno(Model.SEL_FUND_PACT_ACCOUNT pact)
- {
- return GetSelFundPactAccount(base.GetSqlConditon(pact.BALANCESUBJECT, pact.BUYERCODE, pact.SECONDACCOUNT, pact.PACTNO));
- }
- /// <summary>
- /// 通过结算单位,客户名称,secondaccount,合同号 查找所有合同账户信息
- /// </summary>
- /// <param name="pact"></param>
- /// <returns></returns>
- public List<Model.SEL_FUND_PACT_ACCOUNT> GetSelFundPactAccountModelList(Model.SEL_FUND_PACT_ACCOUNT pact)
- {
- DataSet ds = GetSelFundPactAccountByBalanceAndBuyerCodeAndSecAndPactno(pact);
- if (ds == null)
- return null;
- if (ds.Tables.Count == 0)
- return null;
- if (ds.Tables[0].Rows.Count == 0)
- return null;
- return Model.SEL_FUND_PACT_ACCOUNT.GetSelFundPactAccountList(ds);
- }
- /// <summary>
- /// 通过结算单位,客户名称,secondaccount,合同号 查找所有合同账户信息
- /// </summary>
- /// <param name="pact"></param>
- /// <returns></returns>
- public Model.SEL_FUND_PACT_ACCOUNT GetSelFundPactAccountModel(Model.SEL_FUND_PACT_ACCOUNT pact)
- {
- List<Model.SEL_FUND_PACT_ACCOUNT> list = GetSelFundPactAccountModelList(pact);
- if (list == null)
- return null;
- if (list.Count == 0)
- return null;
- return list[0];
-
- }
- /// <summary>
- /// 通过结算单位和客户名称查找一合同号是否存在
- /// </summary>
- /// <param name="bal"></param>
- /// <param name="pactno"></param>
- /// <returns></returns>
- public List<Model.SEL_FUND_PACT_ACCOUNT> GetSelFundPactAccountByBalanceAndPactno(string bal,string buyercode,string pactno)
- {
- return Model.SEL_FUND_PACT_ACCOUNT.GetSelFundPactAccountList(GetSelFundPactAccount(base.GetSqlConditon(bal, buyercode,pactno,"","","")));
-
- }
- public List<Model.SEL_FUND_PACT_ACCOUNT> GetSelFundPactAccountByBalanceAndPactno(string bal, string buyercode, string pactno,out string errMsg)
- {
- errMsg = "";
- return Model.SEL_FUND_PACT_ACCOUNT.GetSelFundPactAccountList(GetSelFundPactAccount(base.GetSqlConditon(bal, buyercode, pactno, "", "", "")));
- }
-
- /// <summary>
- /// 通过结算单位,客户名称,合同号返回合同账户信息
- /// // 原则上同客户单位下只有一个合同账户
- /// </summary>
- /// <param name="bal"></param>
- /// <param name="buyercode"></param>
- /// <param name="pactno"></param>
- /// <returns></returns>
- public Model.SEL_FUND_PACT_ACCOUNT GetSelFundPactAccountByBalanceAndBuyerCodeAndPactno(string bal, string buyercode, string pactno)
- {
- List<Model.SEL_FUND_PACT_ACCOUNT> list = GetSelFundPactAccountByBalanceAndPactno(bal,buyercode,pactno);
- if (list == null)
- return null;
- if (list.Count == 0)
- return null;
- return list[0];
- }
-
- /// <summary>
- /// 通过结算单位,客户名称,secondaccount,合同号 ,获取该合同账户剩余资金
- /// </summary>
- /// <param name="pact"></param>
- /// <returns></returns>
- public double GetSelFundPactAccountLeaveMoney(Model.SEL_FUND_PACT_ACCOUNT pact)
- {
- Model.SEL_FUND_PACT_ACCOUNT fund = GetSelFundPactAccountModel(pact);
- if (fund == null)
- return 0;
- return fund.LEAVEMONEY;
- }
- /// <summary>
- /// 通过结算单位和合同号获取其整个合同账户信息
- /// 同结算单位的情况时只有一个合同号的
- /// </summary>
- /// <param name="balanceSubject"></param>
- /// <param name="pactno"></param>
- /// <returns></returns>
- public DataSet GetSelFundPactAccountByBalanceSubAndPactno(string balanceSubject,string pactno)
- {
- return GetSelFundPactAccount(this.GetSqlConditon(balanceSubject,pactno));
- }
- /// <summary>
- /// 通过结算单位和合同返回其账户信息
- /// </summary>
- /// <param name="balanceSubject"></param>
- /// <param name="pactno"></param>
- /// <returns></returns>
- public List<Model.SEL_FUND_PACT_ACCOUNT> GetSelFundPactAccountByBalanceSubAndPactnoByModel(string balanceSubject, string pactno)
- {
- DataSet ds = GetSelFundPactAccountByBalanceSubAndPactno(balanceSubject,pactno);
- if (ds == null)
- return null;
- if (ds.Tables.Count == 0)
- return null;
- if (ds.Tables[0].Rows.Count == 0)
- return null;
- return Model.SEL_FUND_PACT_ACCOUNT.GetSelFundPactAccountList(ds);
- }
- /// <summary>
- /// 新增合同账户信息
- /// </summary>
- /// <param name="acct"></param>
- /// <param name="err"></param>
- public void CreateFundPactAccount(Model.SEL_FUND_PACT_ACCOUNT acct,out string err)
- {
- err = "";
- if (!Model.SEL_FUND_PACT_ACCOUNT.IsReasonable(acct, out err))
- return;
- string sqlStr = string.Format(SQL_STR_INSERT,
- acct.BALANCESUBJECT,acct.BUYERCODE,acct.SECONDACCOUNT,
- acct.PACTNO,acct.TOTALMONEY,acct.LEAVEMONEY,acct.PACT_BEGINDATE,
- acct.ISINVOINCE,acct.IMPORTOR);
- base.ExecuteNoReaderForSaleFund(sqlStr,out err);
- }
- /// <summary>
- /// 新增合同账户信息,带事务
- /// </summary>
- /// <param name="acct"></param>
- /// <param name="transaction"></param>
- public void CreateFundPactAccount(Model.SEL_FUND_PACT_ACCOUNT acct, DbHelp.DbTransaction transaction)
- {
- string err = "";
- if (!Model.SEL_FUND_PACT_ACCOUNT.IsReasonable(acct, out err))
- return;
- string sqlStr = string.Format(SQL_STR_INSERT,
- acct.BALANCESUBJECT, acct.BUYERCODE, acct.SECONDACCOUNT,
- acct.PACTNO, acct.TOTALMONEY, acct.LEAVEMONEY, acct.PACT_BEGINDATE,
- acct.ISINVOINCE, acct.IMPORTOR);
- base.ExecuteNoReaderForSaleFund(sqlStr, transaction);
- }
- public string Sql_CreateFundPactAccount(Model.SEL_FUND_PACT_ACCOUNT acct)
- {
- string err = "";
- if (!Model.SEL_FUND_PACT_ACCOUNT.IsReasonable(acct, out err))
- return " 1 1";
- string sqlStr = string.Format(SQL_STR_INSERT,
- acct.BALANCESUBJECT, acct.BUYERCODE, acct.SECONDACCOUNT,
- acct.PACTNO, acct.TOTALMONEY, acct.LEAVEMONEY, acct.PACT_BEGINDATE,
- acct.ISINVOINCE, acct.IMPORTOR);
- return sqlStr;
- }
- /// <summary>
- /// 删除合同账户,带结算单位,客户单位,二级单位,合同单位
- /// </summary>
- /// <param name="acct"></param>
- /// <param name="errMsg"></param>
- public void DeleteFundPactAccount(Model.SEL_FUND_PACT_ACCOUNT acct, out string errMsg)
- {
- errMsg = "";
- string sqlstr = string.Format(this.SQL_STR_DELETE,acct.BALANCESUBJECT,acct.BUYERCODE,
- acct.SECONDACCOUNT,acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlstr,out errMsg);
- }
- /// <summary>
- /// 更新合同账户总资金和剩余资金
- /// 主要在从二级账户转资金到合同账户,资金增加
- /// or 从合同账户转钱到上级账户,资金减少
- /// </summary>
- /// <param name="acct"></param>
- public void AddFundPactAccountTotalMoneyAndLeavemoney(Model.SEL_FUND_TRANS_INFO acct,out string err )
- {
- err = "";
- // 参数检查
- if (!Model.SEL_FUND_TRANS_INFO.IsReasonable(acct, out err))
- {
- return;
- }
- string sqlStr = string.Format(SQL_STR_UPDATETOTALMONEY, acct.TRANS_MONEY, acct.BALANCESUBJECT,
- acct.BUYERCODE,acct.SECONDACCOUNT,acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlStr,out err);
- }
- public void AddFundPactAccountTotalMoneyAndLeavemoney(Model.SEL_FUND_TRANS_INFO acct, DbHelp.DbTransaction transaction)
- {
- string err = "";
- // 参数检查
- if (!Model.SEL_FUND_TRANS_INFO.IsReasonable(acct, out err))
- {
- transaction.ErrMsg = err;
- return;
- }
- string sqlStr = string.Format(SQL_STR_UPDATETOTALMONEY, acct.TRANS_MONEY, acct.BALANCESUBJECT,
- acct.BUYERCODE, acct.SECONDACCOUNT, acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlStr, transaction);
- }
- public void AddFundPactAccountTotalMoneyAndLeavemoney(Model.SEL_FUND_TRANS_PACT acct, DbHelp.DbTransaction transaction)
- {
- try
- {
- string err = "";
- if (acct == null)
- {
- transaction.ErrMsg = "Error";
- return;
- }
- // 参数检查
- if (acct.TRANS_MONEY == 0)
- return;
-
- string sqlStr = string.Format(SQL_STR_UPDATETOTALMONEY, acct.TRANS_MONEY, acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BALANCESUBJECT,
- acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BUYERCODE, acct.FUND_TRANS_SECONDACCOUNT.SECONDACCOUNT, acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlStr, transaction);
- }
- catch(Exception ex)
- {
- transaction.ErrMsg = ex.Message;
- }
- }
- public string Sql_AddFundPactAccountTotalMoneyAndLeavemoney(Model.SEL_FUND_TRANS_PACT acct)
- {
-
- string sqlStr = string.Format(SQL_STR_UPDATETOTALMONEY, acct.TRANS_MONEY, acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BALANCESUBJECT,
- acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BUYERCODE, acct.FUND_TRANS_SECONDACCOUNT.SECONDACCOUNT, acct.PACTNO);
- return sqlStr;
-
- }
- public void AddFundPactAccountTotalMoneyAndLeavemoney(Model.SEL_FUND_TRANS_PACT acct, out string errMsg)
- {
- try
- {
- errMsg = "";
- if (acct == null)
- {
- errMsg = "Error";
- return;
- }
- // 参数检查
- if (acct.TRANS_MONEY == 0)
- return;
- string sqlStr = string.Format(SQL_STR_UPDATETOTALMONEY, acct.TRANS_MONEY, acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BALANCESUBJECT,
- acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BUYERCODE, acct.FUND_TRANS_SECONDACCOUNT.SECONDACCOUNT, acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlStr, out errMsg);
- }
- catch (Exception ex)
- {
- errMsg = ex.Message;
- }
- }
- /// <summary>
- /// 更新剩余资金,总资金部变,剩余资金变化,主要在下车使用等
- /// </summary>
- /// <param name="acct"></param>
- /// <param name="err"></param>
- public void AddFundPactAccountLeaveMoney(Model.SEL_FUND_TRANS_INFO acct, out string err)
- {
- err = "";
- // 参数检查
- if (!Model.SEL_FUND_TRANS_INFO.IsReasonable(acct, out err))
- {
- return;
- }
- string sqlStr = string.Format(SQL_STR_UPDATELEAVEMONEY, acct.TRANS_MONEY, acct.BALANCESUBJECT,
- acct.BUYERCODE, acct.SECONDACCOUNT, acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlStr, out err);
- }
- public void AddFundPactAccountLeaveMoney(Model.SEL_FUND_TRANS_PACT acct, out string err)
- {
- err = "";
- // 参数检查
-
- string sqlStr = string.Format(SQL_STR_UPDATELEAVEMONEY, acct.TRANS_MONEY, acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BALANCESUBJECT,
- acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BUYERCODE, acct.FUND_TRANS_SECONDACCOUNT.SECONDACCOUNT, acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlStr, out err);
- }
- public void AddFundPactAccountLeaveMoney(Model.SEL_FUND_TRANS_PACT acct, DbHelp.DbTransaction transaction)
- {
-
- string sqlStr = string.Format(SQL_STR_UPDATELEAVEMONEY, acct.TRANS_MONEY, acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BALANCESUBJECT,
- acct.FUND_TRANS_SECONDACCOUNT.FUND_TRANS_CUST.BUYERCODE, acct.FUND_TRANS_SECONDACCOUNT.SECONDACCOUNT, acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlStr, transaction);
- }
- /// <summary>
- /// 更新剩余资金,总资金部变,剩余资金变化,主要在下车使用等,带事务
- /// </summary>
- /// <param name="acct"></param>
- /// <param name="transaction"></param>
- public void AddFundPactAccountLeaveMoney(Model.SEL_FUND_TRANS_INFO acct, DbHelp.DbTransaction transaction)
- {
- string err = "";
- // 参数检查
- if (!Model.SEL_FUND_TRANS_INFO.IsReasonable(acct, out err))
- {
- transaction.ErrMsg = err;
- return;
- }
- string sqlStr = string.Format(SQL_STR_UPDATELEAVEMONEY, acct.TRANS_MONEY, acct.BALANCESUBJECT,
- acct.BUYERCODE, acct.SECONDACCOUNT, acct.PACTNO);
- base.ExecuteNoReaderForSaleFund(sqlStr, transaction);
- }
- }
- }
|