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

1201 lines
64 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.Data.Odbc;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Threading;
using System.Web;
using System.Windows;
using System.Windows.Forms;
using ZXing;
using ZXing.Common;
using ZXing.QrCode.Internal;
namespace DataUpdate
{
public partial class DataUpdate : Form
{
//EncodingOptions options = null;
//BarcodeWriter writer = null;
//调用API
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern IntPtr GetForegroundWindow(); //获得本窗体的句柄
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);//设置此窗体为活动窗体
public static string _type;
public static decimal days = -3;
public string serverpartcode { get { return ConfigUrationValues("serverpartcode", "").Trim(); } }
public string shopcode { get { return ConfigUrationValues("shopcode", "").Trim(); } }
public string machinecode { get { return ConfigUrationValues("machinecode", "").Trim(); } }
/// <summary>
/// 服务器IP
/// </summary>
public string dbip { get { return ConfigUrationValues("server_ip", "").Trim() == "" ? ConfigUrationValues("dbip", "").Trim() : ConfigUrationValues("server_ip", "").Trim(); } }
/// <summary>
/// webservice服务端口
/// </summary>
public string serviceport { get { return ConfigUrationValues("service_port", "7080").Trim(); } }
Thread UpLoadThread;
public DataUpdate(string[] type)
{
InitializeComponent();
WindowState = FormWindowState.Normal;
Width = 1;
Height = 1;
//_type = type[0];
//QRCodeThread();
//TimerHandle.Interval = 1000;
//TimerHandle.Start();
}
string checkcode;
DataTable DataList { get; set; }
DataTable UploadTable { get; set; }
private void TimerHandle_Tick(object sender, EventArgs e)
{
if (Handle != GetForegroundWindow()) //持续使该窗体置为最前,屏蔽该行则单次置顶
{
SetForegroundWindow(Handle);
}
}
#region -->
/// <summary>
/// 开始二维码生成
/// </summary>
public void QRCodeThread()
{
//if (_type == "CommoditySale")
//{
InputMain Input = new InputMain(_type);
Input.Text = "选择上传天数";
Input.ShowDialog();
if (Input.DialogResult == DialogResult.OK)
{
double _double = Convert.ToDouble(Input.StrValue) * -1;
if (_double < 0)
QRcodeAdd(_type, DateTime.Now.AddDays(_double).ToShortDateString());
else
QRcodeAdd(_type, strUpload_Date(_type));
}
else
{
QRcodeAdd(_type, strUpload_Date(_type));
}
}
#endregion
#region -->
/// <summary>
/// 生成单品集合数据
/// </summary>
private DataTable SaleQrCode(string Upload_Date)
{
string _strSalestart = "";
string _strSaleend = "";
string strtmp = "";
string saletmp = "";
int m = 0;
//List<string> _listSale = new List<string>();
DataTable _DataTable = new DataTable("list");
_DataTable.Columns.Add("id", typeof(decimal));
_DataTable.Columns.Add("startdate", typeof(DateTime));
_DataTable.Columns.Add("enddate", typeof(DateTime));
_DataTable.Columns.Add("salestr", typeof(string));
_DataTable.Columns.Add("salerow", typeof(int));
_DataTable.Columns.Add("checkMD5", typeof(string));
//获取未上传单品记录(交班时间)
string strsql = "select transfer_id, serverpartcode, shopcode,machinecode, startdate, enddate from t_transfer_sale a " +
"where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode +
"' and enddate > datetime('" + Upload_Date + "') and not exists ( select 1 from t_dataupdate b " +
" where a.transfer_id = b.data_id and enddate = b.data_date and b.data_type = 3001 and " +
"b.data_date <= datetime('" + Upload_Date + "')) order by transfer_id asc ";
using (OdbcDataAdapter da = new OdbcDataAdapter(strsql, AnyWhereConn()))
{
DataSet ds = new DataSet();
da.Fill(ds, "t_transfer_sale");
DataTable _TransferSaleTable = ds.Tables["t_transfer_sale"];
UploadTable = _TransferSaleTable;
DataTable _TempTable = _TransferSaleTable.DefaultView.ToTable(true, new string[] { "serverpartcode", "shopcode", "machinecode", "startdate", "enddate" });
for (int i = 0; i < _TempTable.Rows.Count; i++)
{
m = 0;
_strSalestart = _TempTable.Rows[i]["serverpartcode"].ToString() + "|" + _TempTable.Rows[i]["shopcode"].ToString() +
"|" + _TempTable.Rows[i]["machinecode"].ToString() + "|" + Convert.ToDateTime(_TempTable.Rows[i]["startdate"]).ToString("yyyyMMddHHmmss") +
"|" + Convert.ToDateTime(_TempTable.Rows[i]["enddate"]).ToString("yyyyMMddHHmmss");
//根据交班时间获取单品记录
strsql = "select b.commodity_symbol,a.totalcount,a.totalsellamount from t_commoditysale a, t_commodityex b " +
" where a.startdate = datetime('" + _TempTable.Rows[i]["startdate"].ToString() + "') and a.enddate = datetime('" +
_TempTable.Rows[i]["enddate"].ToString() + "') and a.serverpartcode = '" + _TempTable.Rows[i]["serverpartcode"].ToString() +
"' and shopcode = '" + _TempTable.Rows[i]["shopcode"].ToString() + "' and a.commodity_code = b.commodity_code " +
" order by commoditysale_id";
using (OdbcDataAdapter saleda = new OdbcDataAdapter(strsql, AnyWhereConn()))
{
DataSet _DataSet = new DataSet();
saleda.Fill(_DataSet, "t_commoditysale");
DataTable _SaleTable = _DataSet.Tables["t_commoditysale"];
for (int n = 0; n < _SaleTable.Rows.Count; n++)
{
saletmp = _SaleTable.Rows[n]["commodity_symbol"].ToString() +
"^" + _SaleTable.Rows[n]["totalcount"].ToString().Replace(".00", "") +
"^" + _SaleTable.Rows[n]["totalsellamount"].ToString().Replace(".00", "");
if ((strtmp.Length + saletmp.Length) > 300)
{
m++;
DataRow _row = _DataTable.NewRow();
_row["id"] = m;
_row["startdate"] = _TempTable.Rows[i]["startdate"];
_row["enddate"] = _TempTable.Rows[i]["enddate"];
_row["salestr"] = strtmp;
_row["salerow"] = m;
_DataTable.Rows.Add(_row);
strtmp = "";
}
strtmp += (strtmp == "" ? _strSalestart + "|" : ",") + saletmp;
if (n == (_SaleTable.Rows.Count - 1))
{
m++;
DataRow _row = _DataTable.NewRow();
_row["id"] = m;
_row["startdate"] = _TempTable.Rows[i]["startdate"];
_row["enddate"] = _TempTable.Rows[i]["enddate"];
_row["salestr"] = strtmp;
_row["salerow"] = m;
_DataTable.Rows.Add(_row);
strtmp = "";
}
}
}
//根据交班时间获取企业会员、大巴券单品记录
strsql = "select b.commodity_symbol,a.totalcount,a.totalsellamount,a.flag from t_commoditysale_extar a, t_commodityex b " +
" where a.startdate = datetime('" + _TempTable.Rows[i]["startdate"].ToString() + "') and a.enddate = datetime('" +
_TempTable.Rows[i]["enddate"].ToString() + "') and a.serverpartcode = '" + _TempTable.Rows[i]["serverpartcode"].ToString() +
"' and shopcode = '" + _TempTable.Rows[i]["shopcode"].ToString() + "' and a.commodity_code = b.commodity_code " +
" order by commoditysale_id";
using (OdbcDataAdapter saleda = new OdbcDataAdapter(strsql, AnyWhereConn()))
{
DataSet _DataSet = new DataSet();
saleda.Fill(_DataSet, "t_commoditysale_extar");
DataTable _SaleTable = _DataSet.Tables["t_commoditysale_extar"];
for (int n = 0; n < _SaleTable.Rows.Count; n++)
{
decimal.TryParse(_SaleTable.Rows[n]["totalcount"].ToString(), out decimal totalcount);
decimal.TryParse(_SaleTable.Rows[n]["totalsellamount"].ToString(), out decimal totalsellamount);
saletmp = _SaleTable.Rows[n]["commodity_symbol"].ToString() +
"^" + totalcount.ToString("F2").Replace(".00", "") +
"^" + totalsellamount.ToString("F2").Replace(".00", "") +
"^" + _SaleTable.Rows[n]["flag"].ToString();
if ((strtmp.Length + saletmp.Length) > 300)
{
m++;
DataRow _row = _DataTable.NewRow();
_row["id"] = m;
_row["startdate"] = _TempTable.Rows[i]["startdate"];
_row["enddate"] = _TempTable.Rows[i]["enddate"];
_row["salestr"] = strtmp;
_row["salerow"] = m;
_DataTable.Rows.Add(_row);
strtmp = "";
}
strtmp += (strtmp == "" ? _strSalestart + "|" : ",") + saletmp;
if (n == (_SaleTable.Rows.Count - 1))
{
m++;
DataRow _row = _DataTable.NewRow();
_row["id"] = m;
_row["startdate"] = _TempTable.Rows[i]["startdate"];
_row["enddate"] = _TempTable.Rows[i]["enddate"];
_row["salestr"] = strtmp;
_row["salerow"] = m;
_DataTable.Rows.Add(_row);
strtmp = "";
}
}
}
}
if (_DataTable.Rows.Count > 0)
{
string MD5 = "", strMD5 = "";
for (int i = 0; i < _DataTable.Rows.Count; i++)
{
strMD5 += (strMD5 == "" ? "" : ",") + _DataTable.Rows[i]["salestr"].ToString();
}
MD5 = CreateMD5(strMD5);
for (int i = 0; i < _DataTable.Rows.Count; i++)
{
_DataTable.Rows[i]["checkMD5"] = MD5;
}
checkcode = MD5;
}
}
return _DataTable;
}
/// <summary>
/// 生成单品集合数据
/// </summary>
private DataTable SaleQrCodeOld(string Upload_Date)
{
string _strSalestart = "";
string _strSaleend = "";
string strtmp = "";
int m = 0;
//List<string> _listSale = new List<string>();
DataTable _DataTable = new DataTable("list");
_DataTable.Columns.Add("id", typeof(decimal));
_DataTable.Columns.Add("startdate", typeof(DateTime));
_DataTable.Columns.Add("enddate", typeof(DateTime));
_DataTable.Columns.Add("salestr", typeof(string));
_DataTable.Columns.Add("salerow", typeof(int));
_DataTable.Columns.Add("checkMD5", typeof(string));
string strsql = "select transfer_id, serverpartcode, shopcode,machinecode, startdate, enddate, transfer_firstdatas, " +
"transfer_seconddatas, transfer_thirddatas, transfer_forthdatas, transfer_fifthdatas, transfer_sixthdatas, " +
"transfer_seventhdatas, transfer_eighthdatas, transfer_ninthtdatas, transfer_tenthdatas, transfer_eleventhdatas, " +
"transfer_twelfthdatas,transfer_thirteenthdatas, transfer_fourteenthdatas, transfer_fifteenthdatas " +
"from t_transfer_sale a where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode +
"' and enddate > datetime('" + Upload_Date + "') and not exists ( select 1 from t_dataupdate b " +
"where a.transfer_id = b.data_id and enddate = b.data_date and b.data_type = 3001 and " +
"b.data_date <= datetime('" + Upload_Date + "')) order by transfer_id asc";
using (OdbcDataAdapter da = new OdbcDataAdapter(strsql, AnyWhereConn()))
{
DataSet ds = new DataSet();
da.Fill(ds, "t_transfer_sale");
DataTable dt = ds.Tables["t_transfer_sale"];
int indexstart = 0, indexend = 0;
for (int i = 0; i < dt.Columns.Count; i++)
{
if (dt.Columns[i].ColumnName.ToLower() == "transfer_firstdatas")
{
indexstart = i;
}
else if (dt.Columns[i].ColumnName.ToLower() == "transfer_thirteenthdatas")
{
indexend = i;
}
}
foreach (DataRow row in dt.Rows)
{
List<string> _listTmp = new List<string>();
_strSalestart = "";
_strSaleend = "";
strtmp = "";
m = 0;
for (int i = 0; i < dt.Columns.Count; i++)
{
if (i < indexstart)
{
_strSalestart += (_strSalestart == "" ? "" : "|") + (dt.Columns[i].DataType.ToString() == "System.DateTime" ?
Convert.ToDateTime(row[i]).ToString("yyyyMMddHHmmss") : row[i].ToString().Replace(".00", ""));
}
else if (i >= indexstart && i < indexend)
{
if (row[i] != DBNull.Value)
{
List<string> _tmp = new List<string>(row[i].ToString().Split(','));
_listTmp.AddRange(_tmp);
}
}
else if (i >= indexend && i < (dt.Columns.Count - 1))
_strSaleend += (_strSaleend == "" ? "" : "|") + (dt.Columns[i].DataType.ToString() == "System.DateTime" ?
Convert.ToDateTime(row[i]).ToString("yyyyMMddHHmmss") : row[i].ToString().Replace(".00", ""));
}
for (int i = 0; i < _listTmp.Count; i++)
{
if ((strtmp.Length + _listTmp[i].Length) > 300)
{
m++;
DataRow _row = _DataTable.NewRow();
_row["id"] = row["transfer_id"];
_row["startdate"] = row["startdate"];
_row["enddate"] = row["enddate"];
_row["salestr"] = strtmp;
_row["salerow"] = m;
_DataTable.Rows.Add(_row);
strtmp = "";
}
strtmp += (strtmp == "" ? _strSalestart + "|" : ",") + _listTmp[i].Replace(".00", "").Replace("&&", "^");
if (i == (_listTmp.Count - 1))
{
m++;
DataRow _row = _DataTable.NewRow();
_row["id"] = row["transfer_id"];
_row["startdate"] = row["startdate"];
_row["enddate"] = row["enddate"];
_row["salestr"] = strtmp + "|" + _strSaleend;
_row["salerow"] = m;
_DataTable.Rows.Add(_row);
strtmp = "";
}
}
string MD5 = "", strMD5 = "";
for (int i = 0; i < _DataTable.Rows.Count; i++)
{
strMD5 += (strMD5 == "" ? "" : ",") + _DataTable.Rows[i]["salestr"].ToString();
}
MD5 = CreateMD5(strMD5);
for (int i = 0; i < _DataTable.Rows.Count; i++)
{
_DataTable.Rows[i]["checkMD5"] = MD5;
}
checkcode = MD5;
}
}
//QRcodeAdd("CommoditySale", _DataTable);
return _DataTable;
}
#endregion
#region -->
/// <summary>
/// 生成结账数据
/// </summary>
private DataTable EndAccountQrCode(string Upload_Date)
{
string _strEndAccount = "";
string _strPersonSell = "";
string _strTemp = "";
//List<string> _listEndAccount = new List<string>();
DataTable _DataTable = new DataTable("list");
_DataTable.Columns.Add("id", typeof(decimal));
_DataTable.Columns.Add("startdate", typeof(DateTime));
_DataTable.Columns.Add("enddate", typeof(DateTime));
_DataTable.Columns.Add("endaccountstr", typeof(string));
_DataTable.Columns.Add("personsellstr", typeof(string));
_DataTable.Columns.Add("flag", typeof(string));
_DataTable.Columns.Add("checkMD5", typeof(string));
//_DataTable.Columns.Add("sellrow", typeof(string));
string strsql = "select endaccount_id, endaccount_startdate, endaccount_date, serverpartcode, shopcode, " +
"machinecode, endpersoncode, ticketcount, totalcount, totalsellamount, totaloffamount, cash, creditcard, " +
"ticketbill, vipperson, costbill, otherpay, cashpay, flag from t_endaccount a where serverpartcode = '" +
serverpartcode + "' and shopcode = '" + shopcode + "' and machinecode = '" + machinecode +
"' and endaccount_date > datetime('" + Upload_Date + "') and not exists ( select 1 from t_dataupdate b " +
"where a.endaccount_id = b.data_id and endaccount_date = b.data_date and b.data_type in (1001,1002)" +
" and b.data_date <= datetime('" + Upload_Date + "')) order by endaccount_date asc";
using (OdbcDataAdapter da = new OdbcDataAdapter(strsql, AnyWhereConn()))
{
DataSet ds = new DataSet();
da.Fill(ds, "t_endaccount");
DataTable dt = ds.Tables["t_endaccount"];
UploadTable = dt;
//int index = 0;
//for (int i = 0; i < dt.Columns.Count; i++)
//{
// if (dt.Columns[i].ColumnName.ToLower() == "flag")
// {
// index = i;
// break;
// }
//}
foreach (DataRow row in dt.Rows)
{
_strEndAccount = "";
_strPersonSell = "";
_strTemp = "";
for (int i = 0; i < dt.Columns.Count; i++)
{
_strEndAccount += (_strEndAccount == "" ? "" : "|") + (dt.Columns[i].DataType.ToString() ==
"System.DateTime" ? Convert.ToDateTime(row[i]).ToString("yyyyMMddHHmmss") :
row[i].ToString().Replace(".00", ""));
}
strsql = "select personsell_id, serverpartcode, shopcode, machinecode, startdate, enddate, " +
"cashworker_code, ticketcount, totalcount, totalsellamount, totaloffamount, cash, ticketbill, " +
"creditcard, vipperson, costbill, otherpay, cashpay, endpersoncode, reserve_firstnum, " +
"reserve_secondnum, reserve_thirdnum, reserve_firstchar, reserve_secondchar, reserve_thirdchar, " +
"reserve_firstdate, reserve_seconddate, reserve_thirddate from t_personsell where serverpartcode = '" +
serverpartcode + "' and shopcode = '" + shopcode + "' and machinecode = '" + machinecode +
"' and startdate >= datetime('" + row["endaccount_startdate"].ToString() + "') and enddate <= datetime('" +
row["endaccount_date"].ToString() + "') order by personsell_id asc";
using (OdbcDataAdapter personsell = new OdbcDataAdapter(strsql, AnyWhereConn()))
{
DataSet personsellds = new DataSet();
personsell.Fill(personsellds, "t_personsell");
DataTable person = personsellds.Tables["t_personsell"];
//int _index = 0;
//for (int i = 0; i < dt.Columns.Count; i++)
//{
// if (dt.Columns[i].ColumnName.ToLower() == "worknumber")
// {
// _index = i;
// break;
// }
//}
foreach (DataRow _DataRow in person.Rows)
{
_strTemp = "";
for (int i = 0; i < dt.Columns.Count; i++)
{
_strTemp += (_strTemp == "" ? "" : "|") + (person.Columns[i].DataType.ToString() ==
"System.DateTime" ? Convert.ToDateTime(_DataRow[i]).ToString("yyyyMMddHHmmss") :
_DataRow[i].ToString().Replace(".00", ""));
}
_strPersonSell += (_strPersonSell == "" ? "" : ",") + _strTemp;
}
}
//if (_strPersonSell != "")
//{
DataRow _row = _DataTable.NewRow();
_row["id"] = row["endaccount_id"];
_row["startdate"] = row["endaccount_startdate"];
_row["enddate"] = row["endaccount_date"];
_row["endaccountstr"] = _strEndAccount;
_row["personsellstr"] = _strPersonSell;
_row["flag"] = row["flag"];
_DataTable.Rows.Add(_row);
//}
string MD5 = "", strMD5 = "";
for (int i = 0; i < _DataTable.Rows.Count; i++)
{
strMD5 += (strMD5 == "" ? "" : ",") + _DataTable.Rows[i]["endaccountstr"].ToString();
}
MD5 = CreateMD5(strMD5);
for (int i = 0; i < _DataTable.Rows.Count; i++)
{
_DataTable.Rows[i]["checkMD5"] = MD5;
}
checkcode = MD5;
}
}
//QRcodeAdd("EndAccount", _DataTable);
return _DataTable;
}
#endregion
#region md5 16
public static string CreateMD5(string text)
{
var md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
//换成utf8后对于中文加密也适用
byte[] output = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(text));
string pass2md5 = BitConverter.ToString(output, 4, 8).Replace("-", "");
//pass2md5 = pass2md5.ToUpper();
return pass2md5;
}
#endregion
#region -->
/// <summary>
/// 显示二维码列表
/// </summary>
/// <param name="name">显示类型</param>
/// <param name="list">字符串列表</param>
private void QRcodeAdd(string name, string Upload_date)
{
int _Length = 0, _RowCount = 0, _RecordCount = 0, _ScanIndex = 0, _ScanCount = 0;
string _data1 = "", _data2 = "";
//DataTable list = new DataTable();
lblProvince.ForeColor = Color.White;
if (name == "CommoditySale")
{
switch (ConfigUrationValues("CommoditySaleURL", "http://syyw.eshangtech.com:8060/ScanUpdate/CommoditySale.html"))
{
case "http://syyw.eshangtech.com:8060/ScanUpdate/CommoditySale.html":
lblProvince.Text = "当前上传省份:四川";
break;
case "http://cloud.eshangtech.com:8000/ScanUpdate/CommoditySale.html":
lblProvince.Text = "当前上传省份:浙江";
break;
case "http://cloud.eshangtech.com:8000/ScanUpdate_GZ/CommoditySale.html":
lblProvince.Text = "当前上传省份:贵州";
break;
case "http://cloud.eshangtech.com:8000/ScanUpdate_Test/CommoditySale.html":
lblProvince.Text = "当前上传省份:驿商测试";
break;
case "http://113.16.255.162:6060/ScanUpdate/CommoditySale.html":
lblProvince.Text = "当前上传省份:广西恒信";
break;
case "http://60.191.61.27:8080/ScanUpdate/CommoditySale.html":
lblProvince.Text = "当前上传省份:广西交投";
break;
case "http://47.92.38.105:6060/ScanUpdate/CommoditySale.html":
lblProvince.Text = "当前上传省份:甘肃";
break;
case "http://220.177.42.231:6060/ScanUpdate/CommoditySale.html":
lblProvince.Text = "当前上传省份:江西";
break;
default:
lblProvince.Text = "";
break;
}
label2.Text = "单品数据扫码上传";
label1.Text = "扫码结束后需按Enter键扫手机确认码";
DataList = SaleQrCode(Upload_date);
}
else
{
switch (ConfigUrationValues("EndAccountURL", "http://syyw.eshangtech.com:8060/ScanUpdate/EndAccount.html"))
{
case "http://syyw.eshangtech.com:8060/ScanUpdate/EndAccount.html":
lblProvince.Text = "当前上传省份:四川";
break;
case "http://cloud.eshangtech.com:8000/ScanUpdate/EndAccount.html":
lblProvince.Text = "当前上传省份:浙江";
break;
case "http://cloud.eshangtech.com:8000/ScanUpdate_GZ/EndAccount.html":
lblProvince.Text = "当前上传省份:贵州";
break;
case "http://cloud.eshangtech.com:8000/ScanUpdate_Test/EndAccount.html":
lblProvince.Text = "当前上传省份:驿商测试";
break;
case "http://113.16.255.162:6060/ScanUpdate/EndAccount.html":
lblProvince.Text = "当前上传省份:广西恒信";
break;
case "http://60.191.61.27:8080/ScanUpdate/EndAccount.html":
lblProvince.Text = "当前上传省份:广西交投";
break;
case "http://47.92.38.105:6060/ScanUpdate/EndAccount.html":
lblProvince.Text = "当前上传省份:甘肃";
break;
case "http://220.177.42.231:6060/ScanUpdate/EndAccount.html":
lblProvince.Text = "当前上传省份:江西";
break;
default:
lblProvince.Text = "";
break;
}
label2.Text = "日结营收扫码上传";
label1.Text = "扫码结束后需按Enter键扫手机确认码";
DataList = EndAccountQrCode(Upload_date);
}
flowLayoutPanel1.Controls.Clear();
if (DataList.Rows.Count > 0)
{
//_SaveTable = list;
for (int n = 0; n < DataList.Rows.Count; n++)
{
//建立图像显示
PictureBox qrbox = new PictureBox
{
Height = 210,
Width = 210,
Name = "qrbox" + n,
Location = new System.Drawing.Point(12, 8),
Margin = new Padding(5),
BackColor = Color.Red
};
//建立图像说明
Label qrdate = new Label
{
Height = 20,
Width = 95
};
qrdate.Font = new Font(qrdate.Font.FontFamily, 10, System.Drawing.FontStyle.Bold);
qrdate.Location = new System.Drawing.Point(10, 220);
qrdate.Margin = new Padding(0);
qrdate.Name = "qrdate" + n;
qrdate.TextAlign = ContentAlignment.MiddleCenter;
Label qrtime = new Label
{
Height = 20,
Width = 135
};
qrtime.Font = new Font(qrtime.Font.FontFamily, 10, qrtime.Font.Style);
qrtime.Location = new System.Drawing.Point(100, 220);
qrtime.Margin = new Padding(0);
qrtime.Name = "qrtime" + n;
qrtime.TextAlign = ContentAlignment.MiddleCenter;
if (name == "EndAccount")
{
qrdate.Text = Convert.ToDateTime(DataList.Rows[n]["enddate"]).ToString("yyyy-MM-dd");
qrtime.Text = Convert.ToDateTime(DataList.Rows[n]["enddate"]).ToString("HH:mm:ss") +
(DataList.Rows[n]["flag"].ToString() == "5" ? " <稽核>" : " <日结>");
}
else
{
qrdate.Text = Convert.ToDateTime(DataList.Rows[n]["enddate"]).ToString("yyyy-MM-dd");
int t = 0;
for (int x = 0; x < DataList.Rows.Count; x++)
{
if (Convert.ToDateTime(DataList.Rows[x]["enddate"]) == Convert.ToDateTime(DataList.Rows[n]["enddate"]))
{
t++;
}
}
qrtime.Text = Convert.ToDateTime(DataList.Rows[n]["enddate"]).ToString("HH:mm:ss") + (t == 1 ? "" :
" <" + DataList.Rows[n]["salerow"].ToString() + "/" + t + ">");
}
//建立显示及说明容器
Panel qrpanel = new Panel
{
Location = new System.Drawing.Point(0, 0),
BackColor = Color.FromArgb(140, 215, 255),
Name = "qrpanel" + n,
Height = 240,
Width = 235
};
//构造二维码写码器
MultiFormatWriter writer = new MultiFormatWriter();
Dictionary<EncodeHintType, object> hint = new Dictionary<EncodeHintType, object>
{
{ EncodeHintType.CHARACTER_SET, "UTF-8" },
{ EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L }
};
//options = new QrCodeEncodingOptions
//{
// DisableECI = true,
// CharacterSet = "UTF-8",
// Width = qrbox.Height,
// Height = qrbox.Width,
//};
//writer = new BarcodeWriter
//{
// Format = BarcodeFormat.QR_CODE,
// Options = options,
//};
string text = "";
if (name == "CommoditySale")
{
_data1 = HttpUtility.UrlEncode(DataList.Rows[n]["salestr"].ToString());
_Length = DataList.Rows[n]["salestr"].ToString().Length;
_RowCount = Convert.ToInt16(DataList.Rows[n]["salerow"]);
_ScanIndex = n + 1;
_ScanCount = DataList.Rows.Count;
int t = 0;
for (int x = 0; x < DataList.Rows.Count; x++)
{
if (Convert.ToDateTime(DataList.Rows[x]["enddate"]) == Convert.ToDateTime(DataList.Rows[n]["enddate"]))
{
t++;
}
}
_RecordCount = t;
text = ConfigUrationValues("CommoditySaleURL", "http://syyw.eshangtech.com:8060/ScanUpdate/CommoditySale.html") + "?" +
name + "_New=" + _data1 + "&Length=" + _Length + "&RowCount=" + _RowCount + "&RecordCount=" + _RecordCount +
"&CheckCode=" + DataList.Rows[n]["checkMD5"].ToString() + "&ScanIndex=" + _ScanIndex + "&ScanCount=" + _ScanCount;
}
else
{
_data1 = HttpUtility.UrlEncode(DataList.Rows[n]["endaccountstr"].ToString());
_data2 = HttpUtility.UrlEncode(DataList.Rows[n]["personsellstr"].ToString());
_Length = DataList.Rows[n]["endaccountstr"].ToString().Length + DataList.Rows[n]["personsellstr"].ToString().Length;
_RowCount = n + 1;
_ScanIndex = n + 1;
_ScanCount = DataList.Rows.Count;
_RecordCount = DataList.Rows.Count;
text = ConfigUrationValues("EndAccountURL", "http://syyw.eshangtech.com:8060/ScanUpdate/EndAccount.html") + "?" +
name + "=" + _data1 + (_data2 == "" ? "" : "&Personsell=" + _data2) + "&Length=" + _Length + "&RowCount=" +
_RowCount + "&RecordCount=" + _RecordCount + "&CheckCode=" + DataList.Rows[n]["checkMD5"].ToString() +
"&ScanIndex=" + _RowCount + "&ScanCount=" + _RecordCount;
} //生成二维码
BitMatrix bm = writer.encode(text, BarcodeFormat.QR_CODE, qrbox.Width, qrbox.Height, hint);
BarcodeWriter barcodeWriter = new BarcodeWriter();
Bitmap bitmap = barcodeWriter.Write(bm);
//Bitmap bitmap = writer.Write(text);
qrbox.Image = bitmap;
qrpanel.Controls.Add(qrbox);
qrpanel.Controls.Add(qrdate);
qrpanel.Controls.Add(qrtime);
flowLayoutPanel1.Controls.Add(qrpanel);
}
}
else
{
DialogResult _DialogResult = System.Windows.Forms.MessageBox.Show("当前无未上传信息,是否查看最近日结信息上传状态?", "系统提示",
MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
if (_DialogResult == DialogResult.Yes)
{
MachineInfo machineInfo = new MachineInfo
{
TopMost = true,
ShowInTaskbar = false
};
machineInfo.ShowDialog();
Environment.Exit(0);
}
else
{
Environment.Exit(0);
}
}
}
#endregion
#region -->
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
Close();
else if (e.KeyCode == Keys.Enter)
{
TimerHandle.Stop();
MessageForm _MessageBox = new MessageForm(_type, checkcode, ConfigUrationValues("shopcode", ""));
_MessageBox.ShowDialog();
if (_MessageBox.DialogResult == DialogResult.OK)
{
//标记上传记录
if (_type == "CommoditySale") //单品
{
DataTable distinctTable = UploadTable.DefaultView.ToTable(true, new string[] { "id", "enddate" });
for (int i = 0; i < UploadTable.Rows.Count; i++)
{
//string _datetime = TimeHelper.ConvertLongDateTime(Convert.ToInt64(_MessageBox.StrValue)).ToString();
if (Convert.ToDateTime(UploadTable.Rows[i]["enddate"]) > Convert.ToDateTime(strUpload_Date(_type)))
{
UpdateConfigUration(_type, UploadTable.Rows[i]["enddate"].ToString());
}
string _selectstr = "SELECT dataupdate_id, serverpartcode, shopcode, machinecode, data_id, data_date, data_type, " +
"update_date, update_state,update_checknum, dataupdate_desc FROM t_dataupdate " +
"WHERE data_date = datetime('" + UploadTable.Rows[i]["enddate"].ToString() + "') and data_id = " + UploadTable.Rows[i]["id"] +
" and data_type = 3001";
if (DBHelper.ExecuteDataSet(_selectstr).Tables[0].Rows.Count == 0)
{
decimal maxid = 0;
try
{
maxid = decimal.Parse(DBHelper.ExecuteDataSet("select max(dataupdate_id) from t_dataupdate").Tables[0].Rows[0][0].ToString());
}
catch
{
maxid = 0;
}
string _insertstr = "INSERT INTO t_dataupdate (dataupdate_id, serverpartcode, shopcode, machinecode, data_id, data_date, data_type, update_date, update_state) VALUES (" +
(maxid + 1) + ",'" + ConfigUrationValues("serverpartcode", "") + "','" + ConfigUrationValues("shopcode", "") + "','" + ConfigUrationValues("machinecode", "") +
"'," + UploadTable.Rows[i]["id"] + ",datetime('" + UploadTable.Rows[i]["enddate"].ToString() + "'),3001,datetime('" + DateTime.Now.ToString() + "'),2)";
try
{
int rows = DBHelper.ExcuteSql(_insertstr);
}
catch
{
}
}
}
}
else //日结
{
for (int i = 0; i < DataList.Rows.Count; i++)
{
if (Convert.ToDateTime(DataList.Rows[i]["enddate"]) > Convert.ToDateTime(strUpload_Date(_type)))
{
UpdateConfigUration(_type, DataList.Rows[i]["enddate"].ToString());
}
string _selectstr = "SELECT dataupdate_id, serverpartcode, shopcode, machinecode, data_id, data_date, data_type, " +
"update_date, update_state,update_checknum, dataupdate_desc FROM t_dataupdate " +
"WHERE data_date = datetime('" + DataList.Rows[i]["enddate"].ToString() + "') and data_id = " + DataList.Rows[i]["id"] +
" and data_type = " + (DataList.Rows[i]["flag"].ToString() == "5" ? 1002 : 1001);
if (DBHelper.ExecuteDataSet(_selectstr).Tables[0].Rows.Count == 0)
{
decimal maxid = 0;
try
{
maxid = decimal.Parse(DBHelper.ExecuteDataSet("select max(dataupdate_id) from t_dataupdate").Tables[0].Rows[0][0].ToString());
}
catch
{
maxid = 0;
}
string _insertstr = "INSERT INTO t_dataupdate (dataupdate_id, serverpartcode, shopcode, machinecode, data_id, data_date, data_type, update_date, update_state) VALUES (" +
(maxid + 1) + ",'" + ConfigUrationValues("serverpartcode", "") + "','" + ConfigUrationValues("shopcode", "") + "','" + ConfigUrationValues("machinecode", "") +
"'," + DataList.Rows[i]["id"] + ",datetime('" + DataList.Rows[i]["enddate"].ToString() + "')," + (DataList.Rows[i]["flag"].ToString() == "5" ? 1002 : 1001) + ",datetime('" + DateTime.Now.ToString() + "'),2)";
try
{
int rows = DBHelper.ExcuteSql(_insertstr);
}
catch
{
}
}
_selectstr = "select personsell_id, serverpartcode, shopcode, machinecode, startdate, enddate, cashworker_code, " +
"ticketcount, totalcount, totalsellamount, totaloffamount, cash, ticketbill, creditcard, vipperson, costbill, " +
"otherpay, cashpay, endpersoncode, reserve_firstnum, reserve_secondnum, reserve_thirdnum, reserve_firstchar, " +
"reserve_secondchar, reserve_thirdchar, reserve_firstdate, reserve_seconddate, reserve_thirddate from t_personsell " +
"where serverpartcode = '" + serverpartcode + "' and shopcode = '" + shopcode + "' and machinecode = '" + machinecode +
"' and startdate >= datetime('" + DataList.Rows[i]["startdate"].ToString() + "') and enddate <= datetime('" + DataList.Rows[i]["enddate"].ToString() +
"') order by personsell_id asc";
DataTable dataTable = DBHelper.ExecuteDataSet(_selectstr).Tables[0];
if (dataTable.Rows.Count > 0)
{
foreach (DataRow row in dataTable.Rows)
{
_selectstr = "SELECT dataupdate_id, serverpartcode, shopcode, machinecode, data_id, data_date, " +
"data_type, update_date, update_state,update_checknum, dataupdate_desc FROM t_dataupdate " +
"WHERE data_date = datetime('" + row["enddate"].ToString() + "') and data_id = " + row["personsell_id"] +
" and data_type = 2001";
if (DBHelper.ExecuteDataSet(_selectstr).Tables[0].Rows.Count == 0)
{
decimal maxid = 0;
try
{
maxid = decimal.Parse(DBHelper.ExecuteDataSet("select max(dataupdate_id) from t_dataupdate").Tables[0].Rows[0][0].ToString());
}
catch
{
maxid = 0;
}
string _insertstr = "INSERT INTO t_dataupdate (dataupdate_id, serverpartcode, shopcode, machinecode, data_id, data_date, data_type, update_date, update_state) VALUES (" +
(maxid + 1) + ",'" + row["serverpartcode"].ToString() + "','" + row["shopcode"].ToString() + "','" + row["machinecode"].ToString() +
"'," + row["personsell_id"] + ",datetime('" + row["enddate"].ToString() + "'),2001,datetime('" + DateTime.Now.ToString() + "'),2)";
try
{
int rows = DBHelper.ExcuteSql(_insertstr);
}
catch
{
}
}
}
}
}
}
DialogResult _DialogResult = System.Windows.Forms.MessageBox.Show((_type == "CommoditySale" ? "单品信息" : "日结营收") + "上传完成,按确定键返回收银系统", "系统提示", MessageBoxButtons.OK,
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
if (_DialogResult == DialogResult.OK)
Environment.Exit(0);
}
}
else if (e.KeyCode == Keys.Up)
{
if (flowLayoutPanel1.VerticalScroll.Value > flowLayoutPanel1.VerticalScroll.Minimum)
{
if (flowLayoutPanel1.VerticalScroll.Value > 246)
{
flowLayoutPanel1.VerticalScroll.Value -= 246;
flowLayoutPanel1.VerticalScroll.Value -= 246;
}
else
{
flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.Minimum;
flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.Minimum;
}
}
}
else if (e.KeyCode == Keys.Down)
{
if (flowLayoutPanel1.VerticalScroll.Value < flowLayoutPanel1.VerticalScroll.Maximum && flowLayoutPanel1.VerticalScroll.Maximum > 246)
{
flowLayoutPanel1.VerticalScroll.Value += 246;
flowLayoutPanel1.VerticalScroll.Value += 246;
}
else
{
flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.Maximum;
flowLayoutPanel1.VerticalScroll.Value = flowLayoutPanel1.VerticalScroll.Maximum;
}
}
else if (e.KeyCode == Keys.F12)
{
TimerHandle.Stop();
ProvinceMain _MessageBox = new ProvinceMain(_type);
_MessageBox.ShowDialog();
if (_MessageBox.DialogResult == DialogResult.OK)
{
QRcodeAdd(_type, strUpload_Date(_type));
}
TimerHandle.Start();
}
else if (e.KeyCode == Keys.F11)
{
if (UpLoadThread == null || !UpLoadThread.IsAlive)
{
UpLoadThread = new Thread(UpluadDate)
{
IsBackground = true
};
UpLoadThread.Start();
}
}
}
#endregion
private void UpluadDate()
{
//ShowWaiteForm();
int _Length = 0, _RowCount = 0, _RecordCount = 0, _ScanIndex = 0, _ScanCount = 0;
string _data1 = "", _data2 = "";
if (DataList.Rows.Count > 0)
{
ProgressBarValue("正在上传数据请稍侯.....1%", 1);
string Url = "http://183.129.232.104:8010/MobileServicePlatform/Handler/handler_ajax.ashx";
switch (ConfigUrationValues("EndAccountURL", "http://syyw.eshangtech.com:8060/ScanUpdate/EndAccount.html"))
{
case "http://syyw.eshangtech.com:8060/ScanUpdate/EndAccount.html":
Url = "http://syyw.eshangtech.com:8060/MobileServicePlatform/Handler/handler_ajax.ashx";
break;
case "http://cloud.eshangtech.com:8000/ScanUpdate/EndAccount.html":
Url = "http://183.129.232.104:8010/MobileServicePlatform/Handler/handler_ajax.ashx";
break;
case "http://cloud.eshangtech.com:8000/ScanUpdate_GZ/EndAccount.html":
Url = "http://60.191.61.26:60600/MobileServicePlatform/Handler/handler_ajax.ashx";
break;
case "http://113.16.255.162:6060/ScanUpdate/EndAccount.html":
Url = "http://113.16.255.162:6060/MobileServicePlatform/Handler/handler_ajax.ashx";
break;
case "http://60.191.61.27:8080/ScanUpdate/EndAccount.html":
Url = "http://60.191.61.27:8080/MobileServicePlatform/Handler/handler_ajax.ashx";
break;
case "http://47.92.38.105:6060/ScanUpdate/EndAccount.html":
Url = "http://47.92.38.105:6060/MobileServicePlatform/Handler/handler_ajax.ashx";
break;
case "http://220.177.42.231:6060/ScanUpdate/EndAccount.html":
Url = "http://220.177.42.231:6060/MobileServicePlatform/Handler/handler_ajax.ashx";
break;
}
for (int n = 0; n < DataList.Rows.Count; n++)
{
string text = "";
if (_type == "CommoditySale")
{
_data1 = HttpUtility.UrlEncode(DataList.Rows[n]["salestr"].ToString());
_Length = DataList.Rows[n]["salestr"].ToString().Length;
_RowCount = Convert.ToInt16(DataList.Rows[n]["salerow"]);
_ScanIndex = n + 1;
_ScanCount = DataList.Rows.Count;
int t = 0;
for (int x = 0; x < DataList.Rows.Count; x++)
{
if (Convert.ToDateTime(DataList.Rows[x]["enddate"]) == Convert.ToDateTime(DataList.Rows[n]["enddate"]))
{
t++;
}
}
_RecordCount = t;
text = _type + "_New=" + _data1 + "&Length=" + _Length + "&RowCount=" + _RowCount + "&RecordCount=" + _RecordCount +
"&CheckCode=" + DataList.Rows[n]["checkMD5"].ToString() + "&ScanIndex=" + _ScanIndex + "&ScanCount=" + _ScanCount;
}
else
{
_data1 = HttpUtility.UrlEncode(DataList.Rows[n]["endaccountstr"].ToString());
_data2 = HttpUtility.UrlEncode(DataList.Rows[n]["personsellstr"].ToString());
_Length = DataList.Rows[n]["endaccountstr"].ToString().Length + DataList.Rows[n]["personsellstr"].ToString().Length;
_RowCount = n + 1;
_ScanIndex = n + 1;
_ScanCount = DataList.Rows.Count;
_RecordCount = DataList.Rows.Count;
text = _type + "=" + _data1 + (_data2 == "" ? "" : "&Personsell=" + _data2) + "&Length=" + _Length + "&RowCount=" +
_RowCount + "&RecordCount=" + _RecordCount + "&CheckCode=" + DataList.Rows[n]["checkMD5"].ToString() +
"&ScanIndex=" + _RowCount + "&ScanCount=" + _RecordCount;
}
string postDataStr = "action_type=ScanCodeUpdate&action_data=" + HttpUtility.UrlEncode(text) + "&action_record=1";
string _strServiceURL = String.Format("http://{0}:{1}/service.asmx", dbip, serviceport);
try
{
System.Collections.Hashtable hashtable = new System.Collections.Hashtable
{
{ "url", Url },
{ "postDataStr", postDataStr }
};
string retString = ESSupport.Lib.SoapWSHelper.QuerySoapWebServiceString(_strServiceURL, "UploadSeller", hashtable);
ProgressBarValue("正在上传数据请稍侯....." + ((decimal)(n + 1) / DataList.Rows.Count * 100).ToString("F2") + "%", (int)((decimal)(n + 1) / DataList.Rows.Count * 100));
if (checkcode == retString)
{
System.Windows.Forms.MessageBox.Show("数据上传成功!", "系统提示", MessageBoxButtons.OK,
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
ProgressBarValue("", 101);
return;
}
}
catch (Exception ex)
{
LogHelper.WriteServiceLog("扫码直接上传异常:" + ex.Message);
}
}
System.Windows.Forms.MessageBox.Show("上传失败,请重试!", "系统提示", MessageBoxButtons.OK,
MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
ProgressBarValue("", 101);
return;
}
}
public void ProgressBarValue(string txt, int progValue)
{
Invoke(new ProgressBarMess(ProgBar), new object[] { txt, progValue });
}
delegate void ProgressBarMess(string txt, int progValue);
void ProgBar(string txt, int progValue)
{
if (progValue > 100)
{
TimerHandle.Start();
progressBar1.Value = 100;
lblProg.Text = txt;
progressBar1.Visible = false;
lblProg.Visible = false;
label1.Visible = true;
}
else
{
TimerHandle.Stop();
progressBar1.Value = progValue;
lblProg.Text = txt;
progressBar1.Visible = true;
lblProg.Visible = true;
label1.Visible = false;
}
}
#region -->
/// <summary>
/// 获取已上传信息日期
/// </summary>
/// <param name="ConfigUration_Name">上传类型名称</param>
/// <returns>日期</returns>
public static string strUpload_Date(string ConfigUration_Name)
{
DateTime _EndAccount;
//string sqlstr = "select configuration_values from t_configuration where lower(configuration_name) = lcase('" + ConfigUration_Name + "')";
//using (OdbcConnection conn = AnyWhereConn())
//{
// try
// {
// conn.Open();
// using (OdbcCommand com = new OdbcCommand(sqlstr, conn))
// {
// OdbcDataReader dr = com.ExecuteReader();
// dr.Read();
// _EndAccount = Convert.ToDateTime(dr["configuration_values"]);
// }
// conn.Close();
// }
// catch (Exception ex)
// {
// int _int = Convert.ToInt32(ConfigUrationValues("endaccounttimes", "20")) * -1;
// _EndAccount = Convert.ToDateTime(DateTime.Now.AddDays(_int).ToShortDateString());
// }
//}
_EndAccount = Convert.ToDateTime(DateTime.Now.AddDays(-3).ToShortDateString());
return _EndAccount.ToString();
}
#endregion
#region -->
/// <summary>
/// 更新本地配置信息
/// </summary>
/// <param name="ConfigUration_Name">配置名称</param>
/// <param name="ConfigUration_Values">配置内容</param>
/// <returns></returns>
public static bool UpdateConfigUration(string ConfigUration_Name, string ConfigUration_Values)
{
string strsql = "select count(*) from t_configuration where configuration_name = '" + ConfigUration_Name + "'";
using (OdbcConnection conn = AnyWhereConn())
{
try
{
conn.Open();
OdbcCommand com = new OdbcCommand(strsql, conn);
OdbcDataReader dr = com.ExecuteReader();
dr.Read();
if (dr[0].ToString() == "0")
{
OdbcCommand max = new OdbcCommand("select max(configuration_id) from t_configuration", conn);
OdbcDataReader read = max.ExecuteReader();
read.Read();
decimal maxid = Convert.ToDecimal(read[0]);
strsql = "insert into t_configuration(configuration_id, configuration_date, configuration_name, configuration_values)values(" +
(maxid + 1) + ", now(),'" + ConfigUration_Name + "','" + ConfigUration_Values + "')";
OdbcCommand insert = new OdbcCommand(strsql, conn);
insert.ExecuteNonQuery();
return true;
}
else
{
strsql = "update t_configuration set configuration_values = '" + ConfigUration_Values + "' where configuration_name = '" + ConfigUration_Name + "'";
OdbcCommand insert = new OdbcCommand(strsql, conn);
insert.ExecuteNonQuery();
return true;
}
}
catch
{
return false;
}
}
}
#endregion
#region -->
/// <summary>
/// 获取配置信息
/// </summary>
/// <param name="ConfigUrationName">配置名称</param>
/// <param name="defaultValue">无配置信息时默认值</param>
/// <returns></returns>
public static 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 = ExecuteDataSet(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 = ConfigHelper.Win32API.INIGetStringValue(Environment.CurrentDirectory + "\\setup.ini", "DBCONECT", ConfigUrationName, defaultValue);
if (strValues == "")
strValues = ConfigHelper.Win32API.INIGetStringValue(Environment.CurrentDirectory + "\\set.ini", "DBCONECT", ConfigUrationName, defaultValue);
}
return strValues;
}
#endregion
/// <summary>
/// 本地数据库连接
/// </summary>
/// <returns></returns>
public static OdbcConnection AnyWhereConn()
{
string strConn = "DSN=anysql1;UID=dba;PWD=sql;";
OdbcConnection Conany = new OdbcConnection(strConn);
return Conany;
}
/// <summary>
/// 本地执行SQL语句并返回DataSet
/// </summary>
/// <param name="SelectSql">SQL语句</param>
/// <returns></returns>
public static DataSet ExecuteDataSet(string SelectSql)
{
using (OdbcConnection conany = AnyWhereConn())
{
DataSet _DataSet = new DataSet();
try
{
OdbcDataAdapter _OdbcDataAdapter = new OdbcDataAdapter(SelectSql, conany);
_OdbcDataAdapter.Fill(_DataSet);
return _DataSet;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
private void DataUpdate_Load(object sender, EventArgs e)
{
Window win_ScanDataUpload = new SacnUpload.ScanDataUpload();
System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(win_ScanDataUpload);
System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(win_ScanDataUpload);
helper.Owner = this.Handle;
win_ScanDataUpload.WindowStartupLocation = WindowStartupLocation.CenterOwner;
win_ScanDataUpload.ShowDialog();
Environment.Exit(0);
}
}
}