| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- 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.FundBLL.FundSecondLevelAccount
- {
- public class FundSecondlevelAccountMgt:FundBaseBLL.FundBaseBLL
- {
- private OpeBase _ob;
- public FundSecondlevelAccountMgt(OpeBase ob)
- : base(ob)
- {
- _ob = ob;
- }
- public DataSet GetSecondLevelAccountByBalanceAndBuyercode(string balanceSubject,string buyercode)
- {
- return this.GetSecondLevelAccountInstance().GetSelFundSecondLevelAccountInfoByBalanceSubjectAndBuyerCode(balanceSubject, buyercode, true);
- }
- private FundDAL.FundSecondLevelAccountDAL.FundSecondlevelAccountDAL GetSecondLevelAccountInstance()
- {
- return new FundDAL.FundSecondLevelAccountDAL.FundSecondlevelAccountDAL(this._ob);
- }
- private FundDAL.FundSecondLevelAccountDAL.FundSecondUsedDetailDAL GetSecondLevelDetailInstance()
- {
- return new FundDAL.FundSecondLevelAccountDAL.FundSecondUsedDetailDAL(this._ob);
- }
- /// <summary>
- /// 通过结算单位,客户单位,二级单位返回二级账户资金转移信息
- /// </summary>
- /// <param name="balancesubject"></param>
- /// <param name="buyercode"></param>
- /// <param name="secondacct"></param>
- /// <returns></returns>
- public DataSet GetSelFundSecondUsedDetailByBalanceSubjectAndBuyercodeAndSecondName(string balancesubject, string buyercode, string secondacct)
- {
- return GetSecondLevelDetailInstance().GetSelFundSecondUsedDetailBybalAndBuyercodeAndsecondName(balancesubject,buyercode,secondacct);
- }
- /// <summary>
- /// 获取所有二级账户,并组合成数组返回
- /// </summary>
- /// <returns></returns>
- public string[] GetAllSecondLevelAccount()
- {
- List<string> list = new List<string>();
- DataSet ds = this.GetSecondLevelAccountInstance().GetSelFundSecondlevelAccountInfo("");
- if (Util.DataSetUtil.Count(ds) == 0)
- return null;
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- if (!list.Contains(dr[_columnNameSecAct].ToString()))
- {
- list.Add(dr[_columnNameSecAct].ToString());
- }
-
- }
- return list.ToArray();
-
- }
- /// <summary>
- /// 获取所有二级账户信息,list返回
- /// </summary>
- /// <returns></returns>
- public List<string> GetAllSecondLevelAccountList()
- {
- List<string> list = new List<string>();
- DataSet ds = this.GetSecondLevelAccountInstance().GetSelFundSecondlevelAccountInfo("");
- if (Util.DataSetUtil.Count(ds) == 0)
- return null;
- foreach (DataRow dr in ds.Tables[0].Rows)
- {
- if (!list.Contains(dr[_columnNameSecAct].ToString()))
- {
- list.Add(dr[_columnNameSecAct].ToString());
- }
- }
- return list;
- }
- private string _columnNameSecAct = "SECONDACCOUNT";
- /// <summary>
- /// 创建二级账户
- /// </summary>
- /// <param name="act"></param>
- /// <param name="errMsg"></param>
- public void CreateSecondLevelAccount(Model.SEL_FUND_SECONDLEVEL_ACCOUNT act, out string errMsg)
- {
- errMsg = "";
- // 检查二级账户是否存在
- Model.SEL_FUND_SECONDLEVEL_ACCOUNT secacct =
- this.GetSecondLevelAccountInstance().GetSelFundSecondAccountBySecondAccount(act.BALANCESUBJECT,act.BUYERCODE,act.SECONDACCOUNT);
- if (secacct != null)
- {
- errMsg = "二级账户已经存在";
- return;
- }
- this.GetSecondLevelAccountInstance().CreateSecondLevelAccount(act,out errMsg);
- }
- /// <summary>
- /// 顺延创建二级账户和三级账户,有则不创建,没有则创建
- /// </summary>
- /// <param name="act"></param>
- /// <param name="errMsg"></param>
- public void CreateSecondLevelAccountAndPactAccount(Model.SEL_FUND_PACT_ACCOUNT act, out string errMsg)
- {
- errMsg = "";
- DbHelp.DbTransaction transaction = base.GetTransaction();
- try
- {
- transaction.BeginTransaction();
- // 检查二级账户是否存在
- Model.SEL_FUND_SECONDLEVEL_ACCOUNT secacct =
- this.GetSecondLevelAccountInstance().GetSelFundSecondAccountBySecondAccount(act.BALANCESUBJECT, act.BUYERCODE, act.SECONDACCOUNT);
- if (secacct == null)
- {
- // 不存在则创建
- Model.SEL_FUND_SECONDLEVEL_ACCOUNT acct =
- new Model.SEL_FUND_SECONDLEVEL_ACCOUNT
- (act.BALANCESUBJECT, act.BUYERCODE, act.SECONDACCOUNT, 0, 0, "System", Util.DateTimeUtil.GetSystemDate(), Util.DateTimeUtil.GetSystemDate());
- this.GetSecondLevelAccountInstance().CreateSecondLevelAccount(acct, transaction);
- }
- // 原则上同结算单位,同客户,一个合同号只能在一个二级账户,不能多个二级账户分布
- List<Model.SEL_FUND_PACT_ACCOUNT> acctmodel = this.GetFundPactAccountInstance().
- GetSelFundPactAccountByBalanceAndPactno(act.BALANCESUBJECT, act.BUYERCODE, act.PACTNO);
- if (acctmodel == null || acctmodel.Count == 0)
- {
- this.GetFundPactAccountInstance().CreateFundPactAccount(act, transaction);
- }
- // 提交
- transaction.Commit();
- }
- catch(Exception ex)
- {
- errMsg = ex.Message;
- transaction.RollBack();
- }
-
-
-
- }
- public void DeleteSecondLevelAccount(Model.SEL_FUND_SECONDLEVEL_ACCOUNT act, out string errMsg)
- {
- errMsg = "";
- if (!FundVariable.FundConstVariable.isDefaultAccountCanBeDelete && act.SECONDACCOUNT == FundVariable.FundConstVariable.defaultSecondLevelAccount)
- {
- errMsg = "默认账号,不允许删除";
- return;
- }
- Model.SEL_FUND_SECONDLEVEL_ACCOUNT le = null;
- le = this.GetSecondLevelAccountInstance().GetSelFundSecondAccountBySecondAccount(act.BALANCESUBJECT,act.BUYERCODE,act.SECONDACCOUNT);
- if (le != null)
- {
- if (le.LEAVEMONEY > 0)
- {
- errMsg = "有剩余资金,不允许删除";
- return;
- }
- }
- // 检查其是否有合同子账户
- FundBLL.FundPactAccount.FundPactAccountMgt pactaccountBLL =
- new FundBLL.FundPactAccount.FundPactAccountMgt (this._ob);
- List<Model.SEL_FUND_PACT_ACCOUNT> pactAccount = null;
- pactAccount = pactaccountBLL.GetFundPactAccountModelListByBalanceAndBuyercodeAndSecondAccount(act.BALANCESUBJECT,act.BUYERCODE,act.SECONDACCOUNT);
- if (pactAccount != null)
- {
- errMsg = "账户存在子账户";
- return;
- }
- this.GetSecondLevelAccountInstance().DeleteSecondLevelAccount(act,out errMsg);
- }
- }
- }
|