public static bool ExistCheckItem(string precode, string code, string checkcode, out string sErrMsg) { try { string sql = "SELECT Count(*) From tFoodClass Where SysCode Like '" + precode + "' And SysCode<>'" + code + "' And CheckItemCodes Like '%{" + checkcode + ":%}%'"; Object o = DataBase.GetOneValue(sql, out sErrMsg); if (o == null) { return(false); } else { if (Convert.ToInt32(o.ToString()) >= 1) { return(true); } else { return(false); } } } catch (Exception e) { sErrMsg = e.Message; return(false); } }
/// <summary> /// 通过代码获取名称 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string NameFromCode(string code) { string errMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("SELECT NAME FROM TPRODUCEAREA WHERE SYSCODE='{0}' ORDER BY SYSCODE", code); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { errMsg = e.Message; return(null); } }
public static string GetCompanyName(string name) { string errMsg = string.Empty; if (name.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("SELECT Cdname FROM tProprietors WHERE Cdname='{0}' ORDER BY Cdname", name); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { errMsg = e.Message; return(null); } }
/// <summary> /// 查询指定列的值 /// </summary> /// <param name="sFind"></param> /// <param name="code"></param> /// <returns></returns> public static string GetNameFromCode(string sFind, string code) { string sErrMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("SELECT {0} FROM tMachine WHERE syscode='{1}' order by syscode", sFind, code); Object obj = DataBase.GetOneValue(sql, out sErrMsg); if (obj == null || obj == DBNull.Value) { return(string.Empty); } else { return(obj.ToString()); } } catch (Exception e) { sErrMsg = e.Message; return(null); } }
/// <summary> /// 通过代码获取名称 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string NameFromCode(string code) { if (string.IsNullOrEmpty(code)) { return(string.Empty); } string errMsg = string.Empty; try { string sql = string.Format("SELECT CPTITLE FROM tTask WHERE CPCODE='{0}' ORDER BY CPCODE", code); Object obj = DataBase.GetOneValue(sql, out errMsg); if (obj == null || obj == DBNull.Value) { return(string.Empty); } else { return(obj.ToString()); } } catch (Exception e) { errMsg = e.Message; return(null); } }
/// <summary> /// 获取最大编码 /// </summary> /// <param name="code"></param> /// <param name="lev"></param> /// <param name="sErrMsg"></param> /// <returns></returns> public int GetMaxNO(string code, int lev, out string sErrMsg) { sErrMsg = string.Empty; int rtn; try { string sql = string.Format("SELECT SYSCODE FROM TPRODUCEAREA WHERE SYSCODE LIKE '{0}' ORDER BY SYSCODE DESC", code ); Object obj = DataBase.GetOneValue(sql, out sErrMsg); if (obj == null) { rtn = 0; } else { string temp = obj.ToString(); string rightStr = temp.Substring(temp.Length - lev, lev); rtn = Convert.ToInt32(rightStr); } } catch (Exception e) { sErrMsg = e.Message; rtn = -1; } return(rtn); }
public int GetRecCount(string whereSql, out string sErrMsg) { sErrMsg = string.Empty; int rtn; try { string sql = "select Count(*) from tSaleRecord"; if (!whereSql.Equals(string.Empty)) { sql += " where " + whereSql; } Object o = DataBase.GetOneValue(sql, out sErrMsg); if (o == null) { rtn = 0; } else { rtn = Convert.ToInt32(o); } } catch (Exception e) { sErrMsg = e.Message; rtn = -1; } return(rtn); }
/// <summary> /// 获取检测记录数 /// </summary> /// <param name="strWhere"></param> /// <param name="errMsg"></param> /// <returns></returns> public int GetRecCount(string strWhere, out string errMsg) { errMsg = string.Empty; int rtn; try { sb.Length = 0; sb.Append("SELECT COUNT(*) FROM TRESULT"); if (!strWhere.Equals(string.Empty)) { sb.Append(" WHERE "); sb.Append(strWhere); } Object obj = DataBase.GetOneValue(sb.ToString(), out errMsg); sb.Length = 0; if (obj == null) { rtn = 0; } else { rtn = Convert.ToInt32(obj); } } catch (Exception e) { errMsg = e.Message; rtn = -1; } return(rtn); }
/// <summary> /// 通过fullname获取门牌号 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string TxtCiidInfo(string code) { string errMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("select displayname from ( Select fullname,syscode,displayname from tCompany union select Cdname,Ciid,DisplayName from tProprietors where fullname='{0}') ", code); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { errMsg = e.Message; return(null); } }
/// <summary> /// 通过食品类别获取检测项目编号 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string CheckItemsFromCode(string code) { string sErrMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("select CheckItemCodes from tFoodClass where syscode='{0}' order by syscode", code); Object o = DataBase.GetOneValue(sql, out sErrMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { sErrMsg = e.Message; return(null); } }
public int GetStdCodeMaxNO(string prevCode, int lev, out string errMsg) { errMsg = string.Empty; int rtn; try { sb.Length = 0; sb.Append("SELECT Stdcode FROM TCOMPANY WHERE SYSCODE LIKE "); sb.Append("'"); sb.Append(prevCode); sb.Append("'"); sb.Append(" ORDER BY Stdcode DESC"); Object o = DataBase.GetOneValue(sb.ToString(), out errMsg); sb.Length = 0; if (o == null) { rtn = 0; } else { string rightString = o.ToString().Substring(o.ToString().Length - lev, lev); rtn = Convert.ToInt32(rightString); } } catch (Exception e) { errMsg = e.Message; rtn = -1; } return(rtn); }
/// <summary> /// 通过ID获取名称 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string NameFromCode(string code) { string errMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("SELECT CompanyID FROM TCOMPANY WHERE FULLNAME='{0}' ", code); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { errMsg = e.Message; return(null); } }
public static string InfoFromCode(string code) { string errMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("SELECT TCOMPANYKIND.NAME FROM TCOMPANY,TCOMPANYKIND WHERE tCompany.syscode='{0}' AND TCOMPANY.KINDCODE=TCOMPANYKIND.SYSCODE ORDER BY TCOMPANY.SYSCODE", code); object o = DataBase.GetOneValue(sql, out errMsg); if (o != null) { return(o.ToString()); } else { return(string.Empty); } } catch (Exception e) { errMsg = e.Message; return(null); } }
public static bool CompanyIsExist(string swhere) { string errMsg = string.Empty; if (swhere.Equals(string.Empty)) { return(false); } try { string sql = string.Format("SELECT SYSCODE FROM TCOMPANY WHERE {0}", swhere); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return(false); } else { return(true); } } catch (Exception e) { errMsg = e.Message; return(false); } }
/// <summary> /// 默认的仪器列表数 /// </summary> /// <param name="sErrMsg"></param> /// <returns></returns> public static int GetRecCount(out string sErrMsg) { sErrMsg = string.Empty; int rtn = 0; try { string sql = "SELECT Count(*) FROM tMachine WHERE IsSupport=True"; Object obj = DataBase.GetOneValue(sql, out sErrMsg); if (obj == null || obj == DBNull.Value) { rtn = 0; } else { rtn = Convert.ToInt32(obj); } } catch (Exception e) { sErrMsg = e.Message; rtn = -1; } return(rtn); }
/// <summary> /// 判断是否存在相同的名称 /// </summary> /// <param name="name"></param> /// <param name="stdCode"></param> /// <param name="sysCode"></param> /// <returns></returns> public bool ExistSameValue(string name, string stdCode, string sysCode) { string errMsg = string.Empty; try { string sql = string.Empty; if (sysCode.Equals(string.Empty)) { sql = string.Format("SELECT Name FROM tfoodclass WHERE Name='{0} ' Or StdCode='{1}'", name, stdCode); } else { sql = string.Format("SELECT Name FROM tfoodclass WHERE (Name='{0}' Or StdCode='{1}') And SysCode<>'{1}'", name, stdCode); } Object obj = DataBase.GetOneValue(sql, out errMsg); if (obj == null) { return(false); } else { return(true); } } catch (Exception e) { errMsg = e.Message; return(true); } }
/// <summary> /// 通过fullname获取名称 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string Namefullname(string code) { string errMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("select fullname from (select fullname,syscode from tCompany union Select Cdname,Ciid from tProprietors ) as T WHERE fullname='{0}' ", code); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { errMsg = e.Message; return(null); } }
public string GetPreCheckItemCodes(string code, out string errMsg) { errMsg = string.Empty; string rtn = string.Empty; try { string sql = string.Format("select CheckItemCodes from tFoodClass where syscode = '{0}' order by syscode desc", code); Object obj = DataBase.GetOneValue(sql, out errMsg); if (obj == null) { rtn = string.Empty; } else { rtn = obj.ToString(); } } catch (Exception e) { errMsg = e.Message; rtn = string.Empty; } return(rtn); }
/// <summary> /// 标准编码获取名称 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string NameFromStdCode(string code) { string sErrMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("SELECT FULLNAME FROM TCOMPANY WHERE STDCODE='{0}' ORDER BY STDCODE", code); Object o = DataBase.GetOneValue(sql, out sErrMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { sErrMsg = e.Message; return(null); } }
public int GetStdCodeMaxNO(string prevcode, int lev, out string sErrMsg) { sErrMsg = string.Empty; int rtn; try { string sql = "select Stdcode from tSaleRecord where Stdcode like '" + prevcode + "' order by Stdcode desc"; Object o = DataBase.GetOneValue(sql, out sErrMsg); if (o == null) { rtn = 0; } else { string rightStr = o.ToString().Substring(o.ToString().Length - lev, lev); rtn = Convert.ToInt32(rightStr); } } catch (Exception e) { sErrMsg = e.Message; rtn = -1; } return(rtn); }
public static string GetCompanyCode(string name) { string errMsg = string.Empty; if (name.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("SELECT SysCode FROM TCOMPANY WHERE FULLNAME='{0}' ORDER BY SYSCODE", name); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { errMsg = e.Message; return(null); } }
/// <summary> /// 查询是否已经发送过的 /// </summary> /// <param name="sysCode"></param> /// <param name="errMsg"></param> /// <returns></returns> public static bool QueryIsSend(string sysCode, out string errMsg) { errMsg = string.Empty; bool rtn = false; try { string querySql = string.Format("SELECT IsSended FROM tResult where SysCode='{0}' ", sysCode); object obj = DataBase.GetOneValue(querySql, out errMsg); if (obj == null) { rtn = false; } else { rtn = Convert.ToBoolean(obj); } } catch (Exception e) { //Log.WriteLog("更新clsResult",e); errMsg = e.Message; } return(rtn); }
/// <summary> /// 获取最大编号 /// </summary> /// <param name="errMsg"></param> /// <returns></returns> public int GetMaxNO(out string errMsg) { errMsg = string.Empty; int rtn; try { string sql = "SELECT SYSCODE FROM TSTANDARD ORDER BY SYSCODE DESC"; Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { rtn = 0; } else { rtn = Convert.ToInt32(o.ToString()); } } catch (Exception e) { errMsg = e.Message; rtn = -1; } return(rtn); }
/// <summary> /// 获取最大值 /// </summary> /// <param name="code"></param> /// <param name="lev"></param> /// <param name="errMsg"></param> /// <returns></returns> public int GetMaxNO(string code, int lev, out string errMsg) { errMsg = string.Empty; int rtn; try { string sql = string.Format("SELECT CPCODE FROM tTask WHERE CPCODE LIKE '{0}' ORDER BY CPCODE DESC", code); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { rtn = 0; } else { string rightStr = o.ToString().Substring(o.ToString().Length - lev, lev); rtn = Convert.ToInt32(rightStr); } } catch (Exception e) { errMsg = e.Message; rtn = -1; } return(rtn); }
/// <summary> /// 通过代码获取名称 /// </summary> /// <param name="code"></param> /// <returns></returns> public static string GetNameFromCode(string code) { string errMsg = string.Empty; if (string.IsNullOrEmpty(code)) { return(string.Empty); } try { string sql = string.Format("SELECT STDDES FROM TSTANDARD WHERE SYSCODE='{0}' ORDER BY SYSCODE", code); object obj = DataBase.GetOneValue(sql, out errMsg); if (obj == null || obj == DBNull.Value) { return(string.Empty); } else { return(obj.ToString()); } } catch (Exception e) { errMsg = e.Message; return(string.Empty); } }
public bool CanDelete(string code) { string sErrMsg = string.Empty; try { string sql = string.Format("SELECT TPRODUCEAREA.SYSCODE FROM TPRODUCEAREA,TCOMPANY WHERE tProduceArea.SysCode=tCompany.DistrictCode AND tProduceArea.syscode='{0}' ORDER BY TPRODUCEAREA.SYSCODE DESC", code); Object o = DataBase.GetOneValue(sql, out sErrMsg); //sql="select tProduceArea.syscode from tProduceArea,tUserUnit" // + " where tProduceArea.SysCode=tUserUnit.CheckItemCode and tProduceArea.syscode='" + code // + "' order by tProduceArea.syscode desc"; sql = string.Format("SELECT TPRODUCEAREA.SYSCODE FROM tProduceArea,tUserUnit where tProduceArea.SysCode=tUserUnit.SysCode and tProduceArea.syscode='{0}' ORDER BY TPRODUCEAREA.SYSCODE DESC", code); Object o2 = DataBase.GetOneValue(sql, out sErrMsg); if (o == null && o2 == null) { return(true); } else { return(false); } } catch (Exception e) { sErrMsg = e.Message; return(false); } }
/// <summary> /// 获取DisplayName /// </summary> /// <param name="code"></param> /// <returns></returns> public static string CiidNameFromCode(string code) { string errMsg = string.Empty; if (code.Equals(string.Empty)) { return(string.Empty); } try { string sql = string.Format("Select Ciname from tProprietors where cdname='{0}'", code); Object o = DataBase.GetOneValue(sql, out errMsg); if (o == null) { return(string.Empty); } else { return(o.ToString()); } } catch (Exception e) { errMsg = e.Message; return(null); } }
/// <summary> /// 判断是否在 /// </summary> /// <param name="sysCode"></param> /// <returns></returns> public bool IsExists(string sysCode) { string sErr = string.Empty; int ret = 0; string cmdText = string.Format("SELECT COUNT(SysCode) FROM tMachine WHERE SysCode='{0}'", sysCode); object obj = DataBase.GetOneValue(cmdText, out sErr); if (obj != null && obj != DBNull.Value) { ret = Convert.ToInt32(obj); } return(ret != 0); }
/// <summary> /// 检测是否存某个条件的记录 /// </summary> /// <param name="strWhere">查询条件</param> /// <returns></returns> public bool IsExist(string strWhere) { StringBuilder sb = new StringBuilder(); sb.Append("SELECT COUNT(1) FROM tHolesSetting "); if (strWhere != null && strWhere.Length > 0) { sb.Append(" WHERE "); sb.Append(strWhere); } string errMsg = string.Empty; object obj = DataBase.GetOneValue(sb.ToString(), out errMsg); if (obj != null && obj != DBNull.Value) { return(((int)obj) > 0); } return(false); }
public static void DelCheckItem(string code, string checkcode, out string sErrMsg) { try { string pattern = @"({" + checkcode + @":[\S\t]*?})"; Regex r = new Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase); string strResult = string.Empty; string sql = string.Format("SELECT CheckItemCodes From tFoodClass Where SysCode='{0}'", code); Object obj = DataBase.GetOneValue(sql, out sErrMsg); if (obj != null) { strResult = r.Replace(obj.ToString(), string.Empty); sql = string.Format("UPDATE tFoodClass Set CheckItemCodes='{0}' Where SysCode='{1}'", strResult, code); DataBase.ExecuteCommand(sql, out sErrMsg); } } catch (Exception e) { sErrMsg = e.Message; } }