BaseDAL.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. namespace Core.StlMes.Client.Sale.SaleFundMgt.FundDAL.BaseDAL
  8. {
  9. public class BaseDAL
  10. {
  11. private Core.StlMes.Client.Sale.DbHelp.DbExecute dbhelp = null;
  12. private string daoName = FundVariable.FundConstVariable.DefaultDaoName;
  13. public string ConvertStringDateValueToDbLanguage(string columnName, string beginDate, string endDate)
  14. {
  15. string strbegin = beginDate.Replace("-", "").Replace("/", "").Replace(" ","").Substring(0,8);
  16. string strend = endDate.Replace("-", "").Replace("/", "").Replace(" ", "").Substring(0,8);
  17. return string.Format(" and {0} >= trunc( to_date('{1}','yyyymmdd')) and {0} < trunc( to_date('{2}','yyyymmdd')) + 1 ",
  18. columnName, strbegin, strend);
  19. }
  20. public string DaoName
  21. {
  22. set
  23. {
  24. this.daoName = value;
  25. }
  26. }
  27. public BaseDAL(OpeBase ob)
  28. {
  29. // ob.MainUrl = FundVariable.FundConstVariable.defaultMainStringUrl;
  30. dbhelp = new Core.StlMes.Client.Sale.DbHelp.DbExecute(ob);
  31. }
  32. public System.Data.DataSet ExecuteReader(string sqlStr)
  33. {
  34. DataSet ds = new DataSet();
  35. try
  36. {
  37. ds = dbhelp.ExecuteQuery(sqlStr, daoName);
  38. }
  39. catch
  40. {
  41. }
  42. return ds;
  43. }
  44. protected void ExecuteNoReader(string sqlStr,out string errMsg)
  45. {
  46. errMsg = "";
  47. try
  48. {
  49. dbhelp.ExecuteNoQuery(sqlStr, daoName, out errMsg);
  50. }
  51. catch
  52. {
  53. }
  54. }
  55. protected void ExecuteNoReader(string sqlStr)
  56. {
  57. try
  58. {
  59. dbhelp.ExecuteNoQuery(sqlStr, daoName);
  60. }
  61. catch
  62. {
  63. }
  64. }
  65. protected void ExecuteNoReader(string sqlStr, Core.StlMes.Client.Sale.DbHelp.DbTransaction transaction)
  66. {
  67. try
  68. {
  69. dbhelp.ExecuteNoQueryTransaction(sqlStr, transaction);
  70. }
  71. catch
  72. {
  73. }
  74. }
  75. protected void ExecuteNoQueryTransaction(string sqlStr, Core.StlMes.Client.Sale.DbHelp.DbTransaction transaction)
  76. {
  77. try
  78. {
  79. dbhelp.ExecuteNoQueryTransaction(sqlStr, transaction);
  80. }
  81. catch
  82. {
  83. }
  84. }
  85. protected void ExecuteNoReaderForSaleFund(string sqlStr, Core.StlMes.Client.Sale.DbHelp.DbTransaction transaction)
  86. {
  87. ExecuteNoReader(sqlStr,transaction);
  88. }
  89. protected void ExecuteNoReaderForSaleFund(string sqlStr)
  90. {
  91. ExecuteNoReader(sqlStr);
  92. }
  93. protected void ExecuteNoReaderForSaleFund(string sqlStr,out string errMsg)
  94. {
  95. errMsg = "";
  96. ExecuteNoReader(sqlStr,out errMsg);
  97. }
  98. protected DataSet ExecuteReaderForSaleFund(string sqlstr)
  99. {
  100. return this.ExecuteReader(sqlstr);
  101. }
  102. protected virtual string GetSqlConditon(string balancesubject, string buyercode, string secondaccount, string pactno)
  103. {
  104. string sqlCondition = string.Format(" and balancesubject = '{0}' and buyercode = '{1}' and secondaccount = '{2}' and pactno = '{3}' ",
  105. balancesubject, buyercode, secondaccount, pactno
  106. );
  107. return sqlCondition;
  108. }
  109. protected virtual string GetSqlConditon(string balancesubject, string buyercode, string secondaccount)
  110. {
  111. string sqlCondition = string.Format(" and balancesubject = '{0}' and buyercode = '{1}' and secondaccount = '{2}' ",
  112. balancesubject, buyercode, secondaccount);
  113. return sqlCondition;
  114. }
  115. protected virtual string GetSqlConditon(string balancesubject, string pactno)
  116. {
  117. string sqlCondition = string.Format(" and balancesubject = '{0}' and pactno = '{1}' ",
  118. balancesubject, pactno);
  119. return sqlCondition;
  120. }
  121. protected virtual string GetSqlConditon(string balancesubject, string buyercode,string pactno,string v1,string v2,string v3)
  122. {
  123. string sqlCondition = string.Format(" and balancesubject = '{0}' and buyercode = '{2}' and pactno = '{1}' ",
  124. balancesubject, pactno,buyercode);
  125. return sqlCondition;
  126. }
  127. protected virtual string GetSqlConditon(string balancesubject, string buyercode, double v)
  128. {
  129. string sqlCondition = string.Format(" and balancesubject = '{0}' and buyercode = '{1}' ",
  130. balancesubject, buyercode);
  131. return sqlCondition;
  132. }
  133. /// <summary>
  134. /// 获取表中所有字段名称以及显示名称,组合成hs返回
  135. /// 允许前端重写
  136. /// 后续新增字段,注意结果按第一字母顺序
  137. /// 字段名统一大写
  138. /// </summary>
  139. /// <returns>Hashtable</returns>
  140. protected virtual System.Collections.Hashtable GetColumnNameAndCaption()
  141. {
  142. System.Collections.Hashtable hs = new System.Collections.Hashtable();
  143. try
  144. {
  145. hs.Add("ASKPLAN_ID", "提单号");
  146. hs.Add("ASKPLAN_MONEY", "货物款");
  147. hs.Add("BALANCESUBJECT", "销售组织");
  148. hs.Add("BILLNO", "票号");
  149. hs.Add("BUSISEQ", "序列");
  150. hs.Add("BUSITYPE", "类型");
  151. hs.Add("BUYERCODE", "客户单位");
  152. hs.Add("DELETEOR", "删除人");
  153. hs.Add("DELETETIME", "删除时间");
  154. hs.Add("FUNDTYPE", "类型");
  155. hs.Add("IMPORTOR", "录入人");
  156. hs.Add("IMPORTTIME", "录入时间");
  157. hs.Add("INOUTMONEY", "金额");
  158. hs.Add("INOUTTIME", "进出时间");
  159. hs.Add("INVOICE_MONEY", "金额");
  160. hs.Add("ISINVOINCE", "结算标志");
  161. hs.Add("ISMONEYVALID", "是否有效");
  162. hs.Add("ISUNUSUAL", "是否正常");
  163. hs.Add("ISVALID", "是否有效");
  164. hs.Add("LASTUPDATETIME", "更新时间");
  165. hs.Add("LEAVEMONEY", "剩余资金");
  166. hs.Add("MONEY", "发生金额");
  167. hs.Add("MONEY_TYPE", "类型");
  168. hs.Add("OTHERACCOUNT", "对方账户");
  169. hs.Add("PACTNO", "合同号");
  170. hs.Add("PACTNO_MONEY", "合同金额");
  171. hs.Add("PACT_BEGINDATE", "合同开始时间");
  172. hs.Add("PACT_REA_NAME", "映射名称");
  173. hs.Add("PACT_REA_NAME_SHOW", "映射名称");
  174. hs.Add("PRIORITY", "优先级");
  175. hs.Add("RELATION", "映射分类");
  176. hs.Add("REMARK", "备注");
  177. hs.Add("SECONDACCOUNT", "二级账户");
  178. hs.Add("TOTALMONEY", "总资金");
  179. hs.Add("TRANS_MONEY", "运费");
  180. hs.Add("TRANS_PERSON", "调拨人");
  181. hs.Add("TRANS_SEQ", "序列");
  182. hs.Add("TRANS_TIME", "时间");
  183. hs.Add("TRANS_TYPE", "类型");
  184. hs.Add("TYPE", "类型");
  185. hs.Add("USERID", "用户ID");
  186. hs.Add("UPDATETIME", "更新时间");
  187. hs.Add("WEIGHT", "重量");
  188. }
  189. catch
  190. {
  191. }
  192. return hs;
  193. }
  194. /// <summary>
  195. /// 设置数据集的标题
  196. /// </summary>
  197. /// <param name="ds"></param>
  198. /// <param name="hsColumn"></param>
  199. protected void SetDataSetCaption(ref DataSet ds, System.Collections.Hashtable hsColumn)
  200. {
  201. if (ds == null)
  202. return;
  203. if (ds.Tables.Count == 0)
  204. return;
  205. if (hsColumn == null)
  206. return;
  207. if (hsColumn.Count == 0)
  208. return;
  209. foreach ( DataColumn dc in ds.Tables[0].Columns)
  210. {
  211. try
  212. {
  213. dc.Caption = hsColumn[dc.ColumnName.ToUpper()].ToString();
  214. }
  215. catch
  216. {
  217. }
  218. }
  219. }
  220. }
  221. }