CheckDataTrans.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using SysDataLibs;
  5. using SysDataLibs.TableClass ;
  6. using System.Data ;
  7. using SysBaseLibs;
  8. namespace DataTransfersLibs
  9. {
  10. public class CheckDataTrans : Sys_Users_info
  11. {
  12. public CheckDataTrans(DataRow poRow, DBConnSql poDBConn)
  13. : base(poRow)
  14. {
  15. if (poRow != null && poDBConn != null && poDBConn.IsOpened )
  16. {
  17. _DBConn = poDBConn;
  18. if (this.IsMarketSys)
  19. {
  20. string lcSql = "select * from vwUserHasAllMarkets where UserId='" + this.UserID + "'";
  21. rsQuery loQuery = _DBConn.OpenQuery(lcSql);
  22. if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
  23. {
  24. loQuery.MoveFirst();
  25. _MarketId = loQuery.GetString("MarketID");
  26. }
  27. }
  28. }
  29. }
  30. private DBConnSql _DBConn = null;
  31. public DBConnSql DBConn
  32. {
  33. get { return _DBConn; }
  34. }
  35. string _MarketId = "";
  36. public string MarketId
  37. {
  38. get { return _MarketId; }
  39. }
  40. rsQuery _CheckProTypes = null;
  41. private rsQuery CheckProTypes
  42. {
  43. get
  44. {
  45. if (_CheckProTypes == null || !_CheckProTypes.IsOpened)
  46. {
  47. string lcSql = " select * from CheckProjectType ";
  48. _CheckProTypes = _DBConn.OpenQuery(lcSql);
  49. }
  50. return _CheckProTypes;
  51. }
  52. }
  53. rsQuery _CheckItems = null;
  54. private rsQuery CheckItems
  55. {
  56. get
  57. {
  58. if (_CheckItems == null || !_CheckItems.IsOpened)
  59. {
  60. string lcSql = " select * from CheckItem";
  61. _CheckItems = _DBConn.OpenQuery(lcSql);
  62. }
  63. return _CheckItems;
  64. }
  65. }
  66. rsQuery _CheckMethods = null;
  67. private rsQuery CheckMethods
  68. {
  69. get
  70. {
  71. if (_CheckMethods == null || !_CheckMethods.IsOpened)
  72. {
  73. string lcSql = " select * from CheckMethod";
  74. _CheckMethods = _DBConn.OpenQuery(lcSql);
  75. }
  76. return _CheckMethods;
  77. }
  78. }
  79. rsQuery _HabitQuery = null;
  80. private rsQuery HabitQuery
  81. {
  82. get
  83. {
  84. if (_HabitQuery == null || !_HabitQuery.IsOpened)
  85. {
  86. string lcSql = "select " + Habitat_info.cHabitatID + "," + Habitat_info.cNames + " from " + Tn.Habitat;
  87. _HabitQuery = _DBConn.OpenQuery(lcSql);
  88. }
  89. return _HabitQuery;
  90. }
  91. }
  92. rsQuery _SpecialsQuery = null;
  93. private rsQuery SpecialsQuery
  94. {
  95. get
  96. {
  97. if (_SpecialsQuery == null || !_SpecialsQuery.IsOpened)
  98. {
  99. string lcSql = "select * from " + Tn.Specials;
  100. _SpecialsQuery = _DBConn.OpenQuery(lcSql);
  101. }
  102. return _SpecialsQuery;
  103. }
  104. }
  105. rsQuery _VarietyCategoryQuery = null;
  106. private rsQuery VarietyCategoryQuery
  107. {
  108. get
  109. {
  110. if (_VarietyCategoryQuery == null || !_VarietyCategoryQuery.IsOpened)
  111. {
  112. string lcSql = "select * from " + Tn.VarietyCategory;
  113. _VarietyCategoryQuery = _DBConn.OpenQuery(lcSql);
  114. }
  115. return _VarietyCategoryQuery;
  116. }
  117. }
  118. public string GetCheckProTypeIDByItemAndMothed(string pcItem, string pcMothed, string pcValueField)
  119. {
  120. string lcRetVal = "";
  121. var lcItem = TransCheckItem(pcItem);
  122. var lcMothed = TransCheckMothed(pcMothed);
  123. if (CheckCach.CheckProjectCach.ContainsKey(lcItem + "_" + lcMothed))
  124. {
  125. lcRetVal = CheckCach.CheckProjectCach[lcItem + "_" + lcMothed];
  126. return lcRetVal;
  127. }
  128. if (lcItem != null && lcMothed != null&& CheckProTypes != null && CheckProTypes.IsOpened)
  129. {
  130. if (CheckProTypes.GoToRecordByFieldsAndValues(CheckProjectType_info.cCheckItemId + "," + CheckProjectType_info.cCheckMethodId, lcItem + "," + lcMothed))
  131. {
  132. lcRetVal = CheckProTypes.GetString(pcValueField);
  133. }
  134. else if (CheckProTypes.GoToRecordByFieldsAndValues(CheckProjectType_info.cCheckItemId, lcItem))
  135. {
  136. lcRetVal = CheckProTypes.GetString(pcValueField);
  137. }
  138. }
  139. if (!string.IsNullOrEmpty(lcRetVal))
  140. {
  141. CheckCach.CheckProjectCach.Add(lcItem+"_"+ lcMothed,lcRetVal);
  142. }
  143. return lcRetVal;
  144. }
  145. public string GetHabitIdByHabitName(string pcHabitName)
  146. {
  147. string lcRetVal = "";
  148. if (HabitQuery != null && HabitQuery.IsOpened)
  149. {
  150. if (HabitQuery.GoToRecordByFieldsAndValues(Habitat_info.cNames, pcHabitName))
  151. {
  152. return CheckProTypes.GetString(Habitat_info.cHabitatID);
  153. }
  154. }
  155. return lcRetVal;
  156. }
  157. public string TransResult(string pcValue)
  158. {
  159. pcValue = UtilStr.UAndT(pcValue);
  160. if (pcValue == "1" || pcValue == "合格")
  161. {
  162. return "合格";
  163. }
  164. else
  165. {
  166. return "不合格";
  167. }
  168. }
  169. public string TransCheckMothed(string pcValue)
  170. {
  171. string lcRetVal = null;
  172. if (pcValue == "速测法" || pcValue == "检测卡")
  173. {
  174. pcValue = "速测灵";
  175. }
  176. if (pcValue == "检测仪")
  177. {
  178. pcValue = "速测仪";
  179. }
  180. if (CheckCach.CheckMethodCach.ContainsKey(pcValue))
  181. {
  182. lcRetVal = CheckCach.CheckMethodCach[pcValue];
  183. return lcRetVal;
  184. }
  185. if (CheckMethods.GoToRecordByFieldsAndValues(CheckMethod_info.cCheckMethodName, pcValue))
  186. {
  187. lcRetVal = CheckMethods.GetString(CheckMethod_info.cCheckMethodId);
  188. }
  189. if (!string.IsNullOrEmpty(lcRetVal))
  190. {
  191. CheckCach.CheckMethodCach.Add(pcValue, lcRetVal);
  192. }
  193. return lcRetVal;
  194. }
  195. public string TransCheckItem(string pcValue)
  196. {
  197. string lcRetVal = null;
  198. if (pcValue == "残留农药")
  199. {
  200. pcValue = "农药残留";
  201. }
  202. if (CheckCach.CheckItemCach.ContainsKey(pcValue))
  203. {
  204. lcRetVal = CheckCach.CheckItemCach[pcValue];
  205. return lcRetVal;
  206. }
  207. if (CheckItems.GoToRecordByFieldsAndValues(CheckItem_info.cCheckItemName, pcValue))
  208. {
  209. lcRetVal = CheckItems.GetString(CheckItem_info.cCheckItemId);
  210. }
  211. if (!string.IsNullOrEmpty(lcRetVal))
  212. {
  213. CheckCach.CheckItemCach.Add(pcValue, lcRetVal);
  214. }
  215. return lcRetVal;
  216. }
  217. public string GetSampleNo(string pcSampleName)
  218. {
  219. string lcRetVal = "";
  220. //if (SpecialsQuery != null && SpecialsQuery.IsOpened)
  221. //{
  222. // if (SpecialsQuery.GoToRecordByFieldsAndValues(Specials_info.cName, pcSampleName))
  223. // {
  224. // lcRetVal = SpecialsQuery.GetString(Specials_info.cName);
  225. // }
  226. //}
  227. if (CheckCach.VarietyCategoryCache.ContainsKey(pcSampleName))
  228. {
  229. lcRetVal = CheckCach.VarietyCategoryCache[pcSampleName];
  230. return lcRetVal;
  231. }
  232. if (VarietyCategoryQuery.GoToRecordByFieldsAndValues(VarietyCategory_info.cVarietyCategoryName,
  233. pcSampleName))
  234. {
  235. lcRetVal = VarietyCategoryQuery.GetString(VarietyCategory_info.cVarietyCategoryNo);
  236. }
  237. if (!string.IsNullOrEmpty(lcRetVal))
  238. {
  239. CheckCach.VarietyCategoryCache.Add(pcSampleName, lcRetVal);
  240. }
  241. return lcRetVal;
  242. }
  243. //public string GetLittleKindName(string pcSampleName)
  244. //{
  245. // string lcRetVal = "";
  246. // if (SpecialsQuery != null && SpecialsQuery.IsOpened)
  247. // {
  248. // if (SpecialsQuery.GoToRecordByFieldsAndValues(Specials_info.cName, pcSampleName))
  249. // {
  250. // string lcLittleId = SpecialsQuery.GetString(Specials_info.cLittleKindID);
  251. // LittleKind_info loLittleKind = new LittleKind_info(lcLittleId, DBConn);
  252. // lcRetVal = loLittleKind.Name;
  253. // }
  254. // }
  255. // return lcRetVal;
  256. //}
  257. }
  258. public static class CheckCach
  259. {
  260. public static Dictionary<string, string> CheckProjectCach = new Dictionary<string, string>();
  261. public static Dictionary<string, string> CheckItemCach = new Dictionary<string, string>();
  262. public static Dictionary<string, string> CheckMethodCach = new Dictionary<string, string>();
  263. public static Dictionary<string,string> VarietyCategoryCache = new Dictionary<string, string>();
  264. }
  265. }