2025-03-28 09:49:56 +08:00

293 lines
11 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace InvoicingTool
{
public class QualityHelper
{
#region
/// <summary>
/// 服务器IP
/// </summary>
public string dbip { get { return (ConfigUrationValues("server_ip", "").Trim() == "" ? ConfigUrationValues("dbip", "").Trim() : ConfigUrationValues("server_ip", "").Trim()); } }
/// <summary>
/// 数据库端口
/// </summary>
public string dbport { get { return (ConfigUrationValues("server_dbport", "").Trim() == "" ? ConfigUrationValues("dbport", "1521").Trim() : ConfigUrationValues("server_dbport", "1521").Trim()); } }
/// <summary>
/// 数据库名
/// </summary>
public string dbname { get { return (ConfigUrationValues("server_dbname", "").Trim() == "" ? ConfigUrationValues("dbname", "highway_exchange").Trim() : ConfigUrationValues("server_dbname", "highway_exchange").Trim()); } }
/// <summary>
/// 数据库用户名
/// </summary>
public string dbuser { get { return (ConfigUrationValues("server_dbuser", "").Trim() == "" ? ConfigUrationValues("dbuser", "highway_exchange").Trim() : ConfigUrationValues("server_dbuser", "highway_exchange").Trim()); } }
/// <summary>
/// 数据库密码
/// </summary>
public string dbpass { get { return (ConfigUrationValues("server_dbpass", "").Trim() == "" ? ConfigUrationValues("dbpass", "qrwl").Trim() : ConfigUrationValues("server_dbpass", "qrwl").Trim()); } }
/// <summary>
/// 数据库连接名
/// </summary>
public string conname { get { return (ConfigUrationValues("server_conname", "").Trim() == "" ? ConfigUrationValues("conname", "orcl").Trim() : ConfigUrationValues("server_conname", "orcl").Trim()); } }
/// <summary>
/// 服务区编码
/// </summary>
public string serverpartcode { get { return ConfigUrationValues("serverpartcode", "").Trim(); } }
/// <summary>
/// 门店编码
/// </summary>
public string shopcode { get { return ConfigUrationValues("shopcode", "").Trim(); } }
/// <summary>
/// 门店内码
/// </summary>
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 "";
}
}
}
/// <summary>
/// 门店名称
/// </summary>
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 "";
}
}
}
/// <summary>
/// 收银机编码
/// </summary>
public string machinecode { get { return ConfigUrationValues("machinecode", "").Trim(); } }
/// <summary>
/// 收银员工号
/// </summary>
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 "";
}
}
}
/// <summary>
/// 收银员姓名
/// </summary>
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 "";
}
}
}
/// <summary>
/// webservice服务端口
/// </summary>
public string serviceport { get { return (ConfigUrationValues("service_port", "7080").Trim()); } }
public string CheckDate { get; set; }
/// <summary>
/// 打印会员价
/// </summary>
public string PrintMember { get { return ConfigUrationValues("PrintMember", "1").Trim(); } }
/// <summary>
/// 打印条形码
/// </summary>
public string PrintBarcode { get { return ConfigUrationValues("PrintBarcode", "1").Trim(); } }
/// <summary>
/// 打印字体大小
/// </summary>
public string PrintSize { get { return ConfigUrationValues("PrintSize", "10号").Trim(); } }
/// <summary>
/// 打印方式
/// </summary>
public string PrintType { get { return ConfigUrationValues("PrintType", "1").Trim(); } }
/// <summary>
/// 双列左边距
/// </summary>
public string PageLeft { get { return ConfigUrationValues("PageLeft", "0").Trim(); } }
/// <summary>
/// 双列右边距
/// </summary>
public string PageRight { get { return ConfigUrationValues("PageRight", "0").Trim(); } }
/// <summary>
/// 双列上边距
/// </summary>
public string PageTop { get { return ConfigUrationValues("PageTop", "0").Trim(); } }
/// <summary>
/// 双列下边距
/// </summary>
public string PageBottom { get { return ConfigUrationValues("PageBottom", "0").Trim(); } }
/// <summary>
/// 单列左边距
/// </summary>
public string PageLeftI { get { return ConfigUrationValues("PageLeftI", "0").Trim(); } }
/// <summary>
/// 单列右边距
/// </summary>
public string PageRightI { get { return ConfigUrationValues("PageRightI", "0").Trim(); } }
/// <summary>
/// 单列上边距
/// </summary>
public string PageTopI { get { return ConfigUrationValues("PageTopI", "0").Trim(); } }
/// <summary>
/// 单列下边距
/// </summary>
public string PageBottomI { get { return ConfigUrationValues("PageBottomI", "0").Trim(); } }
/// <summary>
/// 管理进货价及库存
/// </summary>
public string StockPrice { get { return ConfigUrationValues("StockPrice", "0").Trim(); } }
/// <summary>
/// 商品快捷键
/// </summary>
public string FastKey { get { return ConfigUrationValues("FastKey", "0").Trim(); } }
/// <summary>
/// 设置会员价
/// </summary>
public string MemberPrice { get { return ConfigUrationValues("memberprice", "0").Trim(); } }
/// <summary>
/// 进销存模式1在线0离线
/// </summary>
public string OnLine { get { return ConfigUrationValues("online", "0").Trim(); } }
#endregion
#region
/// <summary>
/// 获取配置信息
/// </summary>
/// <param name="ConfigUrationName">配置名称</param>
/// <param name="defaultValue">无配置信息时默认值</param>
/// <returns></returns>
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
/// <summary>
/// 更新本地配置信息
/// </summary>
/// <param name="ConfigUration_Name">配置名称</param>shopcode
/// <param name="ConfigUration_Values">配置内容</param>
/// <returns></returns>
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
}
}