1620 lines
75 KiB
C#
1620 lines
75 KiB
C#
using GetHttpData.SDK.ThreadPool;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Net;
|
||
using System.Threading;
|
||
using System.Windows;
|
||
using System.Windows.Controls;
|
||
using System.Windows.Input;
|
||
using System.Windows.Media;
|
||
using System.Windows.Media.Imaging;
|
||
using System.Windows.Threading;
|
||
using TouchCashier.Common;
|
||
using TouchCashier.Utils;
|
||
using TouchCashier.Parameter;
|
||
using System.IO;
|
||
|
||
namespace TouchCashier
|
||
{
|
||
/// <summary>
|
||
/// MainWindow.xaml 的交互逻辑
|
||
/// </summary>
|
||
public partial class MainWindow : Window
|
||
{
|
||
#region 初始化
|
||
private Thread _thread;
|
||
private Thread _DataThread;
|
||
private Thread LoadThread;
|
||
private Thread DownDateThread;
|
||
ClientThread _ClientThread = new ClientThread();
|
||
int Downing = 0;
|
||
bool IsLogin = false;
|
||
#endregion
|
||
|
||
public MainWindow()
|
||
{
|
||
InitializeComponent();
|
||
//初始化
|
||
imgload.Image = Properties.Resources.登录状态;
|
||
imga.Image = Properties.Resources.load;
|
||
PictureFigr.Image = Properties.Resources.扫描指纹;
|
||
PictureFace.Image = Properties.Resources.人脸识别;
|
||
//数据库连接检测
|
||
string sql = "select * from dba.sys_globle";
|
||
try
|
||
{
|
||
DBHelper.QueryOdbc(sql);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//启动本地数据库
|
||
try
|
||
{
|
||
System.Diagnostics.Process.Start(AppDomain.CurrentDomain.BaseDirectory + "dbsrv12.exe",
|
||
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "datebase", "hydb.db") +
|
||
" -os 10240k -m -c 8m -q -n " + Dns.GetHostName());
|
||
}
|
||
catch
|
||
{
|
||
}
|
||
ConnDetection _ConnDetection = new ConnDetection();
|
||
_ConnDetection.ShowDialog();
|
||
//Grid_User.Visibility = Visibility.Collapsed;
|
||
//GridLoad.Visibility = Visibility.Visible;
|
||
//TxtMsg.Text = "正在连接数据库请稍候....";
|
||
}
|
||
//启动加载
|
||
LoadThread = new Thread(Loading)
|
||
{
|
||
IsBackground = true
|
||
};
|
||
Grid_Load.Visibility = Visibility.Visible;
|
||
LoadThread.Start();
|
||
}
|
||
|
||
void Loading()
|
||
{
|
||
try
|
||
{
|
||
if (!File.Exists(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.ini")))
|
||
{
|
||
byte[] Save = Properties.Resources.config;
|
||
FileStream fsObj = new FileStream(Path.Combine(
|
||
AppDomain.CurrentDomain.BaseDirectory, "config.ini"), FileMode.Create);
|
||
fsObj.Write(Save, 0, Save.Length);
|
||
fsObj.Close();
|
||
}
|
||
}
|
||
catch { }
|
||
//升级本地数据库
|
||
//this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
//{
|
||
// TxtLoad.Text = "正在更新本地数据库......";
|
||
//});
|
||
//ESSupport.Lib.DataBaseUpdate.PosDataBaseUpdate();
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
TxtLoad.Text = "正在加载系统设置,请稍候......";
|
||
});
|
||
//获取参数信息
|
||
QualityHelper.GetConfiguration();
|
||
try
|
||
{
|
||
_DataThread = new Thread(GetDate)
|
||
{
|
||
IsBackground = true
|
||
};
|
||
_DataThread.Start();
|
||
}
|
||
catch { }
|
||
//QualityHelper.GetDate();
|
||
//与服务器校对时间
|
||
try
|
||
{
|
||
DateTime _ServerTime = ESSupport.Lib.HttpHelper.GetBeijingTime(
|
||
$"http://{QualityHelper.dbip}:{QualityHelper.serviceport}/Service.asmx");
|
||
if (_ServerTime != DateTime.MinValue && _ServerTime > new DateTime(2020, 06, 01))
|
||
{
|
||
SyTime.SetLocalTimeByStr(_ServerTime);
|
||
QualityHelper.UpdateConfigUration("syncdtime", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||
}
|
||
}
|
||
catch { }
|
||
//获取版本信息并更新
|
||
string version = "YSv" + System.Windows.Forms.Application.ProductVersion.ToString();
|
||
if (QualityHelper.version != version)
|
||
{
|
||
QualityHelper.version = version;
|
||
QualityHelper.UpdateConfigUration("version", version);
|
||
QualityHelper.UpdateConfigUration("UpdateDate",
|
||
DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
||
}
|
||
QualityHelper.UpdateConfigUration("NewSystem", "1");
|
||
if (!QualityHelper.serverpartcode.StartsWith("14") && QualityHelper.serverpartcode != "888888")
|
||
{
|
||
QualityHelper.UpdateConfigUration("VideoSwitch", "0");
|
||
QualityHelper.VideoSwitch = "0";
|
||
}
|
||
if ((!string.IsNullOrWhiteSpace(QualityHelper.ServerPartCodeNew) &&
|
||
QualityHelper.serverpartcode != QualityHelper.ServerPartCodeNew) ||
|
||
(!string.IsNullOrWhiteSpace(QualityHelper.ShopCodeNew) &&
|
||
QualityHelper.shopcode != QualityHelper.ShopCodeNew) ||
|
||
(!string.IsNullOrWhiteSpace(QualityHelper.MachineCodeNew) &&
|
||
QualityHelper.machinecode != QualityHelper.MachineCodeNew))
|
||
{
|
||
try
|
||
{
|
||
if (ESSupport.Lib.SyBaseHelper.QueryOdbc(
|
||
$@"SELECT 1 FROM T_ENDACCOUNT_NEW
|
||
WHERE SERVERPARTCODE = '{QualityHelper.serverpartcode}' AND
|
||
SHOPCODE = '{QualityHelper.shopcode}' AND
|
||
MACHINECODE = '{QualityHelper.machinecode}' AND
|
||
ENDDATE IS NULL").Tables[0].Rows.Count == 0)
|
||
{
|
||
if (QualityHelper.serverpartcode != QualityHelper.ServerPartCodeNew)
|
||
{
|
||
QualityHelper.serverpartcode = QualityHelper.ServerPartCodeNew;
|
||
QualityHelper.UpdateConfigUration("serverpartcode", QualityHelper.ServerPartCodeNew);
|
||
}
|
||
if (QualityHelper.shopcode != QualityHelper.ShopCodeNew)
|
||
{
|
||
QualityHelper.shopcode = QualityHelper.ShopCodeNew;
|
||
QualityHelper.UpdateConfigUration("shopcode", QualityHelper.ShopCodeNew);
|
||
}
|
||
if (QualityHelper.machinecode != QualityHelper.MachineCodeNew)
|
||
{
|
||
QualityHelper.machinecode = QualityHelper.MachineCodeNew;
|
||
QualityHelper.UpdateConfigUration("machinecode", QualityHelper.MachineCodeNew);
|
||
}
|
||
}
|
||
}
|
||
catch { }
|
||
}
|
||
//if (QualityHelper.serverpartcode == "888888") { QualityHelper.VideoSwitch = "1"; }
|
||
DateTime _SoftExpiryDate;
|
||
string _strUsingType = QualityHelper.ConfigurationValues("using_type", "1000");
|
||
if (!DateTime.TryParse(QualityHelper.ConfigurationValues("expirydate", ""), out _SoftExpiryDate))
|
||
{
|
||
try
|
||
{
|
||
_SoftExpiryDate = DateTime.Parse(DBHelper.QueryOdbc("SELECT EXPIRY_DATE " +
|
||
"FROM SYS_GLOBLE WHERE VAR_NAME = 'g_ver'").Tables[0].Rows[0]["expiry_date"].ToString());
|
||
}
|
||
catch { }
|
||
}
|
||
|
||
try
|
||
{
|
||
string _XmlPath = AppDomain.CurrentDomain.BaseDirectory + "update.xml";
|
||
string _KillApp = "TouchCashier.exe|cashier.exe|Stardb.exe|dbsyc.exe|GetMembership.exe|DataUpdate.exe|InvoicingTool.exe|ConnectPoint.exe";
|
||
string _KillAppConfig = ESSupport.Lib.ConfigHelper.GetAppConfig(_XmlPath, "KillApp");
|
||
if (_KillAppConfig != _KillApp)
|
||
{
|
||
ESSupport.Lib.ConfigHelper.UpdateAppConfig(_XmlPath, "KillApp", _KillApp);
|
||
}
|
||
string _StartApp = "Stardb.exe|TouchCashier.exe|GetMembership.exe|ConnectPoint.exe";
|
||
string _StartAppConfig = ESSupport.Lib.ConfigHelper.GetAppConfig(_XmlPath, "StartApp");
|
||
if (_StartAppConfig != _StartApp)
|
||
{
|
||
ESSupport.Lib.ConfigHelper.UpdateAppConfig(_XmlPath, "StartApp", _StartApp);
|
||
}
|
||
if (ESSupport.Lib.ConfigHelper.GetAppConfig(_XmlPath, "NewSystem") != "1")
|
||
{
|
||
ESSupport.Lib.ConfigHelper.UpdateAppConfig(_XmlPath, "NewSystem", "1");
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteServiceLog("启动文件校验失败:" + ex.Message);
|
||
}
|
||
//获取授权码
|
||
string _authorization = QualityHelper.ConfigurationValues("authorization", "");
|
||
string _strServerPartCode = QualityHelper.ConfigurationValues("serverpartcode", "");
|
||
string _strServerIP = QualityHelper.ConfigurationValues("server_ip", "");
|
||
if ((_strServerPartCode.StartsWith("51") || _strServerPartCode.StartsWith("36") || _strServerPartCode.StartsWith("65")) &&
|
||
!ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation().StartsWith("68:ED:A4"))
|
||
//if (!_serverPartCode.StartsWith("33") && !ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation().StartsWith("68:ED:A4"))
|
||
{
|
||
string[] _strCodes;
|
||
try
|
||
{
|
||
_strCodes = _authorization.ToDecrypt().Split('|');
|
||
}
|
||
catch
|
||
{
|
||
_strCodes = new string[4];
|
||
}
|
||
if (_strCodes.Length < 4 || ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation() != _strCodes[3]
|
||
|| DateTime.Parse(_strCodes[2]) < DateTime.Now || _strCodes[0] != _strServerPartCode)
|
||
{
|
||
OracleHelper _OracleHelper = new OracleHelper(QualityHelper.dbip, QualityHelper.dbport,
|
||
QualityHelper.conname, QualityHelper.dbuser, QualityHelper.dbpass);
|
||
try
|
||
{
|
||
_authorization = _OracleHelper.ExcuteSqlGetDataSet(
|
||
$@"SELECT * FROM {QualityHelper.dbuser}.T_CONFIGURATION
|
||
WHERE MACADDRESS = '{ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation()}' AND
|
||
UPPER(CONFIGURATION_NAME) = UPPER('{"AUTHORIZATION"}')"
|
||
).Tables[0].Rows[0]["CONFIGURATION_VALUES"].ToString();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteServiceLog("授权验证失败:" + ex.Message);
|
||
}
|
||
}
|
||
}
|
||
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate
|
||
{
|
||
if ((_strServerPartCode.StartsWith("51") || _strServerPartCode.StartsWith("36") || _strServerPartCode.StartsWith("65")) &&
|
||
!ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation().StartsWith("68:ED:A4") && !string.IsNullOrWhiteSpace(_strServerIP))
|
||
//if (!_serverPartCode.StartsWith("33") && !string.IsNullOrWhiteSpace(_strServerIP) &&
|
||
//!ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation().StartsWith("68:ED:A4"))
|
||
{
|
||
string[] _strCodes;
|
||
try
|
||
{
|
||
_strCodes = _authorization.ToDecrypt().Split('|');
|
||
}
|
||
catch
|
||
{
|
||
_strCodes = new string[4];
|
||
}
|
||
if (_strCodes.Length < 4 || ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation() != _strCodes[3] ||
|
||
DateTime.Parse(_strCodes[2]) < DateTime.Now || _strCodes[0] != _strServerPartCode)
|
||
{
|
||
//if (MessageBox.Show("运行环境自检失败,无法启动。", "系统提示",
|
||
// MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK,
|
||
// MessageBoxOptions.ServiceNotification) == MessageBoxResult.OK)
|
||
//{
|
||
// Environment.Exit(0);
|
||
//}
|
||
LogHelper.WriteServiceLog("启动初始化");
|
||
Environment.Exit(0);
|
||
}
|
||
}
|
||
TxtSoftwareName.Text = QualityHelper.softwarename;
|
||
#region
|
||
try
|
||
{
|
||
//QualityHelper.GetDate();
|
||
switch (QualityHelper.IsTouch)
|
||
{
|
||
case "0":
|
||
chk_other.IsChecked = true;
|
||
chk_log.IsChecked = false;
|
||
break;
|
||
case "1":
|
||
chk_other.IsChecked = false;
|
||
chk_log.IsChecked = true;
|
||
break;
|
||
//case "2":
|
||
// chk_other.IsChecked = false;
|
||
// chk_log.IsChecked = false;
|
||
// break;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
#endregion
|
||
GetValue(TxtVersion, QualityHelper.version, "#000000");
|
||
GetValue(TxtExpiryDate, _SoftExpiryDate == DateTime.MinValue ? "" :
|
||
((_strUsingType == "2000" ? "租赁有效期: " : "软件有效期: ") + _SoftExpiryDate.ToString("yyyy年MM月dd日")), "#000000");
|
||
|
||
#region 设置页面颜色和图片
|
||
try
|
||
{
|
||
if (QualityHelper.softwarename.Contains("蜀越"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/sc.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("高速驿网"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/gsyw.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("贵州"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/gz.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("恒辉"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/jx.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("恒信"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/gx.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("骋客"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/ck.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("驿佳"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/gs.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("招商") || QualityHelper.softwarename.Contains("星程"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/ytw.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("晋行晋驿"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/sx.png"));
|
||
}
|
||
else if (QualityHelper.softwarename.Contains("智驿"))
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/qhzy.png"));
|
||
}
|
||
else
|
||
{
|
||
img_logo.Source = new BitmapImage(new Uri("pack://application:,,,/Image/logo/es.png"));
|
||
}
|
||
img_login.Source = new BitmapImage(new Uri("pack://application:,,,/Image/" + SkinPeeler.ImgSource + "/未登录头像.png"));
|
||
img_uname.Source = new BitmapImage(new Uri("pack://application:,,,/Image/" + SkinPeeler.ImgSource + "/账号.png"));
|
||
img_pwd.Source = new BitmapImage(new Uri("pack://application:,,,/Image/" + SkinPeeler.ImgSource + "/密码.png"));
|
||
chk_log.Style = Resources["" + SkinPeeler.ResourcesSource + "CheckBoxStyle"] as Style;
|
||
chk_other.Style = Resources["" + SkinPeeler.ResourcesSource + "CheckBoxStyle"] as Style;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
#endregion
|
||
Grid_Load.Visibility = Visibility.Collapsed;
|
||
//自动登录
|
||
if (QualityHelper.autologon == "1")
|
||
{
|
||
//QualityHelper.GetDate();
|
||
try
|
||
{
|
||
DataTable _DataTable = DBHelper.QueryOdbc(
|
||
$@"SELECT A.SELLWORKERCODE,A.SELLWORKERNAME,
|
||
A.SELLWORKERPASSWORD
|
||
FROM T_SELLWORKER A,T_PERSONSELL_NEW B
|
||
WHERE A.SERVERPARTCODE = B.SERVERPARTCODE AND
|
||
UPPER(A.SELLWORKERCODE) = UPPER(B.SELLWORKER_CODE) AND
|
||
B.SERVERPARTCODE = '{QualityHelper.serverpartcode}' AND
|
||
B.SHOPCODE = '{QualityHelper.shopcode}' AND
|
||
MACHINECODE = '{QualityHelper.machinecode}' AND ENDDATE IS NULL").Tables[0];
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
TxtUserName.Text = _DataTable.Rows[0]["SELLWORKERCODE"].ToString();
|
||
TxtPwd.Password = _DataTable.Rows[0]["SELLWORKERPASSWORD"].ToString();
|
||
Grid_User.Visibility = Visibility.Collapsed;
|
||
GridLoad.Visibility = Visibility.Visible;
|
||
Button_Click(btn_login, null);
|
||
}
|
||
else
|
||
{
|
||
DownDateThread = new Thread(CheckDate)
|
||
{
|
||
IsBackground = true
|
||
};
|
||
DownDateThread.Start();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteServiceLog("自动登录失败:" + ex.Message);
|
||
LoginFail();
|
||
DownDateThread = new Thread(CheckDate)
|
||
{
|
||
IsBackground = true
|
||
};
|
||
DownDateThread.Start();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
DownDateThread = new Thread(CheckDate)
|
||
{
|
||
IsBackground = true
|
||
};
|
||
DownDateThread.Start();
|
||
}
|
||
TxtUserName.Focus();
|
||
});
|
||
}
|
||
|
||
#region 事件 -> 绑定快捷键
|
||
private void TextBox_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.Key == Key.Enter)
|
||
{
|
||
TxtUserName.Text = TxtUserName.Text.PadLeft(4, '0');
|
||
TxtPwd.SelectAll();
|
||
TxtPwd.Focus();
|
||
}
|
||
else if (e.Key == Key.F16)
|
||
{
|
||
TxtUserName.Text = "";
|
||
return;
|
||
}
|
||
}
|
||
|
||
private void TxtPwd_KeyDown_1(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.Key == Key.Enter)
|
||
{
|
||
Button_Click(btn_login, null);
|
||
return;
|
||
}
|
||
else if (e.Key == Key.F16)
|
||
{
|
||
TxtPwd.Password = "";
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 事件 -> 按钮单击
|
||
private void Button_Click(object sender, RoutedEventArgs e)
|
||
{
|
||
Button keybtn = sender as Button;
|
||
if (!keybtn.IsEnabled)
|
||
{
|
||
return;
|
||
}
|
||
switch (keybtn.Name)
|
||
{
|
||
case "btn_login":
|
||
#region 登录按钮
|
||
keybtn.IsEnabled = false;
|
||
string UserName = TxtUserName.Text.Trim().ToUpper();
|
||
string Pwd = TxtPwd.Password;
|
||
TxtMessage.Text = "";
|
||
//非空判断
|
||
if (UserName == "")
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, "用户名不能为空!", "#FF0000");
|
||
TxtUserName.Focus();
|
||
return;
|
||
}
|
||
if (Pwd == "")
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, "密码不能为空!", "#FF0000");
|
||
TxtPwd.Focus();
|
||
return;
|
||
}
|
||
string _SelectSql;
|
||
//验证是否存在
|
||
try
|
||
{
|
||
DataTable _SellWorker = DBHelper.QueryOdbc(
|
||
$@"SELECT PROWERRIGHT,SELLWORKERCODE,SELLWORKERNAME
|
||
FROM T_SELLWORKER WHERE SERVERPARTCODE='{QualityHelper.serverpartcode}' AND
|
||
UPPER(SELLWORKERCODE)=UPPER('{UserName}') AND
|
||
SELLWORKERPASSWORD='{TxtPwd.Password}' AND VALID = 1").Tables[0];
|
||
if (_SellWorker.Rows.Count > 0)
|
||
{
|
||
QualityHelper.sellworkercode = _SellWorker.Rows[0]["SELLWORKERCODE"].ToString();
|
||
QualityHelper.sellworkername = _SellWorker.Rows[0]["SELLWORKERNAME"].ToString();
|
||
//验证销售权限
|
||
if (PosSystemHelper.SellWorkerAuthority(PosDictionary.AuthorityType.销售,
|
||
_SellWorker.Rows[0]["PROWERRIGHT"].ToString()) != 0)
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, "你没有销售权限!!", "#FF0000");
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
return;
|
||
}
|
||
//更新权限串
|
||
PosControl.ProwerRight = _SellWorker.Rows[0]["PROWERRIGHT"].ToString();
|
||
}
|
||
else
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, "用户名或密码错误!!", "#FF0000");
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
return;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, "数据库连接异常,请重试!", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
return;
|
||
}
|
||
#region 结账
|
||
//判断结账校验
|
||
DataTable dt;
|
||
string sqls = "select isnull(endaccount_day,1) from sys_globle where var_name = 'g_ver'";
|
||
DataTable _tables = DBHelper.QueryOdbc(sqls).Tables[0];
|
||
_SelectSql = "select startdate from t_endaccount_new where serverpartcode='" + QualityHelper.serverpartcode +
|
||
"' and shopcode = '" + QualityHelper.shopcode + "' and machinecode = '" + QualityHelper.machinecode +
|
||
"' and enddate is null";
|
||
try
|
||
{
|
||
dt = DBHelper.QueryOdbc(_SelectSql).Tables[0];
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, "本地数据库连接错误,请重试!", "#FF0000");
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
return;
|
||
}
|
||
if (dt.Rows.Count > 0)
|
||
{
|
||
try
|
||
{
|
||
if (DateTime.Parse(dt.Rows[0][0].ToString()).AddDays(double.Parse(_tables.Rows[0][0].ToString())) < DateTime.Now &&
|
||
DateTime.Parse(dt.Rows[0][0].ToString()) < DateTime.Today.AddDays(double.Parse(_tables.Rows[0][0].ToString()) * -1))
|
||
{
|
||
CommodityShift _CommodityShift = new CommodityShift("check", "0")
|
||
{
|
||
Owner = this
|
||
};
|
||
_CommodityShift.ShowDialog();
|
||
if (_CommodityShift.DialogResult != true)
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, "请先结账后登陆!", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
return;
|
||
}
|
||
}
|
||
#endregion
|
||
#region 交班
|
||
//交班检测
|
||
string _SellWorkerCode = "";
|
||
string _SellWorkerName = "";
|
||
try
|
||
{
|
||
DataTable _DataTable = DBHelper.QueryOdbc(
|
||
$@"SELECT A.PERSONSELL_ID,A.SELLWORKER_CODE,B.SELLWORKERNAME
|
||
FROM T_PERSONSELL_NEW A LEFT JOIN T_SELLWORKER B
|
||
ON UPPER(A.SELLWORKER_CODE) = UPPER(B.SELLWORKERCODE) AND
|
||
B.SERVERPARTCODE = '{QualityHelper.serverpartcode}'
|
||
WHERE A.ENDDATE IS NULL AND A.STARTDATE IS NOT NULL AND
|
||
A.SERVERPARTCODE = '{QualityHelper.serverpartcode}' AND
|
||
A.SHOPCODE='{QualityHelper.shopcode}' AND A.MACHINECODE = '{QualityHelper.machinecode}'
|
||
ORDER BY A.PERSONSELL_ID DESC").Tables[0];
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
_SellWorkerCode = _DataTable.Rows[0]["SELLWORKER_CODE"].ToString().ToUpper();
|
||
_SellWorkerName = _DataTable.Rows[0]["SELLWORKERNAME"].ToString();
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, "收银工班校验失败,请重试!", "#FF0000");
|
||
TxtPwd.Focus();
|
||
TxtPwd.SelectAll();
|
||
return;
|
||
}
|
||
if (UserName != _SellWorkerCode && !String.IsNullOrWhiteSpace(_SellWorkerCode))
|
||
{
|
||
CommodityPrompt _CommodityPrompt = new CommodityPrompt("",
|
||
$"收银员[{_SellWorkerCode}]{_SellWorkerName}未交班,是否交班并登陆?")
|
||
{
|
||
Owner = this
|
||
};
|
||
_CommodityPrompt.ShowDialog();
|
||
if (_CommodityPrompt.DialogResult == false)
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, $"收银员[{_SellWorkerName}]还未交班,不允许登录其他收银员!", "#FF0000");
|
||
TxtUserName.Text = _SellWorkerCode;
|
||
TxtPwd.Password = "";
|
||
TxtPwd.Focus();
|
||
TxtPwd.SelectAll();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
CommodityShift _CommodityShift = new CommodityShift("shift", "1")
|
||
{
|
||
Owner = this
|
||
};
|
||
_CommodityShift.ShowDialog();
|
||
if (_CommodityShift.DialogResult != true)
|
||
{
|
||
keybtn.IsEnabled = true;
|
||
GetValue(TxtMessage, $"收银员[{_SellWorkerName}]还未交班,不允许登录其他收银员!", "#FF0000");
|
||
TxtUserName.Text = _SellWorkerCode;
|
||
TxtPwd.Password = "";
|
||
TxtPwd.Focus();
|
||
TxtPwd.SelectAll();
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
if (QualityHelper.NaturalDayAccount != "0")
|
||
{
|
||
if (ESSupport.Lib.SyBaseHelper.QueryOdbc(
|
||
$@"SELECT 1 FROM T_ENDACCOUNT_NEW
|
||
WHERE SERVERPARTCODE = '{QualityHelper.serverpartcode}' AND
|
||
SHOPCODE = '{QualityHelper.shopcode}' AND MACHINECODE = '{QualityHelper.machinecode}' AND
|
||
STARTDATE = DATETIME('{DateTime.Today.AddDays(-1).ToString("yyyy/MM/dd HH:mm:ss")}') AND
|
||
ENDDATE = DATETIME('{DateTime.Today.AddSeconds(-1).ToString("yyyy/MM/dd HH:mm:ss")}') AND
|
||
ENDACCOUNT_TYPE = {(int)PosDictionary.EndaccountType.NaturalDayAccount}").Tables[0].Rows.Count == 0)
|
||
{
|
||
CommodityPrompt _CommodityPrompt = new CommodityPrompt("",
|
||
$"系统正在生成{DateTime.Today.AddDays(-1).ToString("yyyy/MM/dd")}" +
|
||
$"自然日结算报表\n是否打印自然日结算单?")
|
||
{
|
||
Owner = this
|
||
};
|
||
_CommodityPrompt.ShowDialog();
|
||
bool b_Print = _CommodityPrompt.DialogResult.Value;
|
||
PosReportHelper.CreateEndaccount(QualityHelper.serverpartcode, QualityHelper.shopcode,
|
||
QualityHelper.machinecode, QualityHelper.sellworkercode, 0, DateTime.Today.AddDays(-1),
|
||
DateTime.Today.AddSeconds(-1), PosDictionary.EndaccountType.NaturalDayAccount, b_Print);
|
||
}
|
||
}
|
||
|
||
//登录时的操作
|
||
GetValue(TxtLogin, "", "#FF0000");
|
||
Grid_wf.Visibility = Visibility.Visible;
|
||
LostKeyboard();
|
||
stp_title.Visibility = Visibility.Collapsed;
|
||
stp_name.Visibility = Visibility.Collapsed;
|
||
stp_pwd.Visibility = Visibility.Collapsed;
|
||
stp_img.Visibility = Visibility.Visible;
|
||
btn_login.IsEnabled = false;
|
||
btn_close.IsEnabled = false;
|
||
btnParameter.IsEnabled = false;
|
||
TxtUserName.IsEnabled = false;
|
||
TxtPwd.IsEnabled = false;
|
||
int Edition = 0;
|
||
if (chk_log.IsChecked.Value == true)
|
||
{
|
||
Edition = 1;
|
||
}
|
||
if (chk_other.IsChecked.Value == true)
|
||
{
|
||
Edition = 2;
|
||
}
|
||
if ((_thread == null || !_thread.IsAlive) && !IsLogin)
|
||
{
|
||
IsLogin = true;
|
||
_thread = new Thread(() => Login_User(UserName, Pwd, Edition))
|
||
{
|
||
IsBackground = true
|
||
};
|
||
_thread.Start();
|
||
}
|
||
#endregion
|
||
break;
|
||
case "btnParameter":
|
||
#region 参数
|
||
ParameterPower _ParameterPower = new ParameterPower()
|
||
{
|
||
Owner = this
|
||
};
|
||
_ParameterPower.ShowDialog();
|
||
if (_ParameterPower.DialogResult == true)
|
||
{
|
||
//ParameterSetting _ParameterSetting = new ParameterSetting();
|
||
ParConfigtion _ParConfigtion = new ParConfigtion()
|
||
{
|
||
Owner = this
|
||
};
|
||
_ParConfigtion.ShowDialog();
|
||
QualityHelper.GetConfiguration();
|
||
}
|
||
#endregion
|
||
break;
|
||
case "btnScaveng":
|
||
#region 扫码配置参数
|
||
ScavengConfig _ScavengConfig = new ScavengConfig()
|
||
{
|
||
Owner = this
|
||
};
|
||
_ScavengConfig.ShowDialog();
|
||
#endregion
|
||
break;
|
||
case "btn_close":
|
||
#region 取消
|
||
UpLoadSwitch _UpLoadSwitch = new UpLoadSwitch()
|
||
{
|
||
Owner = this
|
||
};
|
||
if (_UpLoadSwitch.ShowDialog() == true)
|
||
{
|
||
DataUpload _DataUpload = new DataUpload()
|
||
{
|
||
Owner = this
|
||
};
|
||
_DataUpload.ShowDialog();
|
||
}
|
||
#endregion
|
||
break;
|
||
case "btnarport":
|
||
#region 查看状态
|
||
CashRegisterInf _CashRegisterInf = new CashRegisterInf()
|
||
{
|
||
Owner = this
|
||
};
|
||
_CashRegisterInf.ShowDialog();
|
||
#endregion
|
||
break;
|
||
case "btn_user":
|
||
#region 账号登录
|
||
Grid_LoginUser.Visibility = Visibility.Visible;
|
||
Grid_LoginFinger.Visibility = Visibility.Collapsed;
|
||
Grid_LoginFace.Visibility = Visibility.Collapsed;
|
||
gif_face.Visibility = Visibility.Collapsed;
|
||
gif_finger.Visibility = Visibility.Collapsed;
|
||
img_face.Visibility = Visibility.Visible;
|
||
img_finger.Visibility = Visibility.Visible;
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
if (Grid_keyboard.Margin == new Thickness(240, 453, 240, -23))
|
||
{
|
||
GetKeyboard();
|
||
}
|
||
#endregion
|
||
break;
|
||
case "btn_face":
|
||
#region 人脸识别登录
|
||
LostKeyboard();
|
||
Grid_LoginUser.Visibility = Visibility.Collapsed;
|
||
Grid_LoginFinger.Visibility = Visibility.Collapsed;
|
||
Grid_LoginFace.Visibility = Visibility.Visible;
|
||
gif_face.Visibility = Visibility.Collapsed;
|
||
gif_finger.Visibility = Visibility.Collapsed;
|
||
img_face.Visibility = Visibility.Visible;
|
||
img_finger.Visibility = Visibility.Visible;
|
||
TxtStateFace.Text = "正在连接识别器,请稍候..";
|
||
#endregion
|
||
break;
|
||
case "btn_finger":
|
||
#region 指纹识别登录
|
||
LostKeyboard();
|
||
Grid_LoginUser.Visibility = Visibility.Collapsed;
|
||
Grid_LoginFinger.Visibility = Visibility.Visible;
|
||
Grid_LoginFace.Visibility = Visibility.Collapsed;
|
||
gif_face.Visibility = Visibility.Collapsed;
|
||
gif_finger.Visibility = Visibility.Collapsed;
|
||
img_face.Visibility = Visibility.Visible;
|
||
img_finger.Visibility = Visibility.Visible;
|
||
TxtState.Text = "正在连接识别器,请稍候..";
|
||
#endregion
|
||
break;
|
||
case "btnDownDate":
|
||
#region 基础信息下载
|
||
Start();
|
||
#endregion
|
||
break;
|
||
case "btn_report":
|
||
new CommodityMenu("", 0, true) { Owner = this }.ShowDialog();
|
||
break;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> Textblock加载内容
|
||
private void GetValue(TextBlock _TextBlock, string txt, string colortxt)
|
||
{
|
||
GiveValue(_TextBlock, txt, colortxt);
|
||
}
|
||
|
||
void GiveValue(TextBlock _TextBlock, string txt, string colortxt)
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate
|
||
{
|
||
_TextBlock.Text = txt;
|
||
_TextBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString(colortxt));
|
||
//要执行的代码
|
||
});
|
||
}
|
||
#endregion
|
||
|
||
#region 事件 -> 键盘动画效果
|
||
private void TxtUserName_GotFocus_1(object sender, RoutedEventArgs e)
|
||
{
|
||
if (Grid_keyboard.Margin == new Thickness(240, 453, 240, -23))
|
||
{
|
||
GetKeyboard();
|
||
}
|
||
}
|
||
|
||
private void GetKeyboard()
|
||
{
|
||
//键盘弹出
|
||
System.Windows.Media.Animation.Storyboard storyboard_action = new System.Windows.Media.Animation.Storyboard();
|
||
storyboard_action.Stop();
|
||
storyboard_action.Children.Clear();
|
||
//添加动画
|
||
System.Windows.Media.Animation.ThicknessAnimation stb_1 = new System.Windows.Media.Animation.ThicknessAnimation(new Thickness(240, 453, 240, -23), new Thickness(240, 205, 243, -3), new Duration
|
||
(TimeSpan.FromSeconds(0.2)));
|
||
|
||
System.Windows.Media.Animation.Storyboard.SetTarget(stb_1, Grid_keyboard);
|
||
|
||
System.Windows.Media.Animation.Storyboard.SetTargetProperty(stb_1, new PropertyPath("Margin"));
|
||
|
||
storyboard_action.Children.Add(stb_1);
|
||
|
||
//添加动画2
|
||
System.Windows.Media.Animation.ThicknessAnimation stb_2 = new System.Windows.Media.Animation.ThicknessAnimation(new Thickness(265, 115, 263, 98), new Thickness(265, 0, 263, 98), new Duration
|
||
(TimeSpan.FromSeconds(0.2)));
|
||
|
||
System.Windows.Media.Animation.Storyboard.SetTarget(stb_2, Grid_User);
|
||
|
||
System.Windows.Media.Animation.Storyboard.SetTargetProperty(stb_2, new PropertyPath("Margin"));
|
||
|
||
storyboard_action.Children.Add(stb_2);
|
||
|
||
|
||
storyboard_action.Begin();
|
||
}
|
||
|
||
private void LostKeyboard()
|
||
{
|
||
if (Grid_keyboard.Margin == new Thickness(240, 205, 243, -3))
|
||
{
|
||
//键盘收起
|
||
System.Windows.Media.Animation.Storyboard storyboard_action = new System.Windows.Media.Animation.Storyboard();
|
||
storyboard_action.Stop();
|
||
storyboard_action.Children.Clear();
|
||
//添加动画
|
||
System.Windows.Media.Animation.ThicknessAnimation stb_1 = new System.Windows.Media.Animation.ThicknessAnimation(new Thickness(240, 205, 243, -3), new Thickness(240, 453, 240, -23), new Duration
|
||
(TimeSpan.FromSeconds(0.2)));
|
||
|
||
System.Windows.Media.Animation.Storyboard.SetTarget(stb_1, Grid_keyboard);
|
||
|
||
System.Windows.Media.Animation.Storyboard.SetTargetProperty(stb_1, new PropertyPath("Margin"));
|
||
|
||
storyboard_action.Children.Add(stb_1);
|
||
|
||
//添加动画2
|
||
System.Windows.Media.Animation.ThicknessAnimation stb_2 = new System.Windows.Media.Animation.ThicknessAnimation(new Thickness(265, 0, 263, 98), new Thickness(265, 115, 263, 98), new Duration
|
||
(TimeSpan.FromSeconds(0.2)));
|
||
|
||
System.Windows.Media.Animation.Storyboard.SetTarget(stb_2, Grid_User);
|
||
|
||
System.Windows.Media.Animation.Storyboard.SetTargetProperty(stb_2, new PropertyPath("Margin"));
|
||
|
||
storyboard_action.Children.Add(stb_2);
|
||
|
||
|
||
storyboard_action.Begin();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 登录
|
||
private void Login_User(string UserName, string Pwd, int Edition)
|
||
{
|
||
if (!LoginCheck())
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
//GetValue(TxtMessage, "登录校验失败,请重试!", "#FF0000");
|
||
LoginFail();
|
||
});
|
||
return;
|
||
}
|
||
if (string.IsNullOrWhiteSpace(QualityHelper.serverpartshop_id) ||
|
||
string.IsNullOrWhiteSpace(QualityHelper.businesstype))
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "门店信息初始化失败,请重试!", "#FF0000");
|
||
LoginFail();
|
||
});
|
||
return;
|
||
}
|
||
int _PersonResult = Currency.PersonLogin(UserName.Trim(), out string sellWorkerCode);
|
||
switch (_PersonResult)
|
||
{
|
||
case 0:
|
||
break;
|
||
case -1:
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "账期数据插入失败,请重试!", "#FF0000");
|
||
LoginFail();
|
||
});
|
||
return;
|
||
case -2:
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "工班数据插入失败,请重试!", "#FF0000");
|
||
LoginFail();
|
||
});
|
||
return;
|
||
case -3:
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "收银员[" + sellWorkerCode + "]未交班!", "#FF0000");
|
||
LoginFail();
|
||
});
|
||
return;
|
||
case -4:
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "账期数据插入失败,请重试!", "#FF0000");
|
||
LoginFail();
|
||
});
|
||
return;
|
||
case -5:
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "当前系统时间错误,请调整后重新登录!", "#FF0000");
|
||
LoginFail();
|
||
});
|
||
return;
|
||
}
|
||
|
||
if (QualityHelper.IsServerpart == "0")
|
||
{
|
||
try
|
||
{
|
||
if (DBHelper.QueryOdbc(@"SELECT 1 FROM T_ACTIVELOGGING
|
||
WHERE DATE(LOGGING_DATE) = TODAY() AND LOGGING_TYPE = 1000").Tables[0].Rows.Count == 0)
|
||
{
|
||
int _Maxid = 0;
|
||
try
|
||
{
|
||
_Maxid = int.Parse(DBHelper.QueryOdbc("select max(activelogging_id) from t_activelogging").Tables[0].Rows[0][0].ToString());
|
||
}
|
||
catch
|
||
{
|
||
_Maxid = 0;
|
||
}
|
||
string _strInsert = String.Format("insert into t_activelogging (activelogging_id,serverpartcode,shopcode," +
|
||
"machinecode,machinename,macaddress,logging_date,running_interval,logging_type) values " +
|
||
"({0},'{1}','{2}','{3}','{4}','{5}',datetime('{6}'), 0, 1000)", _Maxid + 1, QualityHelper.serverpartcode,
|
||
QualityHelper.shopcode, QualityHelper.machinecode, Dns.GetHostName(),
|
||
ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation(),
|
||
DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo));
|
||
DBHelper.ExecuteSqlTran(_strInsert);
|
||
object[] _args = { QualityHelper.serverpartcode, QualityHelper.shopcode, QualityHelper.machinecode,"0", "0",
|
||
DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo), QualityHelper.shopname };
|
||
ESSupport.Lib.WSHelper.InvokeWebService(String.Format("http://{0}:{1}/service.asmx", "60.191.61.29", "7081"), "endaccountinfo", _args);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteServiceLog("便利店登录推送:" + ex.Message);
|
||
}
|
||
}
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
//对页面元素的操作
|
||
if (QualityHelper.IsGrocery == "1")
|
||
{
|
||
QualityHelper.UpdateConfigUration("IsTouch", "1");
|
||
QualityHelper.IsTouch = "1";
|
||
CommoditySaleCashier _CommoditySaleCashier = new CommoditySaleCashier(TxtUserName.Text.ToUpper());
|
||
_CommoditySaleCashier.Show();
|
||
Close();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
if (chk_log.IsChecked == true)
|
||
{
|
||
CommoditySaleCashier _CommoditySaleCashier = new CommoditySaleCashier(TxtUserName.Text.ToUpper());
|
||
_CommoditySaleCashier.Show();
|
||
Close();
|
||
}
|
||
else if (chk_other.IsChecked == true)
|
||
{
|
||
CommoditySaleOther _CommoditySaleOther = new CommoditySaleOther(TxtUserName.Text.ToUpper());
|
||
_CommoditySaleOther.Show();
|
||
Close();
|
||
}
|
||
}
|
||
});
|
||
}
|
||
#endregion
|
||
|
||
#region 事件 -> 收银员版获取焦点
|
||
private void chk_log_Click_1(object sender, RoutedEventArgs e)
|
||
{
|
||
if (chk_log.IsChecked == true)
|
||
{
|
||
if (Grid_keyboard.Margin == new Thickness(240, 205, 243, -3))
|
||
{
|
||
LostKeyboard();
|
||
}
|
||
chk_other.IsChecked = false;
|
||
QualityHelper.UpdateConfigUration("IsTouch", "1");
|
||
QualityHelper.IsTouch = "1";
|
||
}
|
||
else
|
||
{
|
||
if (Grid_keyboard.Margin == new Thickness(240, 205, 243, -3))
|
||
{
|
||
LostKeyboard();
|
||
}
|
||
chk_other.IsChecked = true;
|
||
chk_log.IsChecked = false;
|
||
QualityHelper.UpdateConfigUration("IsTouch", "0");
|
||
QualityHelper.IsTouch = "0";
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 点击页面空余地方键盘自动收起
|
||
private void Window_MouseDown_1(object sender, MouseButtonEventArgs e)
|
||
{
|
||
if (Grid_keyboard.Margin == new Thickness(240, 205, 243, -3))
|
||
{
|
||
LostKeyboard();
|
||
}
|
||
txt_focus.Focus();
|
||
txt_focus.SelectAll();
|
||
}
|
||
#endregion
|
||
|
||
#region 事件 -> 其他版获取焦点
|
||
private void chk_other_Click_1(object sender, RoutedEventArgs e)
|
||
{
|
||
if (chk_other.IsChecked == true)
|
||
{
|
||
if (Grid_keyboard.Margin == new Thickness(240, 205, 243, -3))
|
||
{
|
||
LostKeyboard();
|
||
}
|
||
chk_log.IsChecked = false;
|
||
QualityHelper.UpdateConfigUration("IsTouch", "0");
|
||
QualityHelper.IsTouch = "0";
|
||
}
|
||
else
|
||
{
|
||
if (Grid_keyboard.Margin == new Thickness(240, 205, 243, -3))
|
||
{
|
||
LostKeyboard();
|
||
}
|
||
chk_log.IsChecked = true;
|
||
chk_other.IsChecked = false;
|
||
QualityHelper.UpdateConfigUration("IsTouch", "1");
|
||
QualityHelper.IsTouch = "1";
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 获取最大编号
|
||
private int GetMaxCode(string StrSql)
|
||
{
|
||
//获取最大编号并加1
|
||
DataTable _DataTable = DBHelper.QueryOdbc(StrSql).Tables[0];
|
||
int MaxCode = 0;
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
try
|
||
{
|
||
MaxCode = int.Parse(_DataTable.Rows[0][0].ToString()) + 1;
|
||
}
|
||
catch
|
||
{
|
||
MaxCode = 1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MaxCode = 1;
|
||
}
|
||
return MaxCode;
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 键盘快捷键
|
||
private void Window_KeyDown_1(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.SystemKey == Key.F4)
|
||
{
|
||
e.Handled = true;
|
||
}
|
||
switch (e.Key)
|
||
{
|
||
case Key.Escape:
|
||
Button_Click(btn_close, null);
|
||
break;
|
||
case Key.F1:
|
||
Button_Click(btnarport, null);
|
||
break;
|
||
case Key.F2:
|
||
if (chk_other.IsChecked == true)
|
||
{
|
||
chk_log.IsChecked = true;
|
||
chk_log_Click_1(null, null);
|
||
}
|
||
else
|
||
{
|
||
chk_other.IsChecked = true;
|
||
chk_other_Click_1(null, null);
|
||
}
|
||
break;
|
||
case Key.F3:
|
||
Button_Click(btnScaveng, null);
|
||
break;
|
||
case Key.F4:
|
||
Button_Click(btnParameter, null);
|
||
break;
|
||
case Key.F5:
|
||
Button_Click(btn_report, null);
|
||
break;
|
||
case Key.Down:
|
||
TxtUserName.Focus();
|
||
if (Grid_keyboard.Margin == new Thickness(240, 453, 240, -23))
|
||
{
|
||
GetKeyboard();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 登录数据校验验证
|
||
/// <summary>
|
||
/// 登录账期班期数据验证
|
||
/// </summary>
|
||
/// <param name="person">登录工号</param>
|
||
/// <returns></returns>
|
||
private bool LoginCheck()
|
||
{
|
||
try
|
||
{
|
||
OracleHelper _OracleHelper = new OracleHelper(QualityHelper.dbip, QualityHelper.dbport, QualityHelper.conname, QualityHelper.dbuser, QualityHelper.dbpass);
|
||
PosControl.OracleServer = new OracleHelper(QualityHelper.dbip, QualityHelper.dbport, QualityHelper.conname, QualityHelper.dbuser, QualityHelper.dbpass);
|
||
//判断本地数据库连接
|
||
try
|
||
{
|
||
DataTable _DataTable = DBHelper.QueryOdbc("select * from dba.sys_globle").Tables[0];
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "本地数据库无法连接,请重试!", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
});
|
||
return false;
|
||
}
|
||
//判断收银机配置
|
||
if (QualityHelper.serverpartcode == "" || QualityHelper.shopcode == "" || QualityHelper.machinecode == "")
|
||
{
|
||
//参数错误
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "收银系统配置不正确,请前往参数页面修改!", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
});
|
||
return false;
|
||
}
|
||
|
||
//与服务器校对时间
|
||
try
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "正在校准系统时间......", "#FF0000");
|
||
});
|
||
DateTime _ServerTime = ESSupport.Lib.HttpHelper.GetBeijingTime($"http://{QualityHelper.dbip}:{QualityHelper.serviceport}/Service.asmx");
|
||
if (_ServerTime != DateTime.MinValue && _ServerTime > new DateTime(2020, 06, 01))
|
||
{
|
||
SyTime.SetLocalTimeByStr(_ServerTime);
|
||
QualityHelper.UpdateConfigUration("syncdtime", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||
}
|
||
}
|
||
catch { }
|
||
|
||
//判断当前时间是否小于上次登录时间
|
||
DateTime _DateTime = new DateTime(2018, 01, 01, 00, 00, 00);
|
||
|
||
string _strLocalDate = QualityHelper.ConfigurationValues("syncdtime", "2018/01/01 00:00:00");
|
||
|
||
DateTime _LocalDate;
|
||
if (DateTime.TryParse(_strLocalDate, out _LocalDate))
|
||
{
|
||
if (DateTime.Now >= _LocalDate)
|
||
{
|
||
QualityHelper.UpdateConfigUration("syncdtime", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||
}
|
||
else
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "当前系统时间错误,请调整后重新登录!", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
});
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//系统第一次启动,判断是否小于预设时间
|
||
if (DateTime.Now >= _DateTime)
|
||
{
|
||
QualityHelper.UpdateConfigUration("syncdtime", DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
|
||
}
|
||
else
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "当前系统时间错误,请调整后重新登录!", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
});
|
||
return false;
|
||
}
|
||
}
|
||
//判断软件到期时间
|
||
try
|
||
{
|
||
string _strUsingType = QualityHelper.ConfigurationValues("using_type", "1000");
|
||
decimal _WarnDay = 0;
|
||
decimal.TryParse(QualityHelper.ConfigurationValues("expiry_day", "15"), out _WarnDay);
|
||
if (_WarnDay == 0)
|
||
{
|
||
_WarnDay = 15;
|
||
}
|
||
DateTime _SoftExpiryDate;
|
||
if (!DateTime.TryParse(QualityHelper.ConfigurationValues("expirydate", ""), out _SoftExpiryDate))
|
||
{
|
||
try
|
||
{
|
||
_SoftExpiryDate = DateTime.Parse(DBHelper.QueryOdbc("SELECT EXPIRY_DATE " +
|
||
"FROM SYS_GLOBLE WHERE VAR_NAME = 'g_ver'").Tables[0].Rows[0]["expiry_date"].ToString());
|
||
}
|
||
catch { }
|
||
}
|
||
if (_SoftExpiryDate != DateTime.MinValue)
|
||
{
|
||
if (DateTime.Today > _SoftExpiryDate)
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, (_strUsingType == "2000" ? "您租赁的设备已到期" : "您购买的设备软件版本已到期") + ",请及时续费!", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
});
|
||
return false;
|
||
}
|
||
int _RemainingTime = (int)_SoftExpiryDate.Subtract(DateTime.Today).TotalDays;
|
||
if (_RemainingTime <= _WarnDay)
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, (_strUsingType == "2000" ? "您租赁的设备剩余【" : "您购买的设备软件版本剩余【") +
|
||
_RemainingTime + "】天到期,请及时续费!", "#FF0000");
|
||
TxtUserName.Focus();
|
||
});
|
||
MessageBoxResult _Result = MessageBox.Show((_strUsingType == "2000" ? "您租赁的设备剩余【" : "您购买的设备软件版本剩余【") +
|
||
_RemainingTime + "】天过期,请及时续费!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information,
|
||
MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteServiceLog("软件有效期检测错误:" + ex.Message);
|
||
}
|
||
|
||
//判断门店状态
|
||
DataTable _ShopTable = ESSupport.Lib.SyBaseHelper.QueryOdbc(
|
||
$@"SELECT SERVERPARTSHOP_ID,SHOPNAME,BUSINESSTYPE,VALID
|
||
FROM T_SHOPMESSAGE WHERE SHOPCODE = '{QualityHelper.shopcode}' AND
|
||
SERVERPARTCODE = '{QualityHelper.serverpartcode}'").Tables[0];
|
||
if (_ShopTable.Rows.Count > 0)
|
||
{
|
||
QualityHelper.serverpartshop_id = _ShopTable.Rows[0]["SERVERPARTSHOP_ID"].ToString();
|
||
QualityHelper.shopname = _ShopTable.Rows[0]["SHOPNAME"].ToString();
|
||
QualityHelper.businesstype = _ShopTable.Rows[0]["BUSINESSTYPE"].ToString();
|
||
if (_ShopTable.Rows[0]["VALID"].ToString() != "1")
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "该门店已停业", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
});
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, "门店信息未下载!", "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
DownDateThread = new Thread(CheckDate)
|
||
{
|
||
IsBackground = true
|
||
};
|
||
DownDateThread.Start();
|
||
TxtUserName.Focus();
|
||
});
|
||
return false;
|
||
}
|
||
|
||
if (QualityHelper.IsServerpart == "1")
|
||
{
|
||
try
|
||
{
|
||
//DataTable _ConfigTable = _OracleHelper.ExcuteSqlGetDataSet(
|
||
// $@"SELECT CONFIGURATION_VALUES
|
||
// FROM {QualityHelper.dbuser}.T_CONFIGURATION
|
||
// WHERE MACADDRESS = '{ESSupport.Lib.PCHelper.GetMacAddressByNetworkInformation()}' AND
|
||
// UPPER(CONFIGURATION_NAME) = 'MOBILEPAYOPERATORS'").Tables[0];
|
||
//if (_ConfigTable.Rows.Count == 0)
|
||
//{
|
||
if (PosSystemHelper.MobilePayConfigUpdate(new string[] { string.Format("http://{0}:{1}/service.asmx",
|
||
QualityHelper.dbip, QualityHelper.DataServicePort) }, QualityHelper.serverpartcode, QualityHelper.businesstype) == -1)
|
||
{
|
||
MessageBoxResult _Result = MessageBox.Show("服务端移动支付服务通道未配置,请联系系统管理员", "系统提示",
|
||
MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.ServiceNotification);
|
||
}
|
||
//}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteServiceLog(ex.Message);
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.WriteServiceLog("登录验证异常:" + ex.Message);
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
GetValue(TxtMessage, ex.Message, "#FF0000");
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
TxtUserName.Focus();
|
||
});
|
||
return false;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
private void LoginFail()
|
||
{
|
||
btn_login.IsEnabled = true;
|
||
btn_close.IsEnabled = true;
|
||
btnParameter.IsEnabled = true;
|
||
TxtUserName.IsEnabled = true;
|
||
stp_name.Visibility = Visibility.Visible;
|
||
stp_pwd.Visibility = Visibility.Visible;
|
||
stp_img.Visibility = Visibility.Collapsed;
|
||
stp_title.Visibility = Visibility.Visible;
|
||
TxtPwd.IsEnabled = true;
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
Grid_wf.Visibility = Visibility.Collapsed;
|
||
Grid_User.Visibility = Visibility.Visible;
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
IsLogin = false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 下载监听回调
|
||
/// </summary>
|
||
/// <param name="downResultInfo"></param>
|
||
/// <param name="resultString"></param>
|
||
private void DownStringEvent(DownResultInfo downResultInfo, string resultString)
|
||
{
|
||
int _DownCount = _ClientThread.getStartDownTypes().Count;
|
||
if (!downResultInfo.StartToEnd)
|
||
{
|
||
Downing++;
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate
|
||
{
|
||
pbrDown.Value = (double)Downing / _DownCount;
|
||
});
|
||
}
|
||
if (Downing == _DownCount)
|
||
{
|
||
//QualityHelper.GetDate();
|
||
QualityHelper.GetConfiguration();
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate
|
||
{
|
||
Grid_Load.Visibility = Visibility.Collapsed;
|
||
pbrDown.Value = 0;
|
||
GetValue(TxtMessage, "基础信息下载完成!", "#FF0000");
|
||
this.IsEnabled = true;
|
||
TxtUserName.Focus();
|
||
TxtUserName.SelectAll();
|
||
});
|
||
}
|
||
}
|
||
|
||
#region 方法 -> 校验数据库
|
||
/// <summary>
|
||
/// 数据库升级校验
|
||
/// </summary>
|
||
private void GetDate()
|
||
{
|
||
try
|
||
{
|
||
ESSupport.Lib.DataBaseUpdate.PosDataBaseUpdate();
|
||
try
|
||
{
|
||
ESSupport.Lib.SyBaseHelper.ExecuteSqlTran(new List<string>
|
||
{
|
||
@"UPDATE T_COMMODITYSALE_NEW A
|
||
SET A.COMMODITY_SYMBOL = B.COMMODITY_SYMBOL
|
||
FROM T_COMMODITYEX B
|
||
WHERE A.COMMODITY_CODE = B.COMMODITY_CODE AND
|
||
A.COMMODITY_SYMBOL IS NULL" ,
|
||
@"UPDATE T_SELLDETAILS A
|
||
SET A.COMMODITY_TYPE = B.COMMODITY_TYPE,
|
||
A.COMMODITY_SYMBOL = B.COMMODITY_SYMBOL
|
||
FROM T_COMMODITYEX B
|
||
WHERE A.COMMODITY_CODE = B.COMMODITY_CODE AND
|
||
A.COMMODITY_SYMBOL IS NULL AND A.COMMODITY_TYPE IS NULL",
|
||
@"UPDATE T_ABNORMALITY A
|
||
SET A.TRANSFER_STATE = 0
|
||
WHERE A.TRANSFER_STATE = 2 AND EXISTS (
|
||
SELECT 1 FROM T_ABNORMALITY B
|
||
WHERE A.ABNORMALITY_CODE = B.ABNORMALITY_PCODE AND
|
||
B.ABNORMALITY_TYPE = 1099 )"
|
||
});
|
||
}
|
||
catch { }
|
||
//ESSupport.Lib.OracleHelper _OracleHelper = new ESSupport.Lib.OracleHelper(QualityHelper.dbip, QualityHelper.dbport,
|
||
// QualityHelper.conname, QualityHelper.dbuser, QualityHelper.dbpass);
|
||
//ESSupport.Lib.DataBaseUpdate.ServerDataBaseUpdate(QualityHelper.dbname, _OracleHelper);
|
||
if (QualityHelper.IsGrocery == "0" || QualityHelper.data_delete == "1")
|
||
{
|
||
DataTable _DataTable = DBHelper.QueryOdbc("SELECT SERVERPARTSHOP_ID FROM T_SHOPMESSAGE " +
|
||
"WHERE SERVERPARTCODE = '" + QualityHelper.serverpartcode + "' AND SHOPCODE = '" + QualityHelper.shopcode + "'").Tables[0];
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
string _ServerPartShopID = _DataTable.Rows[0]["SERVERPARTSHOP_ID"].ToString();
|
||
ESSupport.Lib.DataBaseUpdate.ClearData(QualityHelper.serverpartcode,
|
||
QualityHelper.shopcode, _ServerPartShopID, int.Parse(QualityHelper.effective_day));
|
||
}
|
||
}
|
||
try
|
||
{
|
||
ESSupport.Lib.DataBaseUpdate.ClearDataBackup(
|
||
AppDomain.CurrentDomain.BaseDirectory + "\\DataBackup",
|
||
int.Parse(QualityHelper.effective_day), true);
|
||
}
|
||
catch { }
|
||
}
|
||
catch
|
||
{ }
|
||
}
|
||
#endregion
|
||
|
||
#region 方法 -> 检测数据是否存在并启动下发线程
|
||
private void CheckDate()
|
||
{
|
||
try
|
||
{
|
||
string _SelectSql = String.Format("SELECT SELLWORKERCODE,COUNT(SELLWORKERCODE) " +
|
||
"FROM T_SELLWORKER WHERE SERVERPARTCODE = '{0}' GROUP BY SELLWORKERCODE " +
|
||
"HAVING COUNT(SELLWORKERCODE) > 1", QualityHelper.serverpartcode);
|
||
//删除错误工号数据
|
||
try
|
||
{
|
||
DBHelper.ExecuteSqlTran("DELETE FROM T_SELLWORKER WHERE DATALENGTH(PROWERRIGHT) < 255");
|
||
}
|
||
catch { }
|
||
_SelectSql = "SELECT SHOPMESSAGE_ID FROM T_SHOPMESSAGE WHERE SERVERPARTCODE = '" +
|
||
QualityHelper.serverpartcode + "' AND SHOPCODE = '" + QualityHelper.shopcode + "'";
|
||
DataTable _ShopMessageTable = DBHelper.QueryOdbc(_SelectSql).Tables[0];
|
||
_SelectSql = String.Format("SELECT 1 FROM T_SELLWORKER WHERE SERVERPARTCODE = '{0}'", QualityHelper.serverpartcode);
|
||
DataTable _SellWorkerTable = DBHelper.QueryOdbc(_SelectSql).Tables[0];
|
||
if (_ShopMessageTable.Rows.Count == 0 || _SellWorkerTable.Rows.Count == 0)
|
||
{
|
||
DBHelper.ExecuteSqlTran(new List<string> { "DELETE FROM T_DOWNUPDATE", "DELETE FROM T_SELLWORKER", "DELETE FROM T_SHOPMESSAGE" });
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
Start();
|
||
});
|
||
}
|
||
try
|
||
{
|
||
if (QualityHelper.HDModelSwitch != "1")
|
||
{
|
||
string _ServiceUrl = "http://" + QualityHelper.dbip + ":" + QualityHelper.DataServicePort + "/DataServices/Service.asmx";
|
||
System.Collections.Hashtable hashtable = new System.Collections.Hashtable
|
||
{
|
||
{ "serverPartShop_id", QualityHelper.serverpartshop_id }
|
||
};
|
||
DataTable _DataTable = ESSupport.Lib.JsonHelper.ToDataTable(
|
||
ESSupport.Lib.SoapWSHelper.QuerySoapWebServiceString(_ServiceUrl, "CommodityDeduplication", hashtable));
|
||
if (_DataTable.Rows.Count > 0)
|
||
{
|
||
string _CommodityID = "";
|
||
for (int i = 0; i < _DataTable.Rows.Count; i++)
|
||
{
|
||
_CommodityID += (_CommodityID == "" ? "" : ",") + _DataTable.Rows[i]["COMMODITYEX_ID"].ToString();
|
||
}
|
||
DBHelper.ExecuteSqlTran(string.Format("DELETE FROM T_COMMODITYEX WHERE COMMODITYEX_ID IN ({0})", _CommodityID));
|
||
}
|
||
}
|
||
}
|
||
catch { }
|
||
try
|
||
{
|
||
//启动时删除重复商品条码,并设置重新获取商品数据
|
||
ESSupport.Lib.SyBaseHelper.ExecuteSqlTran(
|
||
@"DELETE FROM T_COMMODITYEX
|
||
WHERE COMMODITY_BARCODE IN(
|
||
SELECT A.COMMODITY_BARCODE
|
||
FROM T_COMMODITYEX A
|
||
--WHERE A.ISVALID = 1
|
||
GROUP BY A.SERVERPARTCODE,A.COMMODITY_BARCODE
|
||
HAVING COUNT(COMMODITY_BARCODE) > 1)");
|
||
ESSupport.Lib.SyBaseHelper.ExecuteSqlTran("DELETE FROM T_DOWNUPDATE");
|
||
}
|
||
catch { }
|
||
}
|
||
catch
|
||
{
|
||
this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate ()
|
||
{
|
||
Start();
|
||
});
|
||
}
|
||
}
|
||
private void Start()
|
||
{
|
||
GridLoad.Visibility = Visibility.Collapsed;
|
||
ConfigThread _ConfigThread = new ConfigThread(QualityHelper.serverpartcode);
|
||
_ClientThread.setConfiguration("http://" + QualityHelper.dbip + ":" + QualityHelper.DataServicePort + "/DataServices/Service.asmx",
|
||
QualityHelper.authorization, QualityHelper.serverpartcode, "",
|
||
QualityHelper.shopcode, QualityHelper.macaddress, QualityHelper.machinecode, 400, 5, 20);
|
||
List<string> _DownList = new List<string>();
|
||
//if (QualityHelper.serverpartcode == "888888")
|
||
//{
|
||
// _DownList = new List<string>() { "T_SELLWORKER_UNIT", "T_SELLWORKER_CLOUD", "T_SHOPMESSAGE_EX", "T_CONFIGURATION" };
|
||
//}
|
||
//else
|
||
//{
|
||
// _DownList = new List<string>() { "T_SELLWORKER", "T_SELLWORKER_UNIT", "T_SELLWORKER_CLOUD", "T_SHOPMESSAGE", "T_SHOPMESSAGE_EX", "T_CONFIGURATION" };
|
||
//}
|
||
|
||
_ClientThread.IsDownload(true, new List<string>() { "T_SELLWORKER", "T_SHOPMESSAGE", "T_CONFIGURATION" });
|
||
_ClientThread.IsDownload(true, _DownList);
|
||
|
||
_ClientThread.setConfigThread(_ConfigThread);
|
||
_ClientThread.DownloadStringEvent += new ClientThread.OutputResultsDownArg(DownStringEvent);//监听上传事件
|
||
bool b = _ClientThread.onState();
|
||
Downing = 0;
|
||
Grid_Load.Visibility = Visibility.Visible;
|
||
this.IsEnabled = false;
|
||
TxtLoad.Text = "正在下载基础信息,请稍候...";
|
||
if (!b)
|
||
{
|
||
Grid_Load.Visibility = Visibility.Collapsed;
|
||
this.IsEnabled = true;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|