123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using SysDataLibs;
- using SysDataLibs.TableClass ;
- using System.Data ;
- using SysBaseLibs;
- namespace DataTransfersLibs
- {
-
- public class CheckDataTrans : Sys_Users_info
- {
- public CheckDataTrans(DataRow poRow, DBConnSql poDBConn)
- : base(poRow)
- {
- if (poRow != null && poDBConn != null && poDBConn.IsOpened )
- {
- _DBConn = poDBConn;
- if (this.IsMarketSys)
- {
- string lcSql = "select * from vwUserHasAllMarkets where UserId='" + this.UserID + "'";
- rsQuery loQuery = _DBConn.OpenQuery(lcSql);
- if (loQuery != null && loQuery.IsOpened && loQuery.RecCount > 0)
- {
- loQuery.MoveFirst();
- _MarketId = loQuery.GetString("MarketID");
- }
- }
- }
- }
- private DBConnSql _DBConn = null;
- public DBConnSql DBConn
- {
- get { return _DBConn; }
- }
- string _MarketId = "";
- public string MarketId
- {
- get { return _MarketId; }
- }
-
- rsQuery _CheckProTypes = null;
- private rsQuery CheckProTypes
- {
- get
- {
- if (_CheckProTypes == null || !_CheckProTypes.IsOpened)
- {
- string lcSql = " select * from CheckProjectType ";
- _CheckProTypes = _DBConn.OpenQuery(lcSql);
- }
- return _CheckProTypes;
- }
- }
- rsQuery _CheckItems = null;
- private rsQuery CheckItems
- {
- get
- {
- if (_CheckItems == null || !_CheckItems.IsOpened)
- {
- string lcSql = " select * from CheckItem";
- _CheckItems = _DBConn.OpenQuery(lcSql);
- }
- return _CheckItems;
- }
- }
- rsQuery _CheckMethods = null;
- private rsQuery CheckMethods
- {
- get
- {
- if (_CheckMethods == null || !_CheckMethods.IsOpened)
- {
- string lcSql = " select * from CheckMethod";
- _CheckMethods = _DBConn.OpenQuery(lcSql);
- }
- return _CheckMethods;
- }
- }
- rsQuery _HabitQuery = null;
- private rsQuery HabitQuery
- {
- get
- {
- if (_HabitQuery == null || !_HabitQuery.IsOpened)
- {
- string lcSql = "select " + Habitat_info.cHabitatID + "," + Habitat_info.cNames + " from " + Tn.Habitat;
- _HabitQuery = _DBConn.OpenQuery(lcSql);
- }
- return _HabitQuery;
- }
- }
- rsQuery _SpecialsQuery = null;
- private rsQuery SpecialsQuery
- {
- get
- {
- if (_SpecialsQuery == null || !_SpecialsQuery.IsOpened)
- {
- string lcSql = "select * from " + Tn.Specials;
- _SpecialsQuery = _DBConn.OpenQuery(lcSql);
- }
- return _SpecialsQuery;
- }
- }
- rsQuery _VarietyCategoryQuery = null;
- private rsQuery VarietyCategoryQuery
- {
- get
- {
- if (_VarietyCategoryQuery == null || !_VarietyCategoryQuery.IsOpened)
- {
- string lcSql = "select * from " + Tn.VarietyCategory;
- _VarietyCategoryQuery = _DBConn.OpenQuery(lcSql);
- }
- return _VarietyCategoryQuery;
- }
- }
- public string GetCheckProTypeIDByItemAndMothed(string pcItem, string pcMothed, string pcValueField)
- {
- string lcRetVal = "";
- var lcItem = TransCheckItem(pcItem);
- var lcMothed = TransCheckMothed(pcMothed);
- if (CheckCach.CheckProjectCach.ContainsKey(lcItem + "_" + lcMothed))
- {
- lcRetVal = CheckCach.CheckProjectCach[lcItem + "_" + lcMothed];
- return lcRetVal;
- }
- if (lcItem != null && lcMothed != null&& CheckProTypes != null && CheckProTypes.IsOpened)
- {
- if (CheckProTypes.GoToRecordByFieldsAndValues(CheckProjectType_info.cCheckItemId + "," + CheckProjectType_info.cCheckMethodId, lcItem + "," + lcMothed))
- {
- lcRetVal = CheckProTypes.GetString(pcValueField);
- }
- else if (CheckProTypes.GoToRecordByFieldsAndValues(CheckProjectType_info.cCheckItemId, lcItem))
- {
- lcRetVal = CheckProTypes.GetString(pcValueField);
- }
- }
- if (!string.IsNullOrEmpty(lcRetVal))
- {
- CheckCach.CheckProjectCach.Add(lcItem+"_"+ lcMothed,lcRetVal);
- }
- return lcRetVal;
- }
- public string GetHabitIdByHabitName(string pcHabitName)
- {
- string lcRetVal = "";
- if (HabitQuery != null && HabitQuery.IsOpened)
- {
- if (HabitQuery.GoToRecordByFieldsAndValues(Habitat_info.cNames, pcHabitName))
- {
- return CheckProTypes.GetString(Habitat_info.cHabitatID);
- }
- }
- return lcRetVal;
- }
- public string TransResult(string pcValue)
- {
- pcValue = UtilStr.UAndT(pcValue);
- if (pcValue == "1" || pcValue == "合格")
- {
- return "合格";
- }
- else
- {
- return "不合格";
- }
- }
- public string TransCheckMothed(string pcValue)
- {
- string lcRetVal = null;
- if (pcValue == "速测法" || pcValue == "检测卡")
- {
- pcValue = "速测灵";
- }
- if (pcValue == "检测仪")
- {
- pcValue = "速测仪";
- }
- if (CheckCach.CheckMethodCach.ContainsKey(pcValue))
- {
- lcRetVal = CheckCach.CheckMethodCach[pcValue];
- return lcRetVal;
- }
- if (CheckMethods.GoToRecordByFieldsAndValues(CheckMethod_info.cCheckMethodName, pcValue))
- {
- lcRetVal = CheckMethods.GetString(CheckMethod_info.cCheckMethodId);
- }
- if (!string.IsNullOrEmpty(lcRetVal))
- {
- CheckCach.CheckMethodCach.Add(pcValue, lcRetVal);
- }
- return lcRetVal;
- }
- public string TransCheckItem(string pcValue)
- {
- string lcRetVal = null;
- if (pcValue == "残留农药")
- {
- pcValue = "农药残留";
- }
- if (CheckCach.CheckItemCach.ContainsKey(pcValue))
- {
- lcRetVal = CheckCach.CheckItemCach[pcValue];
- return lcRetVal;
- }
- if (CheckItems.GoToRecordByFieldsAndValues(CheckItem_info.cCheckItemName, pcValue))
- {
- lcRetVal = CheckItems.GetString(CheckItem_info.cCheckItemId);
- }
- if (!string.IsNullOrEmpty(lcRetVal))
- {
- CheckCach.CheckItemCach.Add(pcValue, lcRetVal);
- }
- return lcRetVal;
- }
- public string GetSampleNo(string pcSampleName)
- {
- string lcRetVal = "";
- //if (SpecialsQuery != null && SpecialsQuery.IsOpened)
- //{
- // if (SpecialsQuery.GoToRecordByFieldsAndValues(Specials_info.cName, pcSampleName))
- // {
- // lcRetVal = SpecialsQuery.GetString(Specials_info.cName);
- // }
- //}
- if (CheckCach.VarietyCategoryCache.ContainsKey(pcSampleName))
- {
- lcRetVal = CheckCach.VarietyCategoryCache[pcSampleName];
- return lcRetVal;
- }
- if (VarietyCategoryQuery.GoToRecordByFieldsAndValues(VarietyCategory_info.cVarietyCategoryName,
- pcSampleName))
- {
- lcRetVal = VarietyCategoryQuery.GetString(VarietyCategory_info.cVarietyCategoryNo);
- }
- if (!string.IsNullOrEmpty(lcRetVal))
- {
- CheckCach.VarietyCategoryCache.Add(pcSampleName, lcRetVal);
- }
- return lcRetVal;
- }
- //public string GetLittleKindName(string pcSampleName)
- //{
- // string lcRetVal = "";
- // if (SpecialsQuery != null && SpecialsQuery.IsOpened)
- // {
- // if (SpecialsQuery.GoToRecordByFieldsAndValues(Specials_info.cName, pcSampleName))
- // {
- // string lcLittleId = SpecialsQuery.GetString(Specials_info.cLittleKindID);
- // LittleKind_info loLittleKind = new LittleKind_info(lcLittleId, DBConn);
- // lcRetVal = loLittleKind.Name;
- // }
- // }
- // return lcRetVal;
- //}
- }
- public static class CheckCach
- {
- public static Dictionary<string, string> CheckProjectCach = new Dictionary<string, string>();
- public static Dictionary<string, string> CheckItemCach = new Dictionary<string, string>();
- public static Dictionary<string, string> CheckMethodCach = new Dictionary<string, string>();
- public static Dictionary<string,string> VarietyCategoryCache = new Dictionary<string, string>();
- }
- }
|