using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace InvoicingTool { 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 { try { return DBHelper.QueryOdbc("select serverpartshop_id from t_shopmessage where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode + "'").Tables[0].Rows[0][0].ToString(); } catch { return ""; } } } /// /// 门店名称 /// public string shopname { get { try { return DBHelper.QueryOdbc("select shopname from t_shopmessage where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode + "'").Tables[0].Rows[0][0].ToString(); } catch { return ""; } } } /// /// 收银机编码 /// public string machinecode { get { return ConfigUrationValues("machinecode", "").Trim(); } } /// /// 收银员工号 /// public string sellworkercode { get { try { return DBHelper.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(); } catch { return ""; } } } /// /// 收银员姓名 /// public string sellworkername { get { try { return DBHelper.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(); } catch { return ""; } } } /// /// webservice服务端口 /// public string serviceport { get { return (ConfigUrationValues("service_port", "7080").Trim()); } } public string CheckDate { get; set; } /// /// 打印会员价 /// public string PrintMember { get { return ConfigUrationValues("PrintMember", "1").Trim(); } } /// /// 打印条形码 /// public string PrintBarcode { get { return ConfigUrationValues("PrintBarcode", "1").Trim(); } } /// /// 打印字体大小 /// public string PrintSize { get { return ConfigUrationValues("PrintSize", "10号").Trim(); } } /// /// 打印方式 /// public string PrintType { get { return ConfigUrationValues("PrintType", "1").Trim(); } } /// /// 双列左边距 /// public string PageLeft { get { return ConfigUrationValues("PageLeft", "0").Trim(); } } /// /// 双列右边距 /// public string PageRight { get { return ConfigUrationValues("PageRight", "0").Trim(); } } /// /// 双列上边距 /// public string PageTop { get { return ConfigUrationValues("PageTop", "0").Trim(); } } /// /// 双列下边距 /// public string PageBottom { get { return ConfigUrationValues("PageBottom", "0").Trim(); } } /// /// 单列左边距 /// public string PageLeftI { get { return ConfigUrationValues("PageLeftI", "0").Trim(); } } /// /// 单列右边距 /// public string PageRightI { get { return ConfigUrationValues("PageRightI", "0").Trim(); } } /// /// 单列上边距 /// public string PageTopI { get { return ConfigUrationValues("PageTopI", "0").Trim(); } } /// /// 单列下边距 /// public string PageBottomI { get { return ConfigUrationValues("PageBottomI", "0").Trim(); } } /// /// 管理进货价及库存 /// public string StockPrice { get { return ConfigUrationValues("StockPrice", "0").Trim(); } } /// /// 商品快捷键 /// public string FastKey { get { return ConfigUrationValues("FastKey", "0").Trim(); } } /// /// 设置会员价 /// public string MemberPrice { get { return ConfigUrationValues("memberprice", "0").Trim(); } } /// /// 进销存模式:1:在线;0:离线; /// public string OnLine { get { return ConfigUrationValues("online", "0").Trim(); } } #endregion #region 获取配置信息 /// /// 获取配置信息 /// /// 配置名称 /// 无配置信息时默认值 /// private 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 = DBHelper.QueryOdbc(strSQL).Tables[0]) { if (_DataTable.Rows.Count > 0) { foreach (DataRow row in _DataTable.Rows) { if (row["configuration_name"].ToString() == ConfigUrationName) { 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(DBHelper.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 { DBHelper.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 { DBHelper.ExecuteSqlTran(strsql); return true; } catch (Exception ex) { return false; } } } #endregion } }