FundInAndOutMgt.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data;
  6. using CoreFS.CA06;
  7. using DbHelp = Core.StlMes.Client.Sale.DbHelp;
  8. namespace Core.StlMes.Client.Sale.SaleFundMgt.FundBLL.FundInAndOut
  9. {
  10. public class FundInAndOutMgt:FundBaseBLL.FundBaseBLL
  11. {
  12. private OpeBase _ob = null;
  13. public FundInAndOutMgt(OpeBase ob):base(ob)
  14. {
  15. _ob = ob;
  16. }
  17. /// <summary>
  18. /// 返回数据集
  19. /// </summary>
  20. /// <param name="sqlConditoin"></param>
  21. /// <returns></returns>
  22. public DataSet GetSelFundCustFundInOut(string sqlConditoin)
  23. {
  24. return this.GetFundInOutInstance().GetSelFundCustFundInOut(sqlConditoin,true);
  25. }
  26. /// <summary>
  27. /// 通过结算单位,客户单位返回其数据集
  28. /// </summary>
  29. /// <param name="balance"></param>
  30. /// <param name="buyercode"></param>
  31. /// <returns></returns>
  32. public DataSet GetSelFundCustFundInOutByBalanceAndBuyercode(string balance, string buyercode)
  33. {
  34. return base.GetFundInOutInstance().GetSelFundCustFundInOutByBalanceSubjectAndBuyerCode(balance, buyercode, true);
  35. }
  36. public DataSet GetSelFundCustFundInOutByBalanceAndBuyercodeAndTime(string balanceSubject, string buyerCode, string begintime, string endtime)
  37. {
  38. return this.GetFundInOutInstance().GetSelFundCustFundInOutByBalanceSubjectAndBuyerCodeAndInOutDate(balanceSubject, buyerCode, begintime, endtime);
  39. }
  40. public DataSet GetSelFundCustFundInOutByBalanceAndTime(string balanceSubject, string begintime, string endtime)
  41. {
  42. return this.GetFundInOutInstance().GetSelFundCustFundInOutByBalanceSubjectAndInOutDate(balanceSubject, begintime, endtime);
  43. }
  44. public List<Model.SEL_FUND_CUST_FUNDINOUT> GetGetSelFundCustFundInOutModelByBalanceSubjectAndBuyerCode(string balanceSubject, string buyerCode)
  45. {
  46. return this.GetFundInOutInstance().GetGetSelFundCustFundInOutModelByBalanceSubjectAndBuyerCode(balanceSubject, buyerCode);
  47. }
  48. /// <summary>
  49. /// 删除一条记录
  50. /// </summary>
  51. /// <param name="busiSeq"></param>
  52. public void DeleteFundInAndOutRecord(string busiSeq)
  53. {
  54. string err = "";
  55. this.GetFundInOutInstance().Update_SelFundCustFundinout(busiSeq, out err);
  56. }
  57. private Model.SEL_FUND_CUST_FUNDINOUT GetSelFundCustInout(string balancesubject, string buyercode, string fundtype, string billno, double money, string importor, string importtime, string inouttime,string remark,string orderno)
  58. {
  59. Model.SEL_FUND_CUST_FUNDINOUT inout = new Model.SEL_FUND_CUST_FUNDINOUT();
  60. inout.BALANCESUBJECT = balancesubject;
  61. inout.BUYERCODE = buyercode;
  62. inout.FUNDTYPE = fundtype;
  63. inout.BILLNO = billno;
  64. inout.INOUTMONEY = money;
  65. inout.IMPORTOR = importor;
  66. inout.IMPORTTIME = importtime;
  67. inout.INOUTTIME = inouttime;
  68. inout.REMARK = remark;
  69. inout.ORDERNO = orderno;
  70. return inout;
  71. }
  72. //private Model.SEL_FUND_CUST_FUNDINOUT GetSelFundCustInout(string balancesubject, string buyercode, string fundtype, string billno, double money, string importor, string importtime, string inouttime, string remark, string secondact)
  73. //{
  74. // Model.SEL_FUND_CUST_FUNDINOUT inout = new Model.SEL_FUND_CUST_FUNDINOUT();
  75. // inout.BALANCESUBJECT = balancesubject;
  76. // inout.BUYERCODE = buyercode;
  77. // inout.FUNDTYPE = fundtype;
  78. // inout.BILLNO = billno;
  79. // inout.INOUTMONEY = money;
  80. // inout.IMPORTOR = importor;
  81. // inout.IMPORTTIME = importtime;
  82. // inout.INOUTTIME = inouttime;
  83. // inout.REMARK = remark;
  84. // inout.SECONDACCOUNT = secondact;
  85. // return inout;
  86. //}
  87. /// <summary>
  88. /// 进账,出账资金则为负数,用同样的方法
  89. /// </summary>
  90. /// <param name="balancesubject">结算单位</param>
  91. /// <param name="buyercode">客户编码</param>
  92. /// <param name="fundtype">类型</param>
  93. /// <param name="billno">票号</param>
  94. /// <param name="money">金额</param>
  95. /// <param name="importor">录入人</param>
  96. /// <param name="importtime">操作时间</param>
  97. /// <param name="inouttime">进账时间</param>
  98. public void AddFundRecord(string balancesubject, string buyercode, string fundtype,
  99. string billno, double money, string importor, string importtime, string inouttime, string remark, string orderno, double leavemny, out string errMsg)
  100. {
  101. errMsg = "";
  102. Model.SEL_FUND_CUST_FUNDINOUT inout = null;
  103. inout = GetSelFundCustInout(balancesubject, buyercode, fundtype, billno, money, importor, importtime, inouttime, remark,orderno);
  104. Model.SEL_FUND_CUST_ACCOUNT acct = new Model.SEL_FUND_CUST_ACCOUNT();
  105. acct.BALANCESUBJECT = balancesubject;
  106. acct.BUYERCODE = buyercode;
  107. inout.IMPORTOR = importor;
  108. inout.LEAVEMONEY = leavemny;
  109. // 开启事务处理
  110. // 先更新总资金
  111. System.Collections.ArrayList sqlList = new System.Collections.ArrayList();
  112. sqlList.Add(base.GetFundCustAccountInstance().Sql_AddMoneyToCustAccount(acct,money));
  113. sqlList.Add(base.GetFundInOutInstance().Sql_Insert_SelFundCustFundinout(inout));
  114. base.ExecuteNoReader(sqlList, out errMsg);
  115. // 写明细
  116. // base.GetFundInOutInstance().Insert_SelFundCustFundinout(inout,transaction);
  117. // 提交
  118. }
  119. public void AddFundRecord(string balancesubject, string buyercode, string fundtype, string billno, double money, string importor, string importtime, string inouttime, string remark, string orderno, double leavemny, string seccount, out string errMsg)
  120. {
  121. errMsg = "";
  122. FundBLL.FundTransferMgt.FundTransferMgt FundTransferMgt = new FundBLL.FundTransferMgt.FundTransferMgt(_ob);
  123. Model.SEL_FUND_CUST_FUNDINOUT inout = null;
  124. inout = GetSelFundCustInout(balancesubject, buyercode, fundtype, billno, money, importor, importtime, inouttime, remark, orderno);
  125. Model.SEL_FUND_CUST_ACCOUNT acct = new Model.SEL_FUND_CUST_ACCOUNT();
  126. acct.BALANCESUBJECT = balancesubject;
  127. acct.BUYERCODE = buyercode;
  128. inout.IMPORTOR = importor;
  129. inout.LEAVEMONEY = leavemny;
  130. inout.SECONDACCOUNT = seccount;
  131. Model.SEL_FUND_TRANS_SECONDACCOUNT sceact = null;
  132. System.Collections.ArrayList lists = null;
  133. // if (money < 0)
  134. // {
  135. // sceact = GetTransSecAccount(balancesubject, buyercode, fundtype, billno, -money,
  136. // importor, importtime, inouttime, remark, seccount);
  137. // lists = FundTransferMgt.GetTransferMoneySecondAccountToCust(sceact, out errMsg);
  138. // }
  139. // else
  140. // {
  141. // sceact = GetTransSecAccount(balancesubject, buyercode, fundtype, billno, money,
  142. //importor, importtime, inouttime, remark, seccount);
  143. // lists = FundTransferMgt.GetTransferMoneyCustToSecondAccount(sceact, out errMsg);
  144. // }
  145. // 开启事务处理
  146. // 先更新总资金
  147. System.Collections.ArrayList sqlList = new System.Collections.ArrayList();
  148. // sqlList.Add(base.GetFundCustAccountInstance().Sql_AddMoneyToCustAccount(acct, money));
  149. sqlList.Add(base.GetFundInOutInstance().Sql_Insert_SelFundCustFundinout(inout));
  150. // sqlList.AddRange(lists);
  151. base.ExecuteNoReader(sqlList, out errMsg);
  152. // 写明细
  153. // base.GetFundInOutInstance().Insert_SelFundCustFundinout(inout,transaction);
  154. // 提交
  155. }
  156. public void AddFundRecord(string busiseq, string balancesubject, string buyercode, string fundtype, string billno, double money, string importor, string importtime, string inouttime, string remark, string orderno,
  157. double leavemny, string seccount, String moneyDe, string prebuyercode,out string errMsg)
  158. {
  159. errMsg = "";
  160. FundBLL.FundTransferMgt.FundTransferMgt FundTransferMgt = new FundBLL.FundTransferMgt.FundTransferMgt(_ob);
  161. Model.SEL_FUND_CUST_FUNDINOUT inout = null;
  162. inout = GetSelFundCustInout(balancesubject, buyercode, fundtype, billno, money, importor, importtime, inouttime, remark, orderno);
  163. Model.SEL_FUND_CUST_ACCOUNT acct = new Model.SEL_FUND_CUST_ACCOUNT();
  164. acct.BALANCESUBJECT = balancesubject;
  165. acct.BUYERCODE = buyercode;
  166. inout.IMPORTOR = importor;
  167. inout.LEAVEMONEY = leavemny;
  168. inout.SECONDACCOUNT = seccount;
  169. inout.BUSISEQ = busiseq;
  170. inout.MONEY_DELIVER = moneyDe;
  171. inout.PREBUYERCODE = prebuyercode;
  172. Model.SEL_FUND_TRANS_SECONDACCOUNT sceact = null;
  173. System.Collections.ArrayList lists = null;
  174. // if (money < 0)
  175. // {
  176. // sceact = GetTransSecAccount(balancesubject, buyercode, fundtype, billno, -money,
  177. // importor, importtime, inouttime, remark, seccount);
  178. // lists = FundTransferMgt.GetTransferMoneySecondAccountToCust(sceact, out errMsg);
  179. // }
  180. // else
  181. // {
  182. // sceact = GetTransSecAccount(balancesubject, buyercode, fundtype, billno, money,
  183. //importor, importtime, inouttime, remark, seccount);
  184. // lists = FundTransferMgt.GetTransferMoneyCustToSecondAccount(sceact, out errMsg);
  185. // }
  186. // 开启事务处理
  187. // 先更新总资金
  188. System.Collections.ArrayList sqlList = new System.Collections.ArrayList();
  189. // sqlList.Add(base.GetFundCustAccountInstance().Sql_AddMoneyToCustAccount(acct, money));
  190. sqlList.Add(base.GetFundInOutInstance().Sql_Insert_SelFundCustFundinout(inout));
  191. // sqlList.AddRange(lists);
  192. base.ExecuteNoReader(sqlList, out errMsg);
  193. // 写明细
  194. // base.GetFundInOutInstance().Insert_SelFundCustFundinout(inout,transaction);
  195. // 提交
  196. }
  197. public void AffrimFundRecord(string busiseq, string balancesubject, string buyercode, string fundtype, string billno, double money, string importor, string importtime, string inouttime, string remark, string orderno, double leavemny, string seccount, out string errMsg)
  198. {
  199. errMsg = "";
  200. FundBLL.FundTransferMgt.FundTransferMgt FundTransferMgt = new FundBLL.FundTransferMgt.FundTransferMgt(_ob);
  201. Model.SEL_FUND_CUST_FUNDINOUT inout = null;
  202. inout = GetSelFundCustInout(balancesubject, buyercode, fundtype, billno, money, importor, importtime, inouttime, remark, orderno);
  203. Model.SEL_FUND_CUST_ACCOUNT acct = new Model.SEL_FUND_CUST_ACCOUNT();
  204. acct.BALANCESUBJECT = balancesubject;
  205. acct.BUYERCODE = buyercode;
  206. inout.IMPORTOR = importor;
  207. inout.LEAVEMONEY = leavemny;
  208. inout.SECONDACCOUNT = seccount;
  209. Model.SEL_FUND_TRANS_SECONDACCOUNT sceact = null;
  210. System.Collections.ArrayList lists = null;
  211. if (money < 0)
  212. {
  213. sceact = GetTransSecAccount(balancesubject, buyercode, fundtype, billno, -money,
  214. importor, importtime, inouttime, remark, seccount);
  215. lists = FundTransferMgt.GetTransferMoneySecondAccountToCust(sceact, out errMsg);
  216. }
  217. else
  218. {
  219. sceact = GetTransSecAccount(balancesubject, buyercode, fundtype, billno, money,
  220. importor, importtime, inouttime, remark, seccount);
  221. lists = FundTransferMgt.GetTransferMoneyCustToSecondAccount(sceact, out errMsg);
  222. }
  223. // 开启事务处理
  224. // 先更新总资金
  225. System.Collections.ArrayList sqlList = new System.Collections.ArrayList();
  226. sqlList.Add(base.GetFundCustAccountInstance().Sql_AddMoneyToCustAccount(acct, money));
  227. sqlList.Add(base.GetFundInOutInstance().Sql_UpdateSelFundCustFundInoutStatusToValidt(busiseq, importor));
  228. sqlList.AddRange(lists);
  229. base.ExecuteNoReader(sqlList, out errMsg);
  230. // 写明细
  231. // base.GetFundInOutInstance().Insert_SelFundCustFundinout(inout,transaction);
  232. // 提交
  233. }
  234. public void UnAffrimFundRecord(string busiseq, string balancesubject, string buyercode, string fundtype, string billno, double money, string importor, string importtime, string inouttime, string remark,string orderno, double leavemny, string seccount, out string errMsg)
  235. {
  236. errMsg = "";
  237. FundBLL.FundTransferMgt.FundTransferMgt FundTransferMgt = new FundBLL.FundTransferMgt.FundTransferMgt(_ob);
  238. Model.SEL_FUND_CUST_FUNDINOUT inout = null;
  239. inout = GetSelFundCustInout(balancesubject, buyercode, fundtype, billno, money, importor, importtime, inouttime, remark, orderno);
  240. Model.SEL_FUND_CUST_ACCOUNT acct = new Model.SEL_FUND_CUST_ACCOUNT();
  241. acct.BALANCESUBJECT = balancesubject;
  242. acct.BUYERCODE = buyercode;
  243. inout.IMPORTOR = importor;
  244. inout.LEAVEMONEY = leavemny;
  245. inout.SECONDACCOUNT = seccount;
  246. Model.SEL_FUND_TRANS_SECONDACCOUNT sceact = null;
  247. System.Collections.ArrayList lists = null;
  248. sceact = GetTransSecAccount(balancesubject, buyercode, fundtype, billno, -money,
  249. importor, importtime, inouttime, remark, seccount);
  250. lists = FundTransferMgt.GetTransferMoneySecondAccountToCust(sceact, out errMsg);
  251. // 开启事务处理
  252. // 先更新总资金
  253. System.Collections.ArrayList sqlList = new System.Collections.ArrayList();
  254. sqlList.Add(base.GetFundCustAccountInstance().Sql_AddMoneyToCustAccount(acct, money));
  255. sqlList.Add(base.GetFundInOutInstance().Sql_UpdateSelFundCustFundInoutStatusToUnValidt(busiseq, importor));
  256. sqlList.AddRange(lists);
  257. base.ExecuteNoReader(sqlList, out errMsg);
  258. // 写明细
  259. // base.GetFundInOutInstance().Insert_SelFundCustFundinout(inout,transaction);
  260. // 提交
  261. }
  262. public void DeleteFundRecord(string busiseq, string importor, out string errMsg)
  263. {
  264. // 开启事务处理
  265. // 先更新总资金
  266. System.Collections.ArrayList sqlList = new System.Collections.ArrayList();
  267. sqlList.Add(base.GetFundInOutInstance().Sql_DeleteSelFundCustFundInoutRecord(busiseq, importor));
  268. // 如果是钢贸的,同步把给销售的也删除掉
  269. sqlList.Add(base.GetFundInOutInstance().Sql_DeleteSelFundCustFundInoutRecord(busiseq+"-1", importor));
  270. base.ExecuteNoReader(sqlList, out errMsg);
  271. // 写明细
  272. // base.GetFundInOutInstance().Insert_SelFundCustFundinout(inout,transaction);
  273. // 提交
  274. }
  275. private Model.SEL_FUND_TRANS_SECONDACCOUNT GetTransSecAccount(string balancesubject, string buyercode, string fundtype, string billno, double money,
  276. string importor, string importtime, string inouttime, string remark,string seccount)
  277. {
  278. Model.SEL_FUND_TRANS_CUST cust = GetTransCustAccount( balancesubject, buyercode, fundtype, billno, importor, importtime, inouttime, remark, seccount, money);
  279. if (cust == null)
  280. return null;
  281. string secondLevelAccount = seccount;
  282. Model.SEL_FUND_TRANS_SECONDACCOUNT sec = new Model.SEL_FUND_TRANS_SECONDACCOUNT();
  283. sec.FUND_TRANS_CUST = cust;
  284. sec.SECONDACCOUNT = secondLevelAccount;
  285. sec.TRANS_MONEY = money;
  286. return sec;
  287. }
  288. private Model.SEL_FUND_TRANS_CUST GetTransCustAccount(string balancesubject, string buyercode, string fundtype, string billno, string importor, string importtime, string inouttime, string remark, string seccount,double money)
  289. {
  290. // money = Convert.ToDouble(this.ultraNumericEditor1.Value);
  291. Model.SEL_FUND_TRANS_CUST cust = new Model.SEL_FUND_TRANS_CUST();
  292. cust.BALANCESUBJECT = balancesubject;
  293. cust.BUYERCODE = buyercode;
  294. cust.TRANS_MONEY = money;
  295. cust.TRANS_PERSON = importor;
  296. cust.TRANS_TIME = Util.DateTimeUtil.GetSystemDate();
  297. return cust;
  298. }
  299. }
  300. }