using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace ConnectPoint { public class QualityHelper { #region 属性 /// /// 服务器IP /// public string dbip { get { return (ConfigurationValues("server_ip", "").Trim() == "" ? ConfigurationValues("dbip", "").Trim() : ConfigurationValues("server_ip", "").Trim()); } } /// /// 数据库端口 /// public string dbport { get { return (ConfigurationValues("server_dbport", "").Trim() == "" ? ConfigurationValues("dbport", "1521").Trim() : ConfigurationValues("server_dbport", "1521").Trim()); } } /// /// 数据库名 /// public string dbname { get { return (ConfigurationValues("server_dbname", "").Trim() == "" ? ConfigurationValues("dbname", "highway_exchange").Trim() : ConfigurationValues("server_dbname", "highway_exchange").Trim()); } } /// /// 数据库用户名 /// public string dbuser { get { return (ConfigurationValues("server_dbuser", "").Trim() == "" ? ConfigurationValues("dbuser", "highway_exchange").Trim() : ConfigurationValues("server_dbuser", "highway_exchange").Trim()); } } /// /// 数据库密码 /// public string dbpass { get { return (ConfigurationValues("server_dbpass", "").Trim() == "" ? ConfigurationValues("dbpass", "qrwl").Trim() : ConfigurationValues("server_dbpass", "qrwl").Trim()); } } /// /// 数据库连接名 /// public string conname { get { return (ConfigurationValues("server_conname", "").Trim() == "" ? ConfigurationValues("conname", "orcl").Trim() : ConfigurationValues("server_conname", "orcl").Trim()); } } /// /// 服务区编码 /// public string serverpartcode { get { return ConfigurationValues("serverpartcode", "").Trim(); } } /// /// 门店编码 /// public string shopcode { get { return ConfigurationValues("shopcode", "").Trim(); } } /// /// 门店内码 /// public string serverpartshop_id { get { return ESSupport.Lib.SyBaseHelper.QueryOdbc("select serverpartshop_id from t_shopmessage where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode + "'").Tables[0].Rows[0][0].ToString(); } } /// /// 门店名称 /// public string shopname { get { return ESSupport.Lib.SyBaseHelper.QueryOdbc("select shopname from t_shopmessage where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode + "'").Tables[0].Rows[0][0].ToString(); } } /// /// 收银机编码 /// public string machinecode { get { return ConfigurationValues("machinecode", "").Trim(); } } /// /// 收银员工号 /// public string sellworkercode { get { return ESSupport.Lib.SyBaseHelper.QueryOdbc("select cashworker_code from t_personsell where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode + "' and machinecode = '" + machinecode + "' and enddate is null " ).Tables[0].Rows[0]["cashworker_code"].ToString(); } } /// /// 收银员姓名 /// public string sellworkername { get { return ESSupport.Lib.SyBaseHelper.QueryOdbc("select sellworkername from t_sellworker where serverpartcode = '" + serverpartcode + "' and sellworkercode = (select cashworker_code from t_personsell where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode + "' and machinecode = '" + machinecode + "' and enddate is null )" ).Tables[0].Rows[0]["sellworkername"].ToString(); } } public string CheckDate { get; set; } /// /// webservice服务端口 /// public string serviceport { get { return ConfigurationValues("service_port", "7080").Trim(); } } public string DataServicePort { get { return ConfigurationValues("DataServicePort", "7080").Trim(); } } public string MobilePayOperators { get { return ConfigurationValues("MobilePayOperators", "1001").Trim(); } } /// /// 打印会员价 /// public string PrintMember { get { return ConfigurationValues("PrintMember", "1").Trim(); } } /// /// 打印方式 /// public string PrintType { get { return ConfigurationValues("PrintType", "1").Trim(); } } /// /// 左边距 /// public string PageLeft { get { return ConfigurationValues("PageLeft", "5").Trim(); } } /// /// 右边距 /// public string PageRight { get { return ConfigurationValues("PageRight", "5").Trim(); } } /// /// 上边距 /// public string PageTop { get { return ConfigurationValues("PageTop", "5").Trim(); } } /// /// 下边距 /// public string PageBottom { get { return ConfigurationValues("PageBottom", "5").Trim(); } } /// /// 设置会员价 /// public string MemberPrice { get { return ConfigurationValues("memberprice", "0").Trim(); } } public string SoftWareName { get { return ConfigurationValues("softwarename", "").Trim(); } } /// /// 授权码 /// public string Authorization { get { return (ConfigurationValues("authorization", "").Trim()); } } #endregion #region 获取配置信息 /// /// 获取配置信息 /// /// 配置名称 /// 无配置信息时默认值 /// public string ConfigurationValues(string ConfigurationName, string defaultValue) { string strSQL = "select configuration_name,configuration_values from dba.t_configuration where lower(configuration_name) = lcase('" + ConfigurationName + "')"; string strValues = ""; try { using (DataTable _DataTable = ESSupport.Lib.SyBaseHelper.QueryOdbc(strSQL).Tables[0]) { if (_DataTable.Rows.Count > 0) { foreach (DataRow row in _DataTable.Rows) { if (row["configuration_name"].ToString().ToLower() == ConfigurationName.ToLower()) { strValues = row["configuration_values"].ToString(); } } } else { strValues = ConfigHelper.Win32API.INIGetStringValue(Environment.CurrentDirectory + "\\setup.ini", "DBCONECT", ConfigurationName, defaultValue); if (strValues == "") strValues = ConfigHelper.Win32API.INIGetStringValue(Environment.CurrentDirectory + "\\set.ini", "DBCONECT", ConfigurationName, defaultValue); } } } catch { strValues = defaultValue; } return strValues; } #endregion #region 修改本地配置信息 /// /// 更新本地配置信息 /// /// 配置名称shopcode /// 配置内容 /// public bool UpdateConfiguration(string Configuration_Name, string configuration_Values) { string strsql = "select 1 from t_configuration where lower(configuration_name) = lcase('" + Configuration_Name + "')"; if (DBHelper.QueryOdbc(strsql).Tables[0].Rows.Count == 0) { decimal maxid = 0; try { maxid = decimal.Parse(ESSupport.Lib.SyBaseHelper.QueryOdbc("select max(configuration_id) from t_configuration").Tables[0].Rows[0][0].ToString()); } catch (Exception ex) { maxid = 0; } strsql = "insert into t_configuration(configuration_id, configuration_date, configuration_name, configuration_values)values(" + (maxid + 1) + ", now(),'" + Configuration_Name + "','" + configuration_Values + "')"; try { ESSupport.Lib.SyBaseHelper.ExecuteSqlTran(strsql); return true; } catch (Exception ex) { return false; } } else { strsql = "update t_configuration set configuration_values = '" + configuration_Values + "' where lower(configuration_name) = lcase('" + Configuration_Name + "')"; try { ESSupport.Lib.SyBaseHelper.ExecuteSqlTran(strsql); return true; } catch (Exception ex) { return false; } } } #endregion } }