/// <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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        public static string StdCodeFromCode(string code)
        {
            string errMsg = string.Empty;

            if (code.Equals(string.Empty))
            {
                return(string.Empty);
            }

            try
            {
                string sql = string.Format("SELECT STDCODE FROM TCOMPANY 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);
            }
        }
示例#4
0
        public int GetMaxNO(string prevCode, int lev, out string errMsg)
        {
            errMsg = string.Empty;
            int rtn;

            try
            {
                sb.Length = 0;
                sb.Append("SELECT SYSCODE FROM TCOMPANY WHERE SYSCODE LIKE ");
                sb.Append("'");
                sb.Append(prevCode);
                //sb.Append(StringUtil.RepeatChar('_', lev));
                sb.Append("'");
                sb.Append(" ORDER BY SYSCODE DESC");
                Object o = DataBase.GetOneValue(sb.ToString(), out errMsg);
                sb.Length = 0;
                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);
        }
示例#5
0
        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);
            }
        }
示例#6
0
        /// <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);
        }
示例#7
0
        /// <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>
        /// 通过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);
            }
        }
        /// <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);
            }
        }
示例#10
0
        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);
        }
示例#11
0
        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);
            }
        }
        public int GetMaxNO(out string errMsg)
        {
            errMsg = string.Empty;
            int rtn;

            try
            {
                string sql = "select UserCode from tUserInfo order by UserCode 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>
        /// <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 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="pType"></param>
        /// <returns></returns>
        public DataTable GetParents(out int pType)
        {
            string errMsg = string.Empty;

            pType = 0;
            DataTable dt = null;

            try
            {
                string sql = "SELECT DistrictCode FROM TUSERUNIT ORDER BY SYSCODE";
                object obj = DataBase.GetOneValue(sql, out errMsg);
                if (obj == null)
                {
                    pType = -1;
                }
                else
                {
                    string selectSql = "SELECT Name AS DistrictName,syscode FROM tDistrict WHERE StdCode LIKE '%" + obj.ToString() + "%'";

                    string[] cmd = new string[1] {
                        selectSql
                    };
                    string[] names = new string[1] {
                        "DistrictName"
                    };
                    dt = DataBase.GetDataSet(cmd, names, out errMsg).Tables["DistrictName"];
                }
            }
            catch (Exception e)
            {
                errMsg = e.Message;
            }
            return(dt);
        }
        /// <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);
            }
        }
示例#17
0
        /// <summary>
        /// 获取最大编号
        /// </summary>
        /// <param name="prevCode"></param>
        /// <param name="lev"></param>
        /// <param name="sErrMsg"></param>
        /// <returns></returns>
        public int GetMaxNO(string prevCode, int lev, out string errMsg)
        {
            errMsg = string.Empty;
            int rtn;

            try
            {
                string sql = string.Format("SELECT syscode FROM tResult WHERE syscode LIKE '{0}' ORDER BY SYSCODE DESC", prevCode);
                Object obj = DataBase.GetOneValue(sql, out errMsg);
                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)
            {
                errMsg = e.Message;
                rtn    = -1;
            }

            return(rtn);
        }
示例#18
0
        /// <summary>
        /// 判断是否存在,去掉第二参数,连接字符串。
        /// </summary>
        /// <param name="swhere"></param>
        /// <returns></returns>
        public static bool DistrictIsExist(string swhere)//,string Conncentstr
        {
            string sErrMsg = string.Empty;

            if (swhere.Equals(string.Empty))
            {
                return(false);
            }

            try
            {
                string sql = "SELECT SYSCODE FROM TCOM_DISTRICT WHERE " + swhere;
                Object o   = DataBase.GetOneValue(sql, out sErrMsg);//Conncentstr,
                if (o == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception e)
            {
                sErrMsg = e.Message;
                return(false);
            }
        }
示例#19
0
        /// <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>
        /// 查询指定列的值
        /// </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);
            }
        }
示例#21
0
        /// <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);
            }
        }
        /// <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);
        }
示例#23
0
        /// <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="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 tUserUnit WHERE syscode LIKE '{0}' ORDER BY syscode DESC", code
                                           );
                object obj = DataBase.GetOneValue(sql, out sErrMsg);
                if (obj == null)
                {
                    rtn = 0;
                }
                else
                {
                    string rightStr = obj.ToString().Substring(obj.ToString().Length - lev, lev);
                    rtn = Convert.ToInt32(rightStr);
                }
            }
            catch (Exception e)
            {
                sErrMsg = e.Message;
                rtn     = -1;
            }

            return(rtn);
        }
示例#25
0
        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="code">单位代码</param>
        /// <returns></returns>
        public static string GetNameFromStandarCode(string code)
        {
            string sErrMsg = string.Empty;

            if (code.Equals(string.Empty))
            {
                return(string.Empty);
            }

            try
            {
                string sql = string.Format("SELECT FullName FROM tUserUnit WHERE stdcode='{0}' ORDER BY syscode", code);
                Object obj = DataBase.GetOneValue(sql, out sErrMsg);
                if (obj == null)
                {
                    return(string.Empty);
                }
                else
                {
                    return(obj.ToString());
                }
            }
            catch (Exception e)
            {
                sErrMsg = e.Message;
                return(null);
            }
        }
示例#27
0
        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 tProprietors.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);
            }
        }
        /// <summary>
        /// 获取标准代码
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string GetStdCode(string code)
        {
            string errMsg = string.Empty;

            if (code.Equals(string.Empty))
            {
                return(string.Empty);
            }

            try
            {
                string sql = string.Format("SELECT STDCODE FROM TUSERUNIT WHERE SYSCODE='{0}'", code);
                object obj = DataBase.GetOneValue(sql, out errMsg);
                if (obj == null)
                {
                    return(string.Empty);
                }
                else
                {
                    return(obj.ToString());
                }
            }
            catch (Exception e)
            {
                errMsg = e.Message;
                return(string.Empty);
            }
        }
示例#29
0
        public int GetStdCodeMaxNO(string prevcode, int lev, out string sErrMsg)
        {
            sErrMsg = string.Empty;
            int rtn;

            try
            {
                string sql = "select Stdcode from tStockRecord 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 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);
     }
 }