FundInOutDAL.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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.FundDAL.FundInOutDAL
  9. {
  10. public class FundInOutDAL:BaseDAL.BaseDAL
  11. {
  12. private const string SQL_SEL_FUND_CUST_FUNDINOUT = @" select busiseq,
  13. balancesubject,
  14. buyercode,
  15. inoutmoney,
  16. INOUTTIME,
  17. fundtype,
  18. billno,
  19. isvalid,
  20. remark,
  21. importor,
  22. importtime,
  23. leavemoney ,secondaccount,affrimper,affrimdate ,
  24. money_deliver,prebuyercode,orderno
  25. from sel_fund_cust_fundinout where 1 = 1 {0}";
  26. private const string SQL_SEL_FUND_CUST_FUNDINOUT_INSERT = @" insert into sel_fund_cust_fundinout
  27. (BUSISEQ,
  28. BALANCESUBJECT,
  29. BUYERCODE,
  30. INOUTMONEY,
  31. FUNDTYPE,
  32. BILLNO,
  33. ISVALID,
  34. REMARK,
  35. ORDERNO,
  36. IMPORTOR,
  37. IMPORTTIME,
  38. LEAVEMONEY,INOUTTIME,SECONDACCOUNT,MONEY_DELIVER
  39. ,PREBUYERCODE,INVOICE_MONTH) values(
  40. '{12}','{0}','{1}',{2},'{3}','{4}','{5}','{6}','{7}','{8}',sysdate
  41. ,{9},to_date('{10}','yyyymmddhh24miss'),'{11}','{13}','{14}',GET_FISCAL_MONTH()) ";
  42. private const string SQL_DELETEBYBUSISEQ = @"delete from sel_fund_cust_fundinout a where a.busiseq = '{0}' ";
  43. private const string SQL_UPDATEBYBUSISEQ = @" update sel_fund_cust_fundinout a set isvalid = '1' where a.busiseq = '{0}' ";
  44. public FundInOutDAL(OpeBase ob): base(ob)
  45. {
  46. }
  47. private string GetSqlCondition(string balancesubject, string buyercode)
  48. {
  49. return string.Format(" and balancesubject = '{0}' and buyercode = '{1}' ", balancesubject, buyercode);
  50. }
  51. /// <summary>
  52. /// 返回数据集
  53. /// </summary>
  54. /// <param name="sqlCondition"></param>
  55. /// <returns></returns>
  56. public DataSet GetSelFundCustFundInOut(string sqlCondition)
  57. {
  58. string sqlStr = string.Format(SQL_SEL_FUND_CUST_FUNDINOUT,sqlCondition);
  59. return base.ExecuteReader(sqlStr);
  60. }
  61. /// <summary>
  62. /// 返回数据集,带标题
  63. /// </summary>
  64. /// <param name="sqlCondition"></param>
  65. /// <param name="isSetCaption"></param>
  66. /// <returns></returns>
  67. public DataSet GetSelFundCustFundInOut(string sqlCondition,Boolean isSetCaption)
  68. {
  69. DataSet ds = GetSelFundCustFundInOut(sqlCondition);
  70. if (isSetCaption)
  71. {
  72. base.SetDataSetCaption(ref ds,base.GetColumnNameAndCaption());
  73. }
  74. return ds;
  75. }
  76. /// <summary>
  77. /// 通过结算主体和客户名称返回记录
  78. /// </summary>
  79. /// <param name="balanceSubject"></param>
  80. /// <param name="buyerCode"></param>
  81. /// <returns></returns>
  82. public DataSet GetSelFundCustFundInOutByBalanceSubjectAndBuyerCode(string balanceSubject,string buyerCode )
  83. {
  84. return GetSelFundCustFundInOut(GetSqlCondition(balanceSubject,buyerCode));
  85. }
  86. /// <summary>
  87. /// 通过结算主体和客户名称返回记录,初始化标题,记录开始时间,结束时间
  88. /// </summary>
  89. /// <param name="balanceSubject"></param>
  90. /// <param name="buyerCode"></param>
  91. /// <param name="begintime"></param>
  92. /// <param name="endtime"></param>
  93. /// <returns></returns>
  94. public DataSet GetSelFundCustFundInOutByBalanceSubjectAndBuyerCodeAndInOutDate(string balanceSubject, string buyerCode,string begintime,string endtime)
  95. {
  96. string sqlcondition = GetSqlCondition(balanceSubject, buyerCode);
  97. sqlcondition = sqlcondition + ConvertStringDateValueToDbLanguage("inouttime", begintime, endtime);
  98. return GetSelFundCustFundInOut(sqlcondition, true);
  99. }
  100. public DataSet GetSelFundCustFundInOutByBalanceSubjectAndInOutDate(string balanceSubject, string begintime, string endtime)
  101. {
  102. string sqlcondition = string.Format(" and balancesubject = '{0}' ",balanceSubject);
  103. sqlcondition = sqlcondition + ConvertStringDateValueToDbLanguage("inouttime", begintime, endtime);
  104. return GetSelFundCustFundInOut(sqlcondition, true);
  105. }
  106. /// <summary>
  107. /// 通过结算主体和客户名称返回记录,初始化标题
  108. /// </summary>
  109. /// <param name="balanceSubject">结算单位</param>
  110. /// <param name="buyerCode">客户单位</param>
  111. /// <param name="isSetCaption">是否初始化dataset 标题</param>
  112. /// <returns></returns>
  113. public DataSet GetSelFundCustFundInOutByBalanceSubjectAndBuyerCode(string balanceSubject, string buyerCode,Boolean isSetCaption)
  114. {
  115. return GetSelFundCustFundInOut(GetSqlCondition(balanceSubject, buyerCode), isSetCaption);
  116. }
  117. public List<Model.SEL_FUND_CUST_FUNDINOUT> GetGetSelFundCustFundInOutModelByBalanceSubjectAndBuyerCode(string balanceSubject, string buyerCode)
  118. {
  119. DataSet ds = GetSelFundCustFundInOutByBalanceSubjectAndBuyerCode( balanceSubject, buyerCode );
  120. return Model.SEL_FUND_CUST_FUNDINOUT.GetSelFundCustFundInOutList(ds);
  121. }
  122. private string GetInsertSqlStrByFundInandOutModel(Model.SEL_FUND_CUST_FUNDINOUT inout)
  123. {
  124. if (inout == null)
  125. return "";
  126. try
  127. {
  128. string sqlStr = string.Format(SQL_SEL_FUND_CUST_FUNDINOUT_INSERT,
  129. inout.BALANCESUBJECT,
  130. inout.BUYERCODE,
  131. inout.INOUTMONEY,
  132. inout.FUNDTYPE,
  133. inout.BILLNO,
  134. "0",
  135. inout.REMARK,
  136. inout.ORDERNO,
  137. inout.IMPORTOR,
  138. inout.LEAVEMONEY, inout.INOUTTIME,inout.SECONDACCOUNT,inout.BUSISEQ,inout.MONEY_DELIVER,
  139. inout.PREBUYERCODE
  140. );
  141. return sqlStr;
  142. }
  143. catch
  144. { }
  145. return "";
  146. }
  147. /// <summary>
  148. /// 写入一个进出账记录,带事务
  149. /// </summary>
  150. /// <param name="inout"></param>
  151. /// <param name="transaction"></param>
  152. public void Insert_SelFundCustFundinout(Model.SEL_FUND_CUST_FUNDINOUT inout,Core.StlMes.Client.Sale.DbHelp.DbTransaction transaction)
  153. {
  154. string InsertSqlStr = GetInsertSqlStrByFundInandOutModel(inout);
  155. if (InsertSqlStr.Length == 0)
  156. return;
  157. string err = "";
  158. if(! Model.SEL_FUND_CUST_FUNDINOUT.IsReasonable(inout,out err))
  159. {
  160. transaction.ErrMsg = err;
  161. return;
  162. }
  163. try
  164. {
  165. base.ExecuteNoQueryTransaction(InsertSqlStr, transaction);
  166. }
  167. catch
  168. {
  169. }
  170. }
  171. public string Sql_Insert_SelFundCustFundinout(Model.SEL_FUND_CUST_FUNDINOUT inout)
  172. {
  173. string InsertSqlStr = GetInsertSqlStrByFundInandOutModel(inout);
  174. return InsertSqlStr;
  175. }
  176. public string Sql_UpdateSelFundCustFundInoutStatusToValidt(string busiseq,string person)
  177. {
  178. string sql = " update sel_fund_cust_fundinout set isvalid = '1' ,affrimper = '{0}',affrimdate = sysdate where busiseq = '{1}' ";
  179. sql = string.Format(sql,person,busiseq);
  180. return sql;
  181. }
  182. public string Sql_UpdateSelFundCustFundInoutStatusToUnValidt(string busiseq, string person)
  183. {
  184. string sql = " update sel_fund_cust_fundinout set isvalid = '0' ,affrimper = '',affrimdate = null where busiseq = '{0}' ";
  185. sql = string.Format(sql, busiseq);
  186. return sql;
  187. }
  188. public string Sql_DeleteSelFundCustFundInoutRecord(string busiseq, string person)
  189. {
  190. string sql = " delete from sel_fund_cust_fundinout where busiseq = '{0}' and isvalid = '0' ";
  191. sql = string.Format(sql, busiseq);
  192. return sql;
  193. }
  194. /// <summary>
  195. /// 写入一个进出账记录
  196. /// </summary>
  197. /// <param name="inout"></param>
  198. /// <param name="errMsg"></param>
  199. public void Insert_SelFundCustFundinout(Model.SEL_FUND_CUST_FUNDINOUT inout,out string errMsg)
  200. {
  201. string InsertSqlStr = GetInsertSqlStrByFundInandOutModel(inout);
  202. errMsg = "";
  203. if (InsertSqlStr.Length == 0)
  204. return;
  205. if (!Model.SEL_FUND_CUST_FUNDINOUT.IsReasonable(inout, out errMsg))
  206. {
  207. return;
  208. }
  209. try
  210. {
  211. base.ExecuteNoReader(InsertSqlStr, out errMsg);
  212. }
  213. catch
  214. {
  215. }
  216. }
  217. /// <summary>
  218. /// 删除一个记录
  219. /// </summary>
  220. /// <param name="buseSeq"></param>
  221. /// <param name="errMsg"></param>
  222. public void Delete_SelFundCustFundinout(string buseSeq, out string errMsg)
  223. {
  224. string sqlStr = "";
  225. sqlStr = string.Format(SQL_DELETEBYBUSISEQ, buseSeq);
  226. errMsg = "";
  227. try
  228. {
  229. base.ExecuteNoReader(sqlStr, out errMsg);
  230. }
  231. catch
  232. {
  233. }
  234. }
  235. public void Delete_SelFundCustFundinout(string buseSeq, DbHelp.DbTransaction transaction)
  236. {
  237. string sqlStr = "";
  238. sqlStr = string.Format(SQL_DELETEBYBUSISEQ, buseSeq);
  239. try
  240. {
  241. base.ExecuteNoQueryTransaction(sqlStr, transaction);
  242. }
  243. catch
  244. {
  245. }
  246. }
  247. /// <summary>
  248. /// 删除一条记录,指示将标志位改为无效
  249. /// </summary>
  250. /// <param name="buseSeq"></param>
  251. /// <param name="errMsg"></param>
  252. public void Update_SelFundCustFundinout(string buseSeq, out string errMsg)
  253. {
  254. string sqlStr = " ";
  255. sqlStr = string.Format(SQL_UPDATEBYBUSISEQ, buseSeq);
  256. errMsg = "";
  257. try
  258. {
  259. base.ExecuteNoReader(sqlStr, out errMsg);
  260. }
  261. catch
  262. {
  263. }
  264. }
  265. public void Update_SelFundCustFundinout(string buseSeq, DbHelp.DbTransaction transaction)
  266. {
  267. string sqlStr = " ";
  268. sqlStr = string.Format(SQL_UPDATEBYBUSISEQ, buseSeq);
  269. try
  270. {
  271. base.ExecuteNoQueryTransaction(sqlStr, transaction);
  272. }
  273. catch
  274. {
  275. }
  276. }
  277. }
  278. }