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 CheckProjectCach = new Dictionary(); public static Dictionary CheckItemCach = new Dictionary(); public static Dictionary CheckMethodCach = new Dictionary(); public static Dictionary VarietyCategoryCache = new Dictionary(); } }