Add project files.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1 @@
|
||||
12
|
||||
@@ -0,0 +1,20 @@
|
||||
<UserControl x:Class="SafeBagDE70.CollectionUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<hc:SimpleStackPanel Background="White" VerticalAlignment="Center" Margin="20">
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Red" Text="TÚI ĐÃ ĐẦY, HÃY THỰC HIỆN LẤY TÚI TIỀN RA KHỎI MÁY:" HorizontalAlignment="Center"/>
|
||||
<Separator/>
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Blue" Text="1. KIỂM TRA VÀ LẤY TIỀN KHỎI TẤT CẢ CÁC NGĂN"/>
|
||||
<Separator/>
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Blue" Text="2. THỰC HIỆN LẤY TÚI TIỀN RA KHỎI MÁY (NẾU BẠN LÀ NHÂN VIÊN VIETINBANK)"/>
|
||||
<Separator/>
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Blue" Text="3. ẤN THIẾT LẬP BỘ ĐẾM (NẾU BẠN LÀ NHÂN VIÊN VIETINBANK)"/>
|
||||
<Separator/>
|
||||
</hc:SimpleStackPanel>
|
||||
</UserControl>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,189 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
using SafeBagDE70.Services;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
///
|
||||
public partial class MainWindow : HandyControl.Controls.Window
|
||||
{
|
||||
private WelcomeUC _welcomeUC;
|
||||
private DepositSMUCv2 _depositUC;
|
||||
private CollectionUC _collectionUC;
|
||||
private InformationUC _informationUC;
|
||||
private ErrorUC _errorUC;
|
||||
private UserControl _currentUC;
|
||||
private UserControl _prevUC;
|
||||
private TimeoutUC _timeoutUC;
|
||||
private MaintainanceUC _maintainanceUC;
|
||||
private EndSessionUC _endSessionUC;
|
||||
private object objLock = new object();
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += MainWindow_Loaded;
|
||||
}
|
||||
|
||||
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.Init();
|
||||
if (_welcomeUC == null) _welcomeUC = new WelcomeUC();
|
||||
if (_collectionUC == null) _collectionUC = new CollectionUC();
|
||||
if (_informationUC == null) _informationUC = new InformationUC();
|
||||
if (_errorUC == null) _errorUC = new ErrorUC();
|
||||
if (_depositUC == null) _depositUC = new DepositSMUCv2();
|
||||
if (_timeoutUC == null) _timeoutUC = new TimeoutUC();
|
||||
if (_maintainanceUC == null) _maintainanceUC = new MaintainanceUC();
|
||||
if (_endSessionUC == null) _endSessionUC = new EndSessionUC();
|
||||
|
||||
|
||||
gridMain.Children.Add(_welcomeUC);
|
||||
gridMain.Children.Add(_depositUC);
|
||||
gridMain.Children.Add(_collectionUC);
|
||||
gridMain.Children.Add(_informationUC);
|
||||
gridMain.Children.Add(_errorUC);
|
||||
gridMain.Children.Add(_timeoutUC);
|
||||
gridMain.Children.Add(_maintainanceUC);
|
||||
gridMain.Children.Add(_endSessionUC);
|
||||
|
||||
ShowWelcomeScreen();
|
||||
//ShowDepositScreen();
|
||||
}
|
||||
|
||||
public void HideAll()
|
||||
{
|
||||
lock(objLock)
|
||||
{
|
||||
foreach (var item in gridMain.Children)
|
||||
{
|
||||
if (item != null)
|
||||
(item as UserControl).Visibility = Visibility.Hidden;
|
||||
}
|
||||
//_collectionUC.Visibility = Visibility.Hidden;
|
||||
//_informationUC.Visibility = Visibility.Hidden;
|
||||
//_errorUC.Visibility = Visibility.Hidden;
|
||||
//_depositUC.Visibility = Visibility.Hidden;
|
||||
//_welcomeUC.Visibility = Visibility.Hidden;
|
||||
//_maintainanceUC.Visibility=Visibility.Hidden;
|
||||
//_endSessionUC.Visibility = Visibility.Hidden;
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
|
||||
}
|
||||
public void ShowEndSessionScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
HideAll();
|
||||
_endSessionUC.Visibility= Visibility.Visible;
|
||||
}
|
||||
public void ShowInformationScreen(string strInfor,bool bContinue=false,bool bPlaySound=true,List<Control> lstControls=null)
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _informationUC;
|
||||
HideAll();
|
||||
_informationUC.Visibility = Visibility.Visible;
|
||||
_informationUC.ShowInfor(strInfor, bContinue, bPlaySound,lstControls);
|
||||
}
|
||||
public void ShowErrorScreen(string strError)
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _errorUC;
|
||||
HideAll();
|
||||
_errorUC.Visibility = Visibility.Visible;
|
||||
_errorUC.ShowInfor(strError);
|
||||
}
|
||||
public void ShowWelcomeScreen()
|
||||
{
|
||||
_depositUC.StopTimers();
|
||||
_depositUC.StopWelcomeTimer();
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _welcomeUC;
|
||||
HideAll();
|
||||
_welcomeUC.Init();
|
||||
|
||||
_welcomeUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void ShowDepositScreen(bool bInit=true)
|
||||
{
|
||||
_depositUC.ResetTimers();
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _depositUC;
|
||||
HideAll();
|
||||
_depositUC.Visibility = Visibility.Visible;
|
||||
if(bInit)
|
||||
{
|
||||
_depositUC.EndTransaction();
|
||||
_depositUC.InitTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowCollectionScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _collectionUC;
|
||||
HideAll();
|
||||
_collectionUC.Init();
|
||||
_collectionUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public bool IsMaintainanceScreen()
|
||||
{
|
||||
return _currentUC == _maintainanceUC;
|
||||
}
|
||||
public DepositSMUCv2 GetDepositScreen()
|
||||
{
|
||||
return _depositUC;
|
||||
}
|
||||
public void ShowMaintainanceScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
HideAll();
|
||||
_maintainanceUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void ShowTimeoutScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
HideAll();
|
||||
_timeoutUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void StopTimers()
|
||||
{
|
||||
_depositUC.StopTimers();
|
||||
}
|
||||
|
||||
public bool DoCheck()
|
||||
{
|
||||
return _depositUC.DoCheck();
|
||||
}
|
||||
public void ResetTimers()
|
||||
{
|
||||
_depositUC.ResetTimers();
|
||||
}
|
||||
public void BackScreen()
|
||||
{
|
||||
HideAll();
|
||||
_prevUC.Visibility = Visibility.Visible;
|
||||
_currentUC = _prevUC;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,211 @@
|
||||
using CoreScanner;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeWindow.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeUC : UserControl
|
||||
{
|
||||
public string? QRCodeContent = null;
|
||||
public string? PinCode = null;
|
||||
public bool IsAuthenticated = false;
|
||||
public CCoreScannerClass? cCoreScannerClass=null;
|
||||
public WelcomeUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitQRCodeScanner();
|
||||
}
|
||||
private void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string pin = PinCodeBox.Password;
|
||||
|
||||
if (ValidatePin(pin))
|
||||
{
|
||||
PinCode=PinCodeBox.Password.ToString();
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (PinCode != null)
|
||||
{
|
||||
var strPincode = PinCode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
//DialogResult = true;
|
||||
//this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblPincodeError.Content = "PINCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid PIN. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ForgotPin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Forgot PIN clicked.");
|
||||
}
|
||||
|
||||
private void Help_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Help clicked.");
|
||||
}
|
||||
|
||||
private bool ValidatePin(string pin)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
private async void PinCodeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var onScreenKeyboardProcess = new ProcessStartInfo("osk.exe")
|
||||
{
|
||||
UseShellExecute = true
|
||||
};
|
||||
Process.Start(onScreenKeyboardProcess);
|
||||
try
|
||||
{
|
||||
//var progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
|
||||
//var keyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
|
||||
//Process.Start(keyboardPath);
|
||||
// AutomationElement.FromHandle(-1);
|
||||
|
||||
// string keyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
|
||||
// Process.Start(keyboardPath);
|
||||
//await Launcher.LaunchUriAsync(new Uri("ms-inputapp://"));
|
||||
|
||||
//var onScreenKeyboardProcess = new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
|
||||
//{
|
||||
// UseShellExecute = true
|
||||
//};
|
||||
//Process.Start(onScreenKeyboardProcess);
|
||||
|
||||
QrCodePanel.Visibility = Visibility.Collapsed;
|
||||
PinCodePanel.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void btnQRCodeLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PinCodePanel.Visibility = Visibility.Collapsed;
|
||||
QrCodePanel.Visibility=Visibility.Visible;
|
||||
cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
|
||||
|
||||
}
|
||||
public void InitQRCodeScanner()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Instantiate CoreScanner Class
|
||||
cCoreScannerClass = new CCoreScannerClass();
|
||||
|
||||
// Call Open API
|
||||
short[] scannerTypes = new short[1]; // Scanner Types you are interested in
|
||||
scannerTypes[0] = 1; // 1 for all scanner types
|
||||
short numberOfScannerTypes = 1; // Size of the scannerTypes array
|
||||
int status; // Extended API return code
|
||||
|
||||
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
|
||||
|
||||
// Subscribe for barcode events in cCoreScannerClass
|
||||
|
||||
|
||||
// Let's subscribe for events
|
||||
int opcode = 1001; // Method for Subscribe events
|
||||
string outXML; // XML Output
|
||||
string inXML = "<inArgs>" +
|
||||
"<cmdArgs>" +
|
||||
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
|
||||
"<arg-int>1</arg-int>" + // Comma separated event IDs
|
||||
"</cmdArgs>" +
|
||||
"</inArgs>";
|
||||
|
||||
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("Something wrong please check... " + exp.Message);
|
||||
}
|
||||
}
|
||||
private void OnBarcodeEvent(short eventType, ref string pscanData)
|
||||
{
|
||||
string xmlString = pscanData;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(xmlString);
|
||||
|
||||
XmlNode rawDataNode = xmlDoc.SelectSingleNode("//datalabel");
|
||||
string rawDataHex = rawDataNode.InnerText.Trim();
|
||||
|
||||
QRCodeContent = HexStringToString(rawDataHex);
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
||||
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (QRCodeContent != null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == QRCodeContent).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
//DialogResult = true;
|
||||
//this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblQRcodeError.Content = "QRCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static string HexStringToString(string hexString)
|
||||
{
|
||||
string[] hexValues = hexString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] bytes = new byte[hexValues.Length];
|
||||
|
||||
for (int i = 0; i < hexValues.Length; i++)
|
||||
{
|
||||
bytes[i] = Convert.ToByte(hexValues[i], 16);
|
||||
}
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,826 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
using SafeBagDE70.Model;
|
||||
using HandyControl.Tools;
|
||||
using System.Drawing.Printing;
|
||||
using System.Drawing;
|
||||
using static HandyControl.Tools.Interop.InteropValues;
|
||||
using SafeBagDE70.API;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using DE70_CMDv2;
|
||||
using System.Configuration;
|
||||
|
||||
|
||||
namespace SafeBagDE70
|
||||
{ //Summary
|
||||
|
||||
|
||||
public partial class DepositUC : UserControl
|
||||
{
|
||||
SerialPort serialPortDE70 = new SerialPort();
|
||||
SerialPort serialPortSensor= new SerialPort();
|
||||
|
||||
List<CountSession> sessions = new List<CountSession>();
|
||||
ObservableCollection<LvCountItem> lvCountItems = new ObservableCollection<LvCountItem>();
|
||||
private DispatcherTimer timer;
|
||||
private DispatcherTimer sensorTimer;
|
||||
|
||||
int countTimer = 0;
|
||||
CCmdRsp cCmdRsp = null;
|
||||
bool bInitialized = false;
|
||||
|
||||
|
||||
public DepositUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InitTransaction();
|
||||
|
||||
}
|
||||
public void InitTransaction()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (AppData.IsAuthenticated)
|
||||
{
|
||||
lblUser.Content = $"Xin chào khách hàng: {AppData.CurrentCustomerAccount.Name} (Gian hàng {AppData.CurrentCustomerAccount.CustomerId})";
|
||||
}
|
||||
|
||||
// LoginUsingQRCode();
|
||||
if (serialPortDE70.IsOpen) serialPortDE70.Close();
|
||||
if (serialPortSensor.IsOpen) serialPortSensor.Close();
|
||||
|
||||
serialPortDE70.ReadBufferSize = 4096;
|
||||
serialPortDE70.WriteBufferSize = 4096;
|
||||
cCmdRsp = new CCmdRsp(serialPortDE70);
|
||||
AppData.cCmdRsp = cCmdRsp;
|
||||
|
||||
serialPortDE70.PortName = "COM4";
|
||||
serialPortDE70.BaudRate = 9600;
|
||||
serialPortDE70.Parity = Parity.Even;
|
||||
serialPortDE70.DataBits = 8;
|
||||
serialPortDE70.StopBits = StopBits.One;
|
||||
serialPortDE70.ReadTimeout = 10000;
|
||||
serialPortDE70.WriteTimeout = 10000;
|
||||
|
||||
serialPortSensor.PortName = "COM3";
|
||||
serialPortSensor.BaudRate = 9600;
|
||||
serialPortSensor.Parity = Parity.None;
|
||||
serialPortSensor.DataBits = 8;
|
||||
serialPortSensor.StopBits = StopBits.One;
|
||||
serialPortSensor.ReadTimeout = 1000;
|
||||
serialPortSensor.WriteTimeout = 1000;
|
||||
|
||||
|
||||
//Subscrible to the DataReveied event
|
||||
if (!serialPortDE70.IsOpen)
|
||||
serialPortDE70.Open();
|
||||
|
||||
if (!serialPortSensor.IsOpen)
|
||||
serialPortSensor.Open();
|
||||
|
||||
bInitialized = InitSession();
|
||||
|
||||
timer = new DispatcherTimer();
|
||||
timer.Interval = new TimeSpan(0, 0, 10); //10 seconds
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
sensorTimer = new DispatcherTimer();
|
||||
sensorTimer.Interval = new TimeSpan(0, 0, 1); //1 seconds
|
||||
sensorTimer.Tick += SensorTimer_Tick;
|
||||
sensorTimer.Start();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowError("LỖI CỔNG KẾT NỐI, VUI LÒNG KIỂM TRA LẠI CỔNG KẾT NỐI");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void EndTransaction()
|
||||
{
|
||||
try
|
||||
{
|
||||
AppData.IsInTransaction = false;
|
||||
if (timer != null)
|
||||
{
|
||||
timer.Tick -= Timer_Tick;
|
||||
timer.Stop();
|
||||
}
|
||||
if (sensorTimer != null)
|
||||
{
|
||||
sensorTimer.Tick -= SensorTimer_Tick;
|
||||
sensorTimer.Stop();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
public void SetStep(int step)
|
||||
{
|
||||
switch(step)
|
||||
{
|
||||
case 0:
|
||||
btnStart.IsEnabled = true;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = false;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 1:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled =false;
|
||||
break;
|
||||
case 2:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 3:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitSessionCount()
|
||||
{
|
||||
if (lvCount.Items.Count == 11) {
|
||||
foreach(var item in lvCountItems)
|
||||
{
|
||||
item.Quantity = "0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "1000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "2000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "5000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "10000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "20000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "50000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "100000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "200000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "Tổng",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems[10].Quantity = "0";
|
||||
lvCountItems[10].Value = "0";
|
||||
}
|
||||
|
||||
|
||||
lvCount.ItemsSource = lvCountItems;
|
||||
|
||||
//lvCountItems[0].Quantity = "10";
|
||||
}
|
||||
public long maxQuantitySheet = 10000;
|
||||
public int quantityStored = 0;
|
||||
public int totalAllDenominations = 0;
|
||||
public int posDenomi;
|
||||
public bool printerFlag = false;
|
||||
public static string? recvDataString;
|
||||
public int[] TempQuantity = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
public int[] TempNote = new int[5] { 0, 0, 0, 0, 0 };
|
||||
public int[] Notes = new int[5] { 0, 0, 0, 0, 0 };
|
||||
|
||||
private void SensorTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
GetSensorValue();
|
||||
if (AppData.IsInTransaction)
|
||||
{
|
||||
if (AppData.WDTCount == 30)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowTimeoutScreen();
|
||||
}
|
||||
else if (AppData.WDTCount == 60)
|
||||
{
|
||||
//Nhận tiền và Kết thúc
|
||||
StoreStart();
|
||||
EndSession();
|
||||
|
||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
AppData.IsInTransaction = false;
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
AppData.WDTCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Stopwatch watch = new Stopwatch();
|
||||
private void GetSensorValue()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
int state = 0;
|
||||
if (serialPortSensor.IsOpen == true)
|
||||
{
|
||||
//serialPortSensor.DiscardInBuffer();
|
||||
//serialPortSensor.DiscardOutBuffer();
|
||||
|
||||
serialPortSensor.Write(new byte[] { (byte)'S', 13, 10 }, 0, 3);
|
||||
var buffer = new byte[16];
|
||||
|
||||
int n = serialPortSensor.Read(buffer, 0, buffer.Length);
|
||||
|
||||
|
||||
for (int i = 1; i < n - 1; i++)
|
||||
{
|
||||
if ((buffer[i] == 13) && (buffer[i + 1] == 10))
|
||||
{
|
||||
state = buffer[i - 1] - 48;
|
||||
if (bInitialized)
|
||||
{
|
||||
if (state != 0)
|
||||
gridMain.IsEnabled = false;
|
||||
else
|
||||
gridMain.IsEnabled = true;
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
lblStatus.Content = "NGĂN KÉT: ĐÓNG, NGĂN TÚI: ĐÓNG";
|
||||
break;
|
||||
case 1:
|
||||
lblStatus.Content = "NGĂN KÉT: ĐÓNG, NGĂN TÚI: MỞ";
|
||||
break;
|
||||
case 2:
|
||||
lblStatus.Content = "NGĂN KÉT: MỞ, NGĂN TÚI: ĐÓNG";
|
||||
break;
|
||||
case 3:
|
||||
lblStatus.Content = "NGĂN KÉT: MỞ, NGĂN TÚI: MỞ";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// the code that you want to measure comes here
|
||||
watch.Stop();
|
||||
|
||||
var elapsedMs = watch.ElapsedMilliseconds;
|
||||
Debug.WriteLine(elapsedMs);
|
||||
watch.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException("GetSensorValue", ex.ToString());
|
||||
if(serialPortSensor.IsOpen)
|
||||
serialPortSensor.Close();
|
||||
serialPortSensor.Open();
|
||||
serialPortSensor.DiscardInBuffer();
|
||||
serialPortSensor.DiscardOutBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
private void Timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
|
||||
APIModels.SendHealthCheck();
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
public int UpdateTotalQuantity()
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var item in lvCountItems)
|
||||
{
|
||||
if (item.Name != "Tổng")
|
||||
{
|
||||
int quantity = 0;
|
||||
if (int.TryParse(item.Quantity, out quantity))
|
||||
{
|
||||
total += quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int AutoSerialGet(SerialPort serialPort)
|
||||
{
|
||||
int ret;
|
||||
ushort seri_num = 0;
|
||||
ushort get_num = 0;
|
||||
bool endflg = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
ret = cCmdRsp.SendSerialSense();
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
ret = cCmdRsp.GetSerialNum(out seri_num);
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
// Serial number acquisition
|
||||
|
||||
if (cCmdRsp.ChkCntEnd())
|
||||
{
|
||||
endflg = true;
|
||||
Debug.WriteLine("END FLAG: "+cCmdRsp.recv_dat.dat[1]);
|
||||
}
|
||||
Debug.WriteLine("START");
|
||||
Debug.WriteLine($"Num Serial: {seri_num}");
|
||||
|
||||
while (get_num < seri_num)
|
||||
{
|
||||
get_num++;
|
||||
ret = cCmdRsp.SendGetSerial(get_num);
|
||||
|
||||
|
||||
switch (cCmdRsp.recv_dat.dat[18])
|
||||
{
|
||||
case 0x00: TempNote[0] ++; Notes[0] += TempNote[0]; break;
|
||||
case 0x02:
|
||||
//TempNote[1] ++;
|
||||
switch (cCmdRsp.recv_dat.dat[17])
|
||||
{
|
||||
case 0x00: TempQuantity[0]++; break;
|
||||
case 0x01: TempQuantity[1]++; break;
|
||||
case 0x02: TempQuantity[2]++; break;
|
||||
case 0x03: TempQuantity[3]++; break;
|
||||
case 0x04: TempQuantity[4]++; break;
|
||||
case 0x05: TempQuantity[5]++; break;
|
||||
case 0x06: TempQuantity[6]++; break;
|
||||
case 0x07: TempQuantity[7]++; break;
|
||||
case 0x08: TempQuantity[8]++; break;
|
||||
case 0x09: TempQuantity[9]++; break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 0x03: TempNote[2] ++; Notes[2] += TempNote[2]; break;
|
||||
case 0x0b: TempNote[3] ++; Notes[3] += TempNote[3]; break;
|
||||
case 0x0c: TempNote[4] ++; Notes[4] += TempNote[4]; break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("END");
|
||||
//Debug.WriteLine("Ellapsed Time: " + timeSpan.TotalSeconds);
|
||||
if (endflg)
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END GET SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END SEND SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void btnCountStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CountStart();
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
|
||||
private void CountStart()
|
||||
{
|
||||
printerFlag = false;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
try
|
||||
{
|
||||
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
AppData.LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CNTSTART);
|
||||
//var recvData = DE70_CMD.SendxxCmd((byte)CMD_BYTE.CMD_DE_CNTSTART, serialPort);
|
||||
|
||||
//Thread.Sleep(20000);
|
||||
if (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[2] != 43) { }
|
||||
do
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_SENSE);
|
||||
}
|
||||
while (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[1] == 0x09); //SR2 = 0x09 : Counting Status
|
||||
|
||||
//SR3 = 0x43 : Stacker full
|
||||
|
||||
AutoSerialGet(serialPortDE70);
|
||||
|
||||
if (sessions == null || sessions.Count == 0)
|
||||
{
|
||||
double tempSum = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCountItems[i].Quantity = TempQuantity[9 - i].ToString();
|
||||
tempSum += lvCountItems[i].getValue();
|
||||
}
|
||||
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = tempSum.ToString();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
double sum = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
|
||||
}
|
||||
|
||||
a += TempQuantity[9 - i];
|
||||
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sum += lvCountItems[i].getValue();
|
||||
|
||||
}
|
||||
//Update amount of money
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sum.ToString();
|
||||
|
||||
}
|
||||
SetStep(2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheck_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
AppData.LogAction(currentMethod, null);
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
double sumStored;
|
||||
|
||||
//TempNote[1] = 0;
|
||||
|
||||
if (sessions != null)
|
||||
{
|
||||
sumStored = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
//quantityStored += lvCountItems[i].getQuantity();
|
||||
}
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sumStored += lvCountItems[i].getValue();
|
||||
}
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sumStored.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
private void btnStoreStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
StoreStart();
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
|
||||
private void StoreStart()
|
||||
{
|
||||
printerFlag = true;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
AppData.LogAction(currentMethod, null);
|
||||
sessions.Add(new CountSession());
|
||||
|
||||
sessions[sessions.Count - 1].QuantityDenomi = (int[])TempQuantity.Clone();
|
||||
quantityStored = UpdateTotalQuantity();
|
||||
|
||||
Debug.WriteLine(quantityStored);
|
||||
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||
SetStep(3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
InitSession();
|
||||
AppData.IsInTransaction= true;
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
AppData.LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
|
||||
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
SetStep(1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.IsInTransaction = false;
|
||||
AppData.WDTCount = 0;
|
||||
EndSession();
|
||||
}
|
||||
|
||||
private void EndSession()
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
var totalQuantity = lvCountItems[10].Quantity;
|
||||
var totalValue = lvCountItems[10].Value;
|
||||
try
|
||||
{
|
||||
AppData.LogAction(currentMethod, null);
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
//SendData2Server
|
||||
var data2Send = new CountingData2Send
|
||||
{
|
||||
Sessions = sessions,
|
||||
MachineId = null,
|
||||
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
||||
MachineTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
RejectNotes = Notes[0],
|
||||
GenuineNotes = quantityStored,
|
||||
UnfitNotes = Notes[2],
|
||||
CounterfeitNotes = Notes[3],
|
||||
SuspendNotes = Notes[4]
|
||||
|
||||
};
|
||||
var str = JsonConvert.SerializeObject(data2Send);
|
||||
|
||||
APIModels.SendCountingData(data2Send);
|
||||
//Reset all and ready to next session
|
||||
|
||||
if (printerFlag == true)
|
||||
{
|
||||
PrintReceipt();
|
||||
printerFlag = false;
|
||||
|
||||
}
|
||||
InitSession();
|
||||
//Debug.WriteLine("Reject Note: " + Notes[0] );
|
||||
//Debug.WriteLine("Genuine note stored: " + quantityStored);
|
||||
//Debug.WriteLine("Unfit note: " + Notes[2]);
|
||||
//Debug.WriteLine("Counterfeit: " + Notes[3]);
|
||||
//Debug.WriteLine("Suspend: " + Notes[4]);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
|
||||
|
||||
String strNotify = $"BẠN VỪA THỰC HIỆN TIỀN VÀO MÁY CDM:\r\n"
|
||||
+ $"SỐ LƯỢNG TỜ: {totalQuantity}\r\n"
|
||||
+ $"SỐ TIỀN: {totalValue} VND\r\n";
|
||||
|
||||
((MainWindow)Application.Current.MainWindow).ShowInformationScreen(strNotify);
|
||||
}
|
||||
|
||||
private void ShowError(string strError)
|
||||
{
|
||||
//gridMain.IsEnabled = false;
|
||||
//btnCollect2.Visibility=Visibility.Collapsed;
|
||||
//panelError.Visibility = Visibility.Visible;
|
||||
//lblError.Text = strError;
|
||||
//((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
((MainWindow)Application.Current.MainWindow).ShowErrorScreen(strError);
|
||||
}
|
||||
|
||||
private bool InitSession()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Check status
|
||||
cCmdRsp.SendDeSense();
|
||||
var data = cCmdRsp.recv_dat.dat;
|
||||
int IsCassetteFull = 0;
|
||||
int IsNotesInEscrow = 0;
|
||||
IsCassetteFull = data[17] & 0x08;
|
||||
IsNotesInEscrow = data[4] & 0x01;
|
||||
|
||||
if (IsCassetteFull != 0)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowCollectionScreen();
|
||||
return false;
|
||||
}
|
||||
else if (IsNotesInEscrow != 0)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN TRONG NGĂN PHỤ ĐỂ TIẾP TỤC");
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
sessions.Clear();
|
||||
Array.Clear(TempNote, 0, TempNote.Length);
|
||||
Array.Clear(Notes, 0, Notes.Length);
|
||||
quantityStored = 0;
|
||||
maxQuantitySheet = 0;
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
SetStep(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
AppData.LogException("InitSession", ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void PrintReceipt()
|
||||
{
|
||||
var shopName = AppData.CurrentCustomerAccount.Name;
|
||||
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
||||
var tradingCode = "TRA04052024CDM";
|
||||
var storeAccountNumber = 686868686688;
|
||||
var currentTime = DateTime.Now;
|
||||
var printDocument = new PrintDocument();
|
||||
printDocument.PrinterSettings.PrinterName = "CUSTOM K80";
|
||||
printDocument.PrintPage += (sender, e) =>
|
||||
{
|
||||
e.Graphics.DrawString("Biên nhận nộp tiền", new Font("Arial", 15), System.Drawing.Brushes.Black, new PointF(80, 10));
|
||||
e.Graphics.DrawString("Mã máy CDM: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 60));
|
||||
e.Graphics.DrawString("Batch no: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 90));
|
||||
e.Graphics.DrawString("Thời gian GD: " + currentTime.ToString("dd/MM/yyyy HH:mm:ss"), new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 120));
|
||||
e.Graphics.DrawString("Mã GD: " + tradingCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 150));
|
||||
e.Graphics.DrawString("Mã gian hàng: " + shopCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 180));
|
||||
e.Graphics.DrawString("Tên gian hàng: " + shopName, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 210));
|
||||
e.Graphics.DrawString("STK gian hàng: " + storeAccountNumber, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 240));
|
||||
e.Graphics.DrawString("Số tiền nộp: " + lvCountItems[10].Value, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 270));
|
||||
e.Graphics.DrawString("*****Xin cám ơn******", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(100, 300));
|
||||
// To send raw ESC/POS commands, you'd typically use e.Graphics.DrawString() with the command string,
|
||||
// or for more complex scenarios, directly manipulate the byte stream sent to the printer.
|
||||
};
|
||||
printDocument.Print();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EndTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using DE70_CMDv2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
public static class AppData
|
||||
{
|
||||
public static List<CustomerAccount>? customerAccounts = null;
|
||||
public static CustomerAccount? CurrentCustomerAccount{get;set;}
|
||||
public static CCmdRsp? cCmdRsp=null;
|
||||
public static bool IsAuthenticated = false;
|
||||
public static bool IsInTransaction = false;
|
||||
public static int WDTCount = 0;
|
||||
public static void Init()
|
||||
{
|
||||
customerAccounts = new List<CustomerAccount>{
|
||||
new CustomerAccount{Name="NGUYỄN ĐÌNH THUẬN",CustomerId="HUE_0000000001",QRCode="HUE_0000000001",PINCode="H0001" },
|
||||
new CustomerAccount{Name="HOÀNG VĂN HIỆP",CustomerId="HUE_0000000002",QRCode="HUE_0000000002",PINCode="H0002" },
|
||||
new CustomerAccount{Name="PHẠM NGỌC HƯNG",CustomerId="HUE_0000000003",QRCode="HUE_0000000003",PINCode="H0003" }
|
||||
};
|
||||
CurrentCustomerAccount = customerAccounts[0];
|
||||
}
|
||||
public static void LogAction(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("log.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
public static void LogException(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("logException.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
}
|
||||
public class CustomerAccount
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? CustomerId { get; set; }
|
||||
public string? QRCode { get; set; }
|
||||
public string? PINCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<UserControl x:Class="SafeBagDE70.DepositSMUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
mc:Ignorable="d"
|
||||
Width="1280"
|
||||
Height="1024"
|
||||
Background="#F0F0F0"
|
||||
Loaded="UserControl_Loaded"
|
||||
Unloaded="UserControl_Unloaded">
|
||||
<UserControl.Resources>
|
||||
<local:LastItemIndexConverter x:Key="LastItemIndexConverter" />
|
||||
<DataTemplate x:Key="BoldTemplateWithSeparator">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Separator Row -->
|
||||
<RowDefinition Height="2"/>
|
||||
<!-- Data Row -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Separator Line -->
|
||||
<Rectangle Grid.Row="0" Height="2" Fill="Gray" HorizontalAlignment="Stretch"/>
|
||||
|
||||
<!-- Data Content for Last Row -->
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Name}" FontWeight="Bold" Grid.Column="0" />
|
||||
<TextBlock Text="{Binding Quantity}" FontWeight="Bold" Grid.Column="1" />
|
||||
<TextBlock Text="{Binding Value}" FontWeight="Bold" Grid.Column="2" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</UserControl.Resources>
|
||||
<Border BorderThickness="1" BorderBrush="Gray" Margin="10">
|
||||
<Grid x:Name="gridMainPanel">
|
||||
<!--<ContentControl x:Name="MainContent" />-->
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border BorderThickness="0" Background="#003366">
|
||||
<StackPanel Grid.Row="0" >
|
||||
<Label
|
||||
x:Name="lblName"
|
||||
Background="Transparent"
|
||||
Foreground="White"
|
||||
BorderThickness="0"
|
||||
FontWeight="Bold"
|
||||
FontSize="30"
|
||||
Height="50"/>
|
||||
|
||||
<Label HorizontalAlignment="Center"
|
||||
x:Name="lblUser"
|
||||
Background="Transparent"
|
||||
Foreground="White"
|
||||
BorderThickness="0"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Height="50"/>
|
||||
<Border BorderThickness="1" BorderBrush="Gray">
|
||||
<Separator BorderThickness="2" BorderBrush="Gray"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" x:Name="gridMain" VerticalAlignment="Center" Margin="5" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="300"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="BẮT ĐẦU"
|
||||
x:Name="btnStart"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Height="80"
|
||||
Margin="10,0,10,10"
|
||||
Background="#4CAF50" Foreground="White"/>
|
||||
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="NỘP TIỀN"
|
||||
x:Name="btnCountStart"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Height="80"
|
||||
Margin="10"
|
||||
Background="#2196F3" Foreground="White"/>
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="KIỂM TRA"
|
||||
x:Name="btnCheck"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Height="80"
|
||||
Margin="10"
|
||||
Background="#2196F3" Foreground="White"
|
||||
/>
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2">
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="LƯU TRỮ"
|
||||
x:Name="btnStoreStart"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Height="80"
|
||||
Margin="10,0,10,10"
|
||||
Background="#4CAF50" Foreground="White"/>
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="KẾT THÚC"
|
||||
FontWeight="Bold"
|
||||
x:Name="btnEnd"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
Height="80"
|
||||
Margin="10"
|
||||
Background="#4CAF50" Foreground="White"/>
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="THOÁT"
|
||||
FontWeight="Bold"
|
||||
x:Name="btnLogout"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
Height="80"
|
||||
Margin="10"
|
||||
Background="Red" Foreground="White"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Column="1">
|
||||
<ListView HorizontalAlignment="Center" FontSize="30" Width="600" x:Name="lvCount"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
Background="Transparent">
|
||||
<ListView.Resources>
|
||||
<!-- Style for GridViewColumnHeader to set font to bold -->
|
||||
<Style TargetType="GridViewColumnHeader">
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right"/>
|
||||
</Style>
|
||||
|
||||
</ListView.Resources>
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Mệnh giá"
|
||||
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Width="200"/>
|
||||
<GridViewColumn Header="Số lượng"
|
||||
DisplayMemberBinding="{Binding Quantity}"
|
||||
Width="150"/>
|
||||
<GridViewColumn Header="Thành tiền"
|
||||
DisplayMemberBinding="{Binding Value}"
|
||||
Width="200"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<!-- Condition 1: Check if AlternationIndex equals Item Count - 1 -->
|
||||
<Condition Value="True">
|
||||
<Condition.Binding>
|
||||
<MultiBinding Converter="{StaticResource LastItemIndexConverter}">
|
||||
<Binding Path="Name"/>
|
||||
</MultiBinding>
|
||||
</Condition.Binding>
|
||||
</Condition>
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="2" Background="#003366">
|
||||
<Separator BorderThickness="2" BorderBrush="Gray"/>
|
||||
<Label Height="40" x:Name="lblStatus" Background="Transparent" BorderThickness="0" Foreground="Red" FontSize="20" Content="TRẠNG THÁI"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<UserControl x:Class="SafeBagDE70.CollectionUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<hc:SimpleStackPanel Background="White" VerticalAlignment="Center" Margin="20">
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Red" Text="TÚI ĐÃ ĐẦY, HÃY THỰC HIỆN LẤY TÚI TIỀN RA KHỎI MÁY:" HorizontalAlignment="Center"/>
|
||||
<Separator/>
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Blue" Text="1. KIỂM TRA VÀ LẤY TIỀN KHỎI TẤT CẢ CÁC NGĂN"/>
|
||||
<Separator/>
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Blue" Text="2. THỰC HIỆN LẤY TÚI TIỀN RA KHỎI MÁY (NẾU BẠN LÀ NHÂN VIÊN VIETINBANK)"/>
|
||||
<Separator/>
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Blue" Text="3. ẤN THIẾT LẬP BỘ ĐẾM (NẾU BẠN LÀ NHÂN VIÊN VIETINBANK)"/>
|
||||
<Separator/>
|
||||
<hc:HighlightTextBlock x:Name="lblStatus" FontSize="20" FontWeight="Bold" Foreground="Green" Text="TRẠNG THÁI: BỘ ĐẾM ĐẦY"/>
|
||||
<Separator/>
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="btnCollect" Click="btnCollect_Click" Grid.Column="0" Style="{StaticResource ButtonDanger}" Content="THIẾT LẬP BỘ ĐẾM" Height="50"/>
|
||||
<Button x:Name="btnCancel" Click="btnCancel_Click" Grid.Column="1" Style="{StaticResource ButtonWarning}" Content="MỞ NGĂN PHỤ" Height="50"/>
|
||||
</Grid>
|
||||
</hc:SimpleStackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AdminSettingsUC.xaml
|
||||
/// </summary>
|
||||
public partial class AdminMainUC : UserControl
|
||||
{
|
||||
public AdminMainUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LogoutButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void UserManagementButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void DashboardButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ReportsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup />
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Update="App.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="CollectionUC.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="old\QRCodeWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Update="old\WelcomeWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Update="ErrorUC.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="InformationUC.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="CollectionUC.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="DepositUC.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="old\MainUserWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="old\PinCodeWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="old\QRCodeZebraWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="old\QRCodeWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="WelcomeUC.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Update="old\WelcomeWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,766 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
using SafeBagDE70.Model;
|
||||
using HandyControl.Tools;
|
||||
using System.Drawing.Printing;
|
||||
using System.Drawing;
|
||||
using static HandyControl.Tools.Interop.InteropValues;
|
||||
using SafeBagDE70.API;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using DE70_CMDv2;
|
||||
using System.Configuration;
|
||||
|
||||
|
||||
namespace SafeBagDE70
|
||||
{ //Summary
|
||||
public class CountSession
|
||||
{
|
||||
public int[] QuantityDenomi { get; set; }
|
||||
public int[] SumDenomi { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class CountingData2Send
|
||||
{
|
||||
public List<CountSession>? Sessions { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
public string? MachineId { get; set; }
|
||||
public string? MachineTime { get; set; }
|
||||
public int RejectNotes { get; set; }
|
||||
public int GenuineNotes { get; set; }
|
||||
public int UnfitNotes { get; set; }
|
||||
public int CounterfeitNotes { get; set; }
|
||||
public int SuspendNotes { get; set; }
|
||||
}
|
||||
|
||||
public partial class MainUserWindow : HandyControl.Controls.Window
|
||||
{
|
||||
SerialPort serialPortDE70 = new SerialPort();
|
||||
SerialPort serialPortSensor= new SerialPort();
|
||||
|
||||
List<CountSession> sessions = new List<CountSession>();
|
||||
ObservableCollection<LvCountItem> lvCountItems = new ObservableCollection<LvCountItem>();
|
||||
private DispatcherTimer timer;
|
||||
private DispatcherTimer sensorTimer;
|
||||
int countTimer = 0;
|
||||
CCmdRsp cCmdRsp = null;
|
||||
bool bInitialized = false;
|
||||
|
||||
public MainUserWindow()
|
||||
{
|
||||
//Need to update: auto detect COM Port
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
//string queuePath = ConfigurationManager.AppSettings["SensorPort"].ToString();
|
||||
AppData.Init();
|
||||
//this.gridMain.IsEnabled = false;
|
||||
LoginUsingQRCode();
|
||||
|
||||
|
||||
|
||||
serialPortDE70.ReadBufferSize = 4096;
|
||||
serialPortDE70.WriteBufferSize = 4096;
|
||||
cCmdRsp = new CCmdRsp(serialPortDE70);
|
||||
|
||||
serialPortDE70.PortName = "COM4";
|
||||
serialPortDE70.BaudRate = 9600;
|
||||
serialPortDE70.Parity = Parity.Even;
|
||||
serialPortDE70.DataBits = 8;
|
||||
serialPortDE70.StopBits = StopBits.One;
|
||||
|
||||
serialPortSensor.PortName = "COM3";
|
||||
serialPortSensor.BaudRate = 9600;
|
||||
serialPortSensor.Parity = Parity.None;
|
||||
serialPortSensor.DataBits = 8;
|
||||
serialPortSensor.StopBits = StopBits.One;
|
||||
|
||||
//Subscrible to the DataReveied event
|
||||
|
||||
serialPortDE70.Open();
|
||||
serialPortSensor.Open();
|
||||
|
||||
bInitialized= InitSession();
|
||||
|
||||
timer = new DispatcherTimer();
|
||||
timer.Interval = new TimeSpan(0, 0, 10); //10 seconds
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
sensorTimer = new DispatcherTimer();
|
||||
sensorTimer.Interval = new TimeSpan(0, 0, 1); //10 seconds
|
||||
sensorTimer.Tick += SensorTimer_Tick;
|
||||
sensorTimer.Start();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowError("LỖI CỔNG KẾT NỐI, VUI LÒNG KIỂM TRA LẠI CỔNG KẾT NỐI");
|
||||
//MessageBox.Show("Cổng đang mở, kiểm tra lại cổng kết nối");
|
||||
//this.Close();
|
||||
}
|
||||
}
|
||||
public void SetStep(int step)
|
||||
{
|
||||
switch(step)
|
||||
{
|
||||
case 0:
|
||||
btnStart.IsEnabled = true;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = false;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 1:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled =false;
|
||||
break;
|
||||
case 2:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 3:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitSessionCount()
|
||||
{
|
||||
lvCountItems.Clear();
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "1000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "2000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "5000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "10000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "20000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "50000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "100000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "200000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "Tổng",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems[10].Quantity = "0";
|
||||
lvCountItems[10].Value = "0";
|
||||
|
||||
lvCount.ItemsSource = lvCountItems;
|
||||
|
||||
//lvCountItems[0].Quantity = "10";
|
||||
}
|
||||
public long maxQuantitySheet = 10000;
|
||||
public int quantityStored = 0;
|
||||
public int totalAllDenominations = 0;
|
||||
public int posDenomi;
|
||||
public bool printerFlag = false;
|
||||
public static string? recvDataString;
|
||||
public int[] TempQuantity = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
public int[] TempNote = new int[5] { 0, 0, 0, 0, 0 };
|
||||
public int[] Notes = new int[5] { 0, 0, 0, 0, 0 };
|
||||
|
||||
private void SensorTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
int state = 0;
|
||||
if (serialPortSensor.IsOpen==true)
|
||||
{
|
||||
serialPortSensor.Write(new byte[] { (byte)'S', 13, 10 }, 0, 3);
|
||||
var buffer = new byte[16];
|
||||
|
||||
int n = serialPortSensor.Read(buffer, 0, buffer.Length);
|
||||
|
||||
for (int i = 1; i < n - 1; i++)
|
||||
{
|
||||
if ((buffer[i] == 13) && (buffer[i + 1] == 10))
|
||||
{
|
||||
state = buffer[i - 1]-48;
|
||||
if(bInitialized)
|
||||
{
|
||||
if (state != 0)
|
||||
gridMain.IsEnabled = false;
|
||||
else
|
||||
gridMain.IsEnabled = true;
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
lblStatus.Content = "Két: đóng, Túi: đóng";
|
||||
break;
|
||||
case 1:
|
||||
lblStatus.Content = "Két: đóng, Túi: đã bị lấy ra";
|
||||
break;
|
||||
case 2:
|
||||
lblStatus.Content = "Két: mở, Túi: đóng";
|
||||
break;
|
||||
case 3:
|
||||
lblStatus.Content = "Két: mở, Túi: đã bị lấy ra";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
private void Timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
|
||||
APIModels.SendHealthCheck();
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
public int UpdateTotalQuantity()
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var item in lvCountItems)
|
||||
{
|
||||
if (item.Name != "Tổng")
|
||||
{
|
||||
int quantity = 0;
|
||||
if (int.TryParse(item.Quantity, out quantity))
|
||||
{
|
||||
total += quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int AutoSerialGet(SerialPort serialPort)
|
||||
{
|
||||
int ret;
|
||||
ushort seri_num = 0;
|
||||
ushort get_num = 0;
|
||||
bool endflg = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
ret = cCmdRsp.SendSerialSense();
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
ret = cCmdRsp.GetSerialNum(out seri_num);
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
// Serial number acquisition
|
||||
|
||||
if (cCmdRsp.ChkCntEnd())
|
||||
{
|
||||
endflg = true;
|
||||
Debug.WriteLine("END FLAG: "+cCmdRsp.recv_dat.dat[1]);
|
||||
}
|
||||
Debug.WriteLine("START");
|
||||
Debug.WriteLine($"Num Serial: {seri_num}");
|
||||
|
||||
while (get_num < seri_num)
|
||||
{
|
||||
get_num++;
|
||||
ret = cCmdRsp.SendGetSerial(get_num);
|
||||
|
||||
|
||||
switch (cCmdRsp.recv_dat.dat[18])
|
||||
{
|
||||
case 0x00: TempNote[0] ++; Notes[0] += TempNote[0]; break;
|
||||
case 0x02:
|
||||
//TempNote[1] ++;
|
||||
switch (cCmdRsp.recv_dat.dat[17])
|
||||
{
|
||||
case 0x00: TempQuantity[0]++; break;
|
||||
case 0x01: TempQuantity[1]++; break;
|
||||
case 0x02: TempQuantity[2]++; break;
|
||||
case 0x03: TempQuantity[3]++; break;
|
||||
case 0x04: TempQuantity[4]++; break;
|
||||
case 0x05: TempQuantity[5]++; break;
|
||||
case 0x06: TempQuantity[6]++; break;
|
||||
case 0x07: TempQuantity[7]++; break;
|
||||
case 0x08: TempQuantity[8]++; break;
|
||||
case 0x09: TempQuantity[9]++; break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 0x03: TempNote[2] ++; Notes[2] += TempNote[2]; break;
|
||||
case 0x0b: TempNote[3] ++; Notes[3] += TempNote[3]; break;
|
||||
case 0x0c: TempNote[4] ++; Notes[4] += TempNote[4]; break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("END");
|
||||
//Debug.WriteLine("Ellapsed Time: " + timeSpan.TotalSeconds);
|
||||
if (endflg)
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END GET SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END SEND SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void btnCountStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
printerFlag = false;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
try
|
||||
{
|
||||
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CNTSTART);
|
||||
//var recvData = DE70_CMD.SendxxCmd((byte)CMD_BYTE.CMD_DE_CNTSTART, serialPort);
|
||||
|
||||
//Thread.Sleep(20000);
|
||||
if (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[2] != 43) { }
|
||||
do
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_SENSE);
|
||||
}
|
||||
while (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[1] == 0x09); //SR2 = 0x09 : Counting Status
|
||||
|
||||
//SR3 = 0x43 : Stacker full
|
||||
|
||||
AutoSerialGet(serialPortDE70);
|
||||
|
||||
if (sessions == null || sessions.Count == 0)
|
||||
{
|
||||
double tempSum = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCountItems[i].Quantity = TempQuantity[9 - i].ToString();
|
||||
tempSum += lvCountItems[i].getValue();
|
||||
}
|
||||
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = tempSum.ToString();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
double sum = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
|
||||
}
|
||||
|
||||
a += TempQuantity[9 - i];
|
||||
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sum += lvCountItems[i].getValue();
|
||||
|
||||
}
|
||||
//Update amount of money
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sum.ToString();
|
||||
|
||||
}
|
||||
SetStep(2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheck_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
double sumStored;
|
||||
|
||||
//TempNote[1] = 0;
|
||||
|
||||
if (sessions != null)
|
||||
{
|
||||
sumStored = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
//quantityStored += lvCountItems[i].getQuantity();
|
||||
}
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sumStored += lvCountItems[i].getValue();
|
||||
}
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sumStored.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
private void btnStoreStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
printerFlag = true;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
sessions.Add(new CountSession());
|
||||
|
||||
sessions[sessions.Count - 1].QuantityDenomi = (int[])TempQuantity.Clone();
|
||||
quantityStored = UpdateTotalQuantity();
|
||||
|
||||
Debug.WriteLine(quantityStored);
|
||||
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||
SetStep(3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
InitSession();
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
|
||||
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
SetStep(1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
LogAction(currentMethod, null);
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
//SendData2Server
|
||||
var data2Send = new CountingData2Send
|
||||
{
|
||||
Sessions = sessions,
|
||||
MachineId = null,
|
||||
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
||||
MachineTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
RejectNotes = Notes[0],
|
||||
GenuineNotes = quantityStored,
|
||||
UnfitNotes = Notes[2],
|
||||
CounterfeitNotes = Notes[3],
|
||||
SuspendNotes = Notes[4]
|
||||
|
||||
};
|
||||
var str = JsonConvert.SerializeObject(data2Send);
|
||||
|
||||
APIModels.SendCountingData(data2Send);
|
||||
//Reset all and ready to next session
|
||||
|
||||
if(printerFlag == true)
|
||||
{
|
||||
PrintReceipt();
|
||||
printerFlag = false;
|
||||
|
||||
}
|
||||
InitSession();
|
||||
//Debug.WriteLine("Reject Note: " + Notes[0] );
|
||||
//Debug.WriteLine("Genuine note stored: " + quantityStored);
|
||||
//Debug.WriteLine("Unfit note: " + Notes[2]);
|
||||
//Debug.WriteLine("Counterfeit: " + Notes[3]);
|
||||
//Debug.WriteLine("Suspend: " + Notes[4]);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
LoginUsingQRCode();
|
||||
|
||||
}
|
||||
private void ShowError(string strError)
|
||||
{
|
||||
gridMain.IsEnabled = false;
|
||||
|
||||
panelError.Visibility = Visibility.Visible;
|
||||
lblError.Text = strError;
|
||||
}
|
||||
|
||||
private bool InitSession()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Check status
|
||||
cCmdRsp.SendDeSense();
|
||||
var data = cCmdRsp.recv_dat.dat;
|
||||
int IsCassetteFull=data[17] & 0x08;
|
||||
if(IsCassetteFull != 0)
|
||||
{
|
||||
ShowError("TÚI ĐẦY, ĐỀ NGHỊ LẤY TÚI TRƯỚC KHI TIẾP TỤC THAO TÁC");
|
||||
btnCollect2.Visibility=Visibility.Visible;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
sessions.Clear();
|
||||
Array.Clear(TempNote, 0, TempNote.Length);
|
||||
Array.Clear(Notes, 0, Notes.Length);
|
||||
quantityStored = 0;
|
||||
maxQuantitySheet = 0;
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
SetStep(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogException("InitSession", ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void PrintReceipt()
|
||||
{
|
||||
var shopName = AppData.CurrentCustomerAccount.Name;
|
||||
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
||||
var tradingCode = "TRA04052024CDM";
|
||||
var storeAccountNumber = 686868686688;
|
||||
var currentTime = DateTime.Now;
|
||||
var printDocument = new PrintDocument();
|
||||
printDocument.PrinterSettings.PrinterName = "CUSTOM K80";
|
||||
printDocument.PrintPage += (sender, e) =>
|
||||
{
|
||||
e.Graphics.DrawString("Biên nhận nộp tiền", new Font("Arial", 15), System.Drawing.Brushes.Black, new PointF(80, 10));
|
||||
e.Graphics.DrawString("Mã máy CDM: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 60));
|
||||
e.Graphics.DrawString("Batch no: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 90));
|
||||
e.Graphics.DrawString("Thời gian GD: " + currentTime.ToString("dd/MM/yyyy HH:mm:ss"), new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 120));
|
||||
e.Graphics.DrawString("Mã GD: " + tradingCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 150));
|
||||
e.Graphics.DrawString("Mã gian hàng: " + shopCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 180));
|
||||
e.Graphics.DrawString("Tên gian hàng: " + shopName, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 210));
|
||||
e.Graphics.DrawString("STK gian hàng: " + storeAccountNumber, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 240));
|
||||
e.Graphics.DrawString("Số tiền nộp: " + lvCountItems[10].Value, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 270));
|
||||
e.Graphics.DrawString("*****Xin cám ơn******", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(100, 300));
|
||||
// To send raw ESC/POS commands, you'd typically use e.Graphics.DrawString() with the command string,
|
||||
// or for more complex scenarios, directly manipulate the byte stream sent to the printer.
|
||||
};
|
||||
printDocument.Print();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void LogAction(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("log.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
public void LogException(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("logException.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
private void LoginUsingQRCode()
|
||||
{
|
||||
var wnd = new WelcomeWindow();
|
||||
wnd.ShowDialog();
|
||||
|
||||
lblUser.Content = "";
|
||||
//var wnd = new QRCodeZebraWindow();
|
||||
//wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
var strQR = wnd.QRCodeContent;
|
||||
var strPincode = wnd.PinCode;
|
||||
if (AppData.customerAccounts!=null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if(strQR!=null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == strQR).FirstOrDefault();
|
||||
}
|
||||
else if(strPincode!=null)
|
||||
{
|
||||
strPincode = strPincode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
AppData.CurrentCustomerAccount = cca;
|
||||
lblUser.Content = $"Xin chào khách hàng: {cca.Name} (Gian hàng {cca.CustomerId})";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("QRCode không đúng, vui lòng thử lại");
|
||||
LoginUsingQRCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnLoginByPINCode_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var wnd = new PinCodeWindow();
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnCollect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var currentMode = cCmdRsp.GetLockParam().mode;
|
||||
cCmdRsp.GetLockParam().mode = Mode.MODE_COLLECTION;
|
||||
cCmdRsp.SendLock();
|
||||
MessageBox.Show(cCmdRsp.GetSendDat(false));
|
||||
Thread.Sleep(5000);
|
||||
cCmdRsp.GetLockParam().mode = currentMode;
|
||||
cCmdRsp.SendLock();
|
||||
|
||||
InitSession();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
using DE70_CMDv2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CollectionUC.xaml
|
||||
/// </summary>
|
||||
public partial class CollectionUC : UserControl
|
||||
{
|
||||
public CollectionUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void btnCollect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(AppData.cCmdRsp!=null)
|
||||
{
|
||||
CCmdRsp cCmdRsp = AppData.cCmdRsp;
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
//Event fix
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
|
||||
var currentMode = cCmdRsp.GetLockParam().mode;
|
||||
cCmdRsp.GetLockParam().mode = Mode.MODE_COLLECTION;
|
||||
cCmdRsp.SendLock();
|
||||
Thread.Sleep(10000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] != recvData.dat[16])
|
||||
{
|
||||
lblStatus.Text="TRẠNG THÁI: KHỞI TẠO BỘ ĐẾM THÀNH CÔNG";
|
||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(AppData.cCmdRsp!=null)
|
||||
AppData.cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<Application x:Class="SafeBagDE70.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<hc:ThemeResources RequestedTheme="Light">
|
||||
<ResourceDictionary x:Key="Light" hc:ThemeDictionary.Key="Light">
|
||||
|
||||
<!-- Put the resources you want to use in the Light theme Here -->
|
||||
|
||||
<SolidColorBrush x:Key="PrimaryBrush" Color="Red" />
|
||||
<SolidColorBrush x:Key="AppBackgroundBrush" Color="LightBlue" />
|
||||
</ResourceDictionary>
|
||||
</hc:ThemeResources>
|
||||
<hc:Theme/>
|
||||
<ResourceDictionary Source="pack://application:,,,/VirtualKeyboard;component/ResourceDictionaries/DefaultStyles.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
//public class CountSession
|
||||
//{
|
||||
// public int[] QuantityDenomi { get; set; }
|
||||
// public int[] SumDenomi { get; set; }
|
||||
|
||||
//}
|
||||
public partial class MainWindow : HandyControl.Controls.Window
|
||||
{
|
||||
private WelcomeUC _welcomeUC;
|
||||
private DepositUC _depositUC;
|
||||
private CollectionUC _collectionUC;
|
||||
private InformationUC _informationUC;
|
||||
private ErrorUC _errorUC;
|
||||
private UserControl _currentUC;
|
||||
private UserControl _prevUC;
|
||||
private TimeoutUC _timeoutUC;
|
||||
private object objLock = new object();
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Loaded += MainWindow_Loaded;
|
||||
|
||||
}
|
||||
|
||||
private void MainWindow_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.Init();
|
||||
if (_welcomeUC == null) _welcomeUC = new WelcomeUC();
|
||||
if (_collectionUC == null) _collectionUC = new CollectionUC();
|
||||
if (_informationUC == null) _informationUC = new InformationUC();
|
||||
if (_errorUC == null) _errorUC = new ErrorUC();
|
||||
if (_depositUC == null) _depositUC = new DepositUC();
|
||||
if (_timeoutUC == null) _timeoutUC = new TimeoutUC();
|
||||
|
||||
gridMain.Children.Add(_welcomeUC);
|
||||
gridMain.Children.Add(_depositUC);
|
||||
gridMain.Children.Add(_collectionUC);
|
||||
gridMain.Children.Add(_informationUC);
|
||||
gridMain.Children.Add(_errorUC);
|
||||
gridMain.Children.Add(_timeoutUC);
|
||||
|
||||
ShowWelcomeScreen();
|
||||
}
|
||||
|
||||
public void HideAll()
|
||||
{
|
||||
lock(objLock)
|
||||
{
|
||||
foreach (var item in gridMain.Children)
|
||||
{
|
||||
if (item != null)
|
||||
(item as UserControl).Visibility = Visibility.Hidden;
|
||||
}
|
||||
_collectionUC.Visibility = Visibility.Hidden;
|
||||
_informationUC.Visibility = Visibility.Hidden;
|
||||
_errorUC.Visibility = Visibility.Hidden;
|
||||
_depositUC.Visibility = Visibility.Hidden;
|
||||
_welcomeUC.Visibility = Visibility.Hidden;
|
||||
}
|
||||
|
||||
}
|
||||
public void ShowInformationScreen(string strInfor)
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _informationUC;
|
||||
HideAll();
|
||||
_informationUC.Visibility = Visibility.Visible;
|
||||
_informationUC.ShowInfor(strInfor);
|
||||
|
||||
}
|
||||
public void ShowErrorScreen(string strError)
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _errorUC;
|
||||
HideAll();
|
||||
_errorUC.Visibility = Visibility.Visible;
|
||||
_errorUC.ShowInfor(strError);
|
||||
}
|
||||
public void ShowWelcomeScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _welcomeUC;
|
||||
HideAll();
|
||||
_welcomeUC.Init();
|
||||
_welcomeUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void ShowDepositScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _depositUC;
|
||||
HideAll();
|
||||
_depositUC.Visibility = Visibility.Visible;
|
||||
_depositUC.EndTransaction();
|
||||
_depositUC.InitTransaction();
|
||||
}
|
||||
public void ShowCollectionScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
_currentUC = _collectionUC;
|
||||
HideAll();
|
||||
_collectionUC.Init();
|
||||
_collectionUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void ShowTimeoutScreen()
|
||||
{
|
||||
_prevUC = _currentUC;
|
||||
|
||||
HideAll();
|
||||
_timeoutUC.Visibility = Visibility.Visible;
|
||||
}
|
||||
public void BackScreen()
|
||||
{
|
||||
HideAll();
|
||||
_prevUC.Visibility = Visibility.Visible;
|
||||
_currentUC = _prevUC;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,62 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace XamlGeneratedNamespace {
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// GeneratedInternalTypeHelper
|
||||
/// </summary>
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
public sealed class GeneratedInternalTypeHelper : System.Windows.Markup.InternalTypeHelper {
|
||||
|
||||
/// <summary>
|
||||
/// CreateInstance
|
||||
/// </summary>
|
||||
protected override object CreateInstance(System.Type type, System.Globalization.CultureInfo culture) {
|
||||
return System.Activator.CreateInstance(type, ((System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic)
|
||||
| (System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.CreateInstance)), null, null, culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetPropertyValue
|
||||
/// </summary>
|
||||
protected override object GetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, System.Globalization.CultureInfo culture) {
|
||||
return propertyInfo.GetValue(target, System.Reflection.BindingFlags.Default, null, null, culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// SetPropertyValue
|
||||
/// </summary>
|
||||
protected override void SetPropertyValue(System.Reflection.PropertyInfo propertyInfo, object target, object value, System.Globalization.CultureInfo culture) {
|
||||
propertyInfo.SetValue(target, value, System.Reflection.BindingFlags.Default, null, null, culture);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CreateDelegate
|
||||
/// </summary>
|
||||
protected override System.Delegate CreateDelegate(System.Type delegateType, object target, string handler) {
|
||||
return ((System.Delegate)(target.GetType().InvokeMember("_CreateDelegate", (System.Reflection.BindingFlags.InvokeMethod
|
||||
| (System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)), null, target, new object[] {
|
||||
delegateType,
|
||||
handler}, null)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// AddEventHandler
|
||||
/// </summary>
|
||||
protected override void AddEventHandler(System.Reflection.EventInfo eventInfo, object target, System.Delegate handler) {
|
||||
eventInfo.AddEventHandler(target, handler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("VirtualKeyboard")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("VirtualKeyboard")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("VirtualKeyboard")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Runtime.Versioning.TargetPlatformAttribute("Windows7.0")]
|
||||
[assembly: System.Runtime.Versioning.SupportedOSPlatformAttribute("Windows7.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AdminSettingsUC.xaml
|
||||
/// </summary>
|
||||
public partial class AdminSettingsUC : UserControl
|
||||
{
|
||||
public AdminSettingsUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<UserControl x:Class="SafeBagDE70.Admin.LogViewerUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70.Admin"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<Grid>
|
||||
<StackPanel>
|
||||
<TextBlock Text="Realtime Logs" FontSize="20" Margin="10"/>
|
||||
<ListBox x:Name="LogListBox" Height="500" Margin="10"/>
|
||||
<Button Content="Log Information" Width="200" Margin="10" Click="LogInfoButton_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,21 @@
|
||||
<UserControl x:Class="SafeBagDE70.EndSessionUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<hc:SimpleStackPanel Background="White" VerticalAlignment="Center" Margin="20">
|
||||
<hc:HighlightTextBlock x:Name="lblInfor" Text="MÁY ĐANG THỰC HIỆN KẾT THÚC PHIÊN TỰ ĐỘNG" FontSize="20" TextWrapping="Wrap" FontWeight="Bold" Foreground="Blue" HorizontalAlignment="Center"/>
|
||||
<hc:HighlightTextBlock Text="VUI LÒNG CHỜ" FontSize="20" TextWrapping="Wrap" FontWeight="Bold" Foreground="DarkRed" HorizontalAlignment="Center"/>
|
||||
<Separator/>
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
</Grid>
|
||||
</hc:SimpleStackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"C:\\Users\\DELL Precision 7530\\Desktop\\Test\\VK\\VK\\WPFKeyboard\\VirtualKeyboard\\VirtualKeyboard.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"C:\\Users\\DELL Precision 7530\\Desktop\\Test\\VK\\VK\\WPFKeyboard\\VirtualKeyboard\\VirtualKeyboard.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\Users\\DELL Precision 7530\\Desktop\\Test\\VK\\VK\\WPFKeyboard\\VirtualKeyboard\\VirtualKeyboard.csproj",
|
||||
"projectName": "VirtualKeyboard",
|
||||
"projectPath": "C:\\Users\\DELL Precision 7530\\Desktop\\Test\\VK\\VK\\WPFKeyboard\\VirtualKeyboard\\VirtualKeyboard.csproj",
|
||||
"packagesPath": "C:\\Users\\DELL Precision 7530\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\Users\\DELL Precision 7530\\Desktop\\Test\\VK\\VK\\WPFKeyboard\\VirtualKeyboard\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"fallbackFolders": [
|
||||
"C:\\Program Files (x86)\\DevExpress 20.2\\Components\\Offline Packages",
|
||||
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
|
||||
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
|
||||
],
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\DELL Precision 7530\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\DevExpress 20.2.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.FallbackLocation.config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net8.0-windows"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\DevExpress 20.2\\Components\\System\\Components\\Packages": {},
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net8.0-windows7.0": {
|
||||
"targetAlias": "net8.0-windows",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
},
|
||||
"restoreAuditProperties": {
|
||||
"enableAudit": "true",
|
||||
"auditLevel": "low",
|
||||
"auditMode": "direct"
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net8.0-windows7.0": {
|
||||
"targetAlias": "net8.0-windows",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48",
|
||||
"net481"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
},
|
||||
"Microsoft.WindowsDesktop.App.WPF": {
|
||||
"privateAssets": "none"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\8.0.200/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using DE70_CMDv2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CollectionUC.xaml
|
||||
/// </summary>
|
||||
public partial class TimeoutUC : UserControl
|
||||
{
|
||||
public TimeoutUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void ShowInfor(string strInfor)
|
||||
{
|
||||
lblInfor.Text = strInfor;
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.WDTCount = 0;
|
||||
((MainWindow)Application.Current.MainWindow).BackScreen();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AppData.cCmdRsp != null)
|
||||
AppData.cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,60 @@
|
||||
<UserControl x:Class="SafeBagDE70.WelcomeUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
x:Name="ucWelcome"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Top Section -->
|
||||
<StackPanel Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0">
|
||||
<Image Source="icon/logo.ico" Width="200" Height="200" Margin="0,10,0,10" Stretch="UniformToFill"/>
|
||||
<TextBlock Text="Xin chào! Hãy lựa chọn hình thức đăng nhập để tiếp tục" FontSize="24" FontWeight="Bold" TextAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Middle Section -->
|
||||
<Grid Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button hc:IconElement.Geometry="{StaticResource FullScreenGeometry}" Grid.Column="0" Grid.Row="0" x:Name="btnQRCodeLogin" Content="QR CODE" Width="200" Height="100" Margin="0,0,10,0" FontSize="20" FontWeight="Bold" Click="btnQRCodeLogin_Click"/>
|
||||
<Button Grid.Column="2" Grid.Row="0" x:Name="btnPinCodeLogin" Content="PIN CODE" Width="200" Height="100" Margin="10,0,0,0" Click="PinCodeButton_Click" FontSize="20" FontWeight="Bold"/>
|
||||
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="PinCodePanel">
|
||||
<PasswordBox x:Name="PinCodeBox" Width="300" Height="60" FontSize="20" HorizontalContentAlignment="Center" Margin="0,10,0,0"/>
|
||||
<TextBlock Text="Quên mã PIN?" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" Margin="0,5,0,0" MouseLeftButtonUp="ForgotPin_Click"/>
|
||||
<Button Content="Đăng nhập" Width="200" Height="40" Margin="0,10,0,0" Click="LoginButton_Click"/>
|
||||
<Label x:Name="lblPincodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="QrCodePanel">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Đưa QR Code của bạn vào đầu đọc" FontSize="20"/>
|
||||
<hc:LoadingCircle Background="Transparent" VerticalAlignment="Bottom" Width="50" Height="50" Margin="10"/>
|
||||
<Label x:Name="lblQRcodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Bottom Section -->
|
||||
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Text="TRỢ GIÚP" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" MouseLeftButtonUp="Help_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,21 @@
|
||||
<hc:Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
x:Class="SafeBagDE70.PinCodeWindow"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
mc:Ignorable="d"
|
||||
ShowNonClientArea="False"
|
||||
Title="QRCodeWindow" Height="400" Width="600">
|
||||
<Grid>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Nhập PINCODE của bạn" FontSize="30"/>
|
||||
<hc:TextBox HorizontalAlignment="Center" Height="50" Width="200" Margin="10"/>
|
||||
<Button x:Name="btnOK" Content="OK" Width="100" Height="50" Margin="10"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
@@ -0,0 +1,39 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<SolidColorBrush x:Key="KeyboardBackgroundBrush" Color="#2f2f2f"/>
|
||||
<SolidColorBrush x:Key="KeyboardBackgroundAccentBrush" Color="#FFA0A0A0"/>
|
||||
<SolidColorBrush x:Key="KeyboardForegroundBrush" Color="White"/>
|
||||
<sys:Double x:Key="KeyboardIconSize">50</sys:Double>
|
||||
<!--<SolidColorBrush x:Key="UppercaseBrush" Color="#FF006DA0"/>-->
|
||||
|
||||
<Style x:Key="KeyboardButtonStyle" TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
|
||||
<Setter Property="FontSize" Value="30"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Background" Value="{StaticResource KeyboardBackgroundBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource KeyboardForegroundBrush}"/>
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
<Setter Property="Margin" Value="5" />
|
||||
<Setter Property="Height" Value="Auto"/>
|
||||
<Setter Property="Width" Value="Auto" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="KeyboardRepeatButtonStyle" TargetType="{x:Type RepeatButton}" BasedOn="{StaticResource {x:Type RepeatButton}}">
|
||||
<Setter Property="FontSize" Value="30"/>
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="Background" Value="{StaticResource KeyboardBackgroundBrush}"/>
|
||||
<Setter Property="Foreground" Value="{StaticResource KeyboardForegroundBrush}"/>
|
||||
<Setter Property="Focusable" Value="False"/>
|
||||
<Setter Property="Margin" Value="5" />
|
||||
<Setter Property="Height" Value="Auto"/>
|
||||
<Setter Property="Width" Value="Auto" />
|
||||
</Style>
|
||||
|
||||
<Style x:Key="KeyboardValueBoxStyle" TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
|
||||
<Setter Property="FontSize" Value="40" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Foreground" Value="{StaticResource KeyboardForegroundBrush}"/>
|
||||
<Setter Property="Background" Value="{StaticResource KeyboardBackgroundBrush}"/>
|
||||
<Setter Property="Margin" Value="25" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,58 @@
|
||||
using DE70_CMDv2;
|
||||
using SafeBagDE70.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CollectionUC.xaml
|
||||
/// </summary>
|
||||
public partial class InformationUC : UserControl
|
||||
{
|
||||
private bool _bContinue = false;
|
||||
private bool _bPlaySound = false;
|
||||
public InformationUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void ShowInfor(string strInfor, bool bContinue = false, bool bPlaySound=true)
|
||||
{
|
||||
lblInfor.Text = strInfor;
|
||||
_bContinue = bContinue;
|
||||
_bPlaySound = bPlaySound;
|
||||
if (_bPlaySound)
|
||||
SoundManager.StartWarningSound();
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(_bContinue)
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen(false);
|
||||
else
|
||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AppData.cCmdRsp != null)
|
||||
AppData.cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<Application x:Class="SafeBagDE70.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<hc:ThemeResources RequestedTheme="Light">
|
||||
<ResourceDictionary x:Key="Light" hc:ThemeDictionary.Key="Light">
|
||||
|
||||
<!-- Put the resources you want to use in the Light theme Here -->
|
||||
|
||||
<SolidColorBrush x:Key="PrimaryBrush" Color="Red" />
|
||||
<SolidColorBrush x:Key="AppBackgroundBrush" Color="LightBlue" />
|
||||
</ResourceDictionary>
|
||||
</hc:ThemeResources>
|
||||
<hc:Theme/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,113 @@
|
||||
<UserControl x:Class="SafeBagDE70.DepositUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Background="#9edaf7"
|
||||
Loaded="UserControl_Loaded"
|
||||
Unloaded="UserControl_Unloaded">
|
||||
<Border BorderThickness="1" BorderBrush="Gray" Margin="10">
|
||||
<Grid x:Name="gridMainPanel">
|
||||
<!--<ContentControl x:Name="MainContent" />-->
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border BorderThickness="0" BorderBrush="Gray">
|
||||
<StackPanel Grid.Row="0" hc:BorderElement.Circular="True">
|
||||
<Label Content="Vietinbank"
|
||||
Background="Transparent"
|
||||
Foreground="#1d619b"
|
||||
BorderThickness="0"
|
||||
FontWeight="Bold"
|
||||
FontSize="30"
|
||||
Height="50"/>
|
||||
|
||||
<Label HorizontalAlignment="Center"
|
||||
x:Name="lblUser"
|
||||
Background="Transparent"
|
||||
Foreground="White"
|
||||
BorderThickness="0"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Height="50"/>
|
||||
<Border BorderThickness="1" BorderBrush="Gray">
|
||||
<Separator BorderThickness="2" BorderBrush="Gray"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" x:Name="gridMain" VerticalAlignment="Center" Margin="5" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="300"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Button Grid.Row="0" HorizontalAlignment="Stretch" Content="BẮT ĐẦU" x:Name="btnStart" Click="btnStart_Click" FontSize="30" Height="80" />
|
||||
<Button Grid.Row="1" HorizontalAlignment="Stretch" Content="KẾT THÚC" x:Name="btnEnd" Click="btnEnd_Click" FontSize="30" Height="80"/>
|
||||
<Button Grid.Row="2" HorizontalAlignment="Stretch" Content="KT LẤY TÚI" x:Name="btnCollect" Click="btnCollect_Click" FontSize="30" Height="80"/>
|
||||
</Grid>
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" HorizontalAlignment="Stretch" Content="NỘP TIỀN" x:Name="btnCountStart" Click="btnCountStart_Click" FontSize="30" Height="80"/>
|
||||
<Button Grid.Row="1" HorizontalAlignment="Stretch" Content="KIỂM TRA" x:Name="btnCheck" Click="btnCheck_Click" FontSize="30" Height="80"/>
|
||||
<Button Grid.Row="2" HorizontalAlignment="Stretch" Content="LƯU TRỮ" x:Name="btnStoreStart" Click="btnStoreStart_Click" FontSize="30" Height="80" />
|
||||
</Grid>
|
||||
<Grid Grid.Column="1">
|
||||
<ListView HorizontalAlignment="Center" FontSize="30" Width="600" x:Name="lvCount" Style="{StaticResource ListViewBaseStyle}">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Mệnh giá"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Width="200"/>
|
||||
<GridViewColumn Header="Số lượng"
|
||||
DisplayMemberBinding="{Binding Quantity}"
|
||||
Width="200"/>
|
||||
<GridViewColumn Header="Thành tiền"
|
||||
DisplayMemberBinding="{Binding Value}"
|
||||
Width="200"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
<Setter Property="BorderBrush" Value="Gray"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="2">
|
||||
<Separator BorderThickness="2" BorderBrush="Gray"/>
|
||||
<Label Height="40" x:Name="lblStatus" Background="Transparent" BorderThickness="0" Foreground="Red" FontSize="20" Content="Trạng thái"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using DE70_CMDv2;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
public static class AppData
|
||||
{
|
||||
public static List<CustomerAccount>? customerAccounts = null;
|
||||
public static CustomerAccount? CurrentCustomerAccount{get;set;}
|
||||
public static CCmdRsp? cCmdRsp=null;
|
||||
public static void Init()
|
||||
{
|
||||
customerAccounts = new List<CustomerAccount>{
|
||||
new CustomerAccount{Name="NGUYỄN ĐÌNH THUẬN",CustomerId="HUE_0000000001",QRCode="HUE_0000000001",PINCode="H0001" },
|
||||
new CustomerAccount{Name="HOÀNG VĂN HIỆP",CustomerId="HUE_0000000002",QRCode="HUE_0000000002",PINCode="H0002" },
|
||||
new CustomerAccount{Name="PHẠM NGỌC HƯNG",CustomerId="HUE_0000000003",QRCode="HUE_0000000003",PINCode="H0003" }
|
||||
};
|
||||
CurrentCustomerAccount = customerAccounts[0];
|
||||
}
|
||||
}
|
||||
public class CustomerAccount
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? CustomerId { get; set; }
|
||||
public string? QRCode { get; set; }
|
||||
public string? PINCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SafeBagDE70.StateMachine
|
||||
{
|
||||
public class Transition
|
||||
{
|
||||
public List<string> From { get; set; }
|
||||
public List<string> To { get; set; }
|
||||
public List<ActionWithFlag> Actions { get; set; }
|
||||
public bool RequireAtLeastOneActionSuccess { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using DE70_CMDv2;
|
||||
using SafeBagDE70.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CollectionUC.xaml
|
||||
/// </summary>
|
||||
public partial class InformationUC : UserControl
|
||||
{
|
||||
private bool _bContinue = false;
|
||||
private bool _bPlaySound = false;
|
||||
private List<Control> _controls = null;
|
||||
public InformationUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void ShowInfor(string strInfor, bool bContinue = false, bool bPlaySound=true,List<Control> controls=null)
|
||||
{
|
||||
lblInfor.Text = strInfor;
|
||||
_bContinue = bContinue;
|
||||
_bPlaySound = bPlaySound;
|
||||
_controls = controls;
|
||||
if (_bPlaySound)
|
||||
SoundManager.StartWarningSound();
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(_controls!=null)
|
||||
{
|
||||
foreach (var item in _controls)
|
||||
{
|
||||
item.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (_bContinue)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen(false);
|
||||
((MainWindow)Application.Current.MainWindow).ResetTimers();
|
||||
}
|
||||
else
|
||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AppData.cCmdRsp != null)
|
||||
AppData.cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
#pragma checksum "..\..\..\DefaultKeyboardHost.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "8509DC7DAD84ED248634BE5108571E782945BD81"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Controls.Ribbon;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Effects;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Windows.Media.TextFormatting;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Shell;
|
||||
using VirtualKeyboard.Wpf;
|
||||
|
||||
|
||||
namespace VirtualKeyboard.Wpf {
|
||||
|
||||
|
||||
internal partial class DefaultKeyboardHost : System.Windows.Window, System.Windows.Markup.IComponentConnector {
|
||||
|
||||
|
||||
#line 19 "..\..\..\DefaultKeyboardHost.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.ContentControl KeyboardValueContent;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 22 "..\..\..\DefaultKeyboardHost.xaml"
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
|
||||
internal System.Windows.Controls.ContentControl KeyboardContent;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
private bool _contentLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// InitializeComponent
|
||||
/// </summary>
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
|
||||
public void InitializeComponent() {
|
||||
if (_contentLoaded) {
|
||||
return;
|
||||
}
|
||||
_contentLoaded = true;
|
||||
System.Uri resourceLocater = new System.Uri("/VirtualKeyboard;component/defaultkeyboardhost.xaml", System.UriKind.Relative);
|
||||
|
||||
#line 1 "..\..\..\DefaultKeyboardHost.xaml"
|
||||
System.Windows.Application.LoadComponent(this, resourceLocater);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
||||
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
|
||||
switch (connectionId)
|
||||
{
|
||||
case 1:
|
||||
this.KeyboardValueContent = ((System.Windows.Controls.ContentControl)(target));
|
||||
return;
|
||||
case 2:
|
||||
this.KeyboardContent = ((System.Windows.Controls.ContentControl)(target));
|
||||
return;
|
||||
}
|
||||
this._contentLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
<UserControl x:Class="SafeBagDE70.DepositSMUCv2"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
mc:Ignorable="d"
|
||||
Width="1280"
|
||||
Height="1024"
|
||||
Background="#F0F0F0"
|
||||
Loaded="UserControl_Loaded"
|
||||
Unloaded="UserControl_Unloaded">
|
||||
<UserControl.Resources>
|
||||
<local:LastItemIndexConverter x:Key="LastItemIndexConverter" />
|
||||
<DataTemplate x:Key="BoldTemplateWithSeparator">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<!-- Separator Row -->
|
||||
<RowDefinition Height="2"/>
|
||||
<!-- Data Row -->
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Separator Line -->
|
||||
<Rectangle Grid.Row="0" Height="2" Fill="Gray" HorizontalAlignment="Stretch"/>
|
||||
|
||||
<!-- Data Content for Last Row -->
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
<ColumnDefinition Width="100"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Text="{Binding Name}" FontWeight="Bold" Grid.Column="0" />
|
||||
<TextBlock Text="{Binding Quantity}" FontWeight="Bold" Grid.Column="1" />
|
||||
<TextBlock Text="{Binding Value}" FontWeight="Bold" Grid.Column="2" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</UserControl.Resources>
|
||||
<Border BorderThickness="1" BorderBrush="Gray" Margin="10">
|
||||
<Grid x:Name="gridMainPanel">
|
||||
<!--<ContentControl x:Name="MainContent" />-->
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border BorderThickness="0" Background="#003366">
|
||||
<StackPanel Grid.Row="0" >
|
||||
<Label
|
||||
x:Name="lblName"
|
||||
Background="Transparent"
|
||||
Foreground="White"
|
||||
BorderThickness="0"
|
||||
FontWeight="Bold"
|
||||
FontSize="30"
|
||||
Height="50"/>
|
||||
|
||||
<Label HorizontalAlignment="Center"
|
||||
x:Name="lblUser"
|
||||
Background="Transparent"
|
||||
Foreground="White"
|
||||
BorderThickness="0"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Height="50"/>
|
||||
<Border BorderThickness="1" BorderBrush="Gray">
|
||||
<Separator BorderThickness="2" BorderBrush="Gray"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" x:Name="gridMain" VerticalAlignment="Center" Margin="5" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="300"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<StackPanel Grid.Column="0">
|
||||
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="BẮT ĐẦU"
|
||||
x:Name="btnStart"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Height="80"
|
||||
Margin="10,0,10,10"
|
||||
Background="#4CAF50" Foreground="White"/>
|
||||
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="NỘP TIỀN"
|
||||
x:Name="btnCountStart"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Height="80"
|
||||
Margin="10"
|
||||
Background="#2196F3" Foreground="White"/>
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="KIỂM TRA"
|
||||
x:Name="btnCheck"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Height="80"
|
||||
Margin="10"
|
||||
Background="#2196F3" Foreground="White"
|
||||
/>
|
||||
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2">
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="LƯU TRỮ"
|
||||
x:Name="btnStoreStart"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
FontWeight="Bold"
|
||||
Height="80"
|
||||
Margin="10,0,10,10"
|
||||
Background="#4CAF50" Foreground="White"/>
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="KẾT THÚC"
|
||||
FontWeight="Bold"
|
||||
x:Name="btnEnd"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
Height="80"
|
||||
Margin="10"
|
||||
Background="#4CAF50" Foreground="White"/>
|
||||
<Button HorizontalAlignment="Stretch"
|
||||
Content="THOÁT"
|
||||
FontWeight="Bold"
|
||||
x:Name="btnLogout"
|
||||
Click="btnCommon_Click"
|
||||
FontSize="30"
|
||||
Height="80"
|
||||
Margin="10"
|
||||
Background="Red" Foreground="White"/>
|
||||
</StackPanel>
|
||||
<Grid Grid.Column="1">
|
||||
<ListView HorizontalAlignment="Center" FontSize="30" Width="600" x:Name="lvCount"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
ScrollViewer.CanContentScroll="False"
|
||||
Background="Transparent">
|
||||
<ListView.Resources>
|
||||
<!-- Style for GridViewColumnHeader to set font to bold -->
|
||||
<Style TargetType="GridViewColumnHeader">
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right"/>
|
||||
</Style>
|
||||
|
||||
</ListView.Resources>
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Mệnh giá"
|
||||
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Width="200"/>
|
||||
<GridViewColumn Header="Số lượng"
|
||||
DisplayMemberBinding="{Binding Quantity}"
|
||||
Width="150"/>
|
||||
<GridViewColumn Header="Thành tiền"
|
||||
DisplayMemberBinding="{Binding Value}"
|
||||
Width="200"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Right"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
<Style.Triggers>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<!-- Condition 1: Check if AlternationIndex equals Item Count - 1 -->
|
||||
<Condition Value="True">
|
||||
<Condition.Binding>
|
||||
<MultiBinding Converter="{StaticResource LastItemIndexConverter}">
|
||||
<Binding Path="Name"/>
|
||||
</MultiBinding>
|
||||
</Condition.Binding>
|
||||
</Condition>
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="2" Background="#003366">
|
||||
<Separator BorderThickness="2" BorderBrush="Gray"/>
|
||||
<Label Height="40" x:Name="lblStatus" Background="Transparent" BorderThickness="0" Foreground="Red" FontSize="20" Content="TRẠNG THÁI"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
<hc:Window x:Class="SafeBagDE70.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="465" Width="810">
|
||||
<Grid RenderTransformOrigin="0.499,0.444">
|
||||
<Grid.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform/>
|
||||
<SkewTransform/>
|
||||
<RotateTransform Angle="0.075"/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Grid.RenderTransform>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="60*"/>
|
||||
<RowDefinition Height="40*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="22*"/>
|
||||
<RowDefinition Height="65*"/>
|
||||
<RowDefinition Height="65*"/>
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="270*"/>
|
||||
<ColumnDefinition Width="270*"/>
|
||||
<ColumnDefinition Width="270*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Grid.Row="0" Grid.Column="0" Content="Bắt đầu" x:Name="btnStart" Click="btnStart_Click" Background="#33CC33" FontSize="30" />
|
||||
<Button Grid.Row="0" Grid.Column="2" Content="Kết thúc" x:Name="btnEnd" Click="btnEnd_Click" Background="#FF4500" FontSize="30"/>
|
||||
<Button Grid.Row="13" Grid.Column="0" Content="Đếm" x:Name="btnCountStart" Click="btnCountStart_Click" Background="#63B8FF" FontSize="30" Grid.RowSpan="2"/>
|
||||
<Button Grid.Row="13" Grid.Column="1" Content="Kiểm tra" x:Name="btnCheck" Click="btnCheck_Click" Background="#87CEFF" FontSize="30" Grid.RowSpan="2" />
|
||||
<Button Grid.Row="13" Grid.Column="2" Content="Lưu trữ" x:Name="btnStoreStart" Click="btnStoreStart_Click" Background="#00F5FF" FontSize="30" Grid.RowSpan="2" />
|
||||
|
||||
|
||||
|
||||
<!--<TextBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="Denomination" IsReadOnly="True" Text ="Denomination" TextWrapping="Wrap" FontSize="25" BorderBrush="White" Padding="30,0"/>-->
|
||||
|
||||
<TextBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="Denomination" IsReadOnly="True" Text="Mệnh giá" TextWrapping="Wrap" FontSize="20" Padding="90,5" BorderBrush="White" />
|
||||
|
||||
<TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi0" IsReadOnly="True" Text="500đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi1" IsReadOnly="True" Text="1.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi2" IsReadOnly="True" Text="2.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi3" IsReadOnly="True" Text="5.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="6" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi4" IsReadOnly="True" Text="10.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi5" IsReadOnly="True" Text="20.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="8" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi6" IsReadOnly="True" Text="50.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi7" IsReadOnly="True" Text="100.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="10" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi8" IsReadOnly="True" Text="200.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="11" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="denomi9" IsReadOnly="True" Text="500.000đ" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
|
||||
<!--Quantity of each Denomination -->
|
||||
|
||||
<TextBox Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi0" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="3" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi1" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi2" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi3" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="6" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi4" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="7" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi5" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="8" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi6" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="9" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi7" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="10" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi8" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="11" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="quantityDenomi9" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
|
||||
<!--Total amount of each denomination-->
|
||||
|
||||
<TextBox Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi0" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi1" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi2" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi3" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="6" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi4" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="7" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi5" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="8" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi6" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="9" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi7" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="10" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi8" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
<TextBox Grid.Row="11" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="totalAmountQuantityDenomi9" IsReadOnly="True" TextWrapping="Wrap" FontSize="15" Padding="100,0" BorderBrush="White" />
|
||||
|
||||
<TextBox Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="Quantity" IsReadOnly="True" Text="Số lượng" TextWrapping="Wrap" FontSize="20" Padding="90,5" BorderBrush="White" />
|
||||
|
||||
<TextBox Grid.Row="1" Grid.Column="2" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="Total" IsReadOnly="True" Text="Tổng" TextWrapping="Wrap" FontSize="20" Padding="105,5" BorderBrush="White" />
|
||||
|
||||
<TextBox Grid.Row="12" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="1" x:Name="txtFixed" IsReadOnly="True" Text ="Tổng tiền" TextWrapping="Wrap" FontSize="30" Padding="80,10" BorderBrush="White" />
|
||||
|
||||
<TextBox Grid.Row="12" Grid.Column="2" Grid.RowSpan="1" x:Name="txtTotalMoney" IsReadOnly="True" TextWrapping="Wrap" FontSize="30" Padding="90,10" BorderBrush="White" />
|
||||
</Grid>
|
||||
|
||||
</hc:Window>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="SafeBagDE70.InformationUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<hc:SimpleStackPanel Background="White" VerticalAlignment="Center" Margin="20">
|
||||
<hc:HighlightTextBlock x:Name="lblInfor" FontSize="30" TextWrapping="Wrap" FontWeight="Bold" Foreground="Blue" HorizontalAlignment="Center"/>
|
||||
<Separator/>
|
||||
<Grid Margin="10">
|
||||
<Button Width="200" x:Name="btnEnd" Click="btnEnd_Click" Grid.Column="0" Style="{StaticResource ButtonPrimary}" Content="TIẾP TỤC" Height="50"/>
|
||||
</Grid>
|
||||
</hc:SimpleStackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,129 @@
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using SafeBagDE70.Admin;
|
||||
using SafeBagDE70.Model;
|
||||
using SafeBagDE70.StateMachine;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using VirtualKeyboard.Wpf;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : System.Windows.Application
|
||||
{
|
||||
public static StateMachineConfig StateMachineConfig { get; private set; }
|
||||
private static Mutex mutex;
|
||||
public App()
|
||||
{
|
||||
}
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
|
||||
CheckInstance();
|
||||
LoadConfig();
|
||||
LoadDualScreens();
|
||||
}
|
||||
private static void CheckInstance()
|
||||
{
|
||||
bool isNewInstance;
|
||||
string mutexName = "9f5b55c9-c6eb-443a-8e28-027defa46fb5";
|
||||
|
||||
mutex = new Mutex(true, mutexName, out isNewInstance);
|
||||
|
||||
if (!isNewInstance)
|
||||
{
|
||||
// If an instance is already running, exit the application
|
||||
System.Windows.MessageBox.Show("Ứng dụng đã khởi chạy");
|
||||
System.Windows.Application.Current.Shutdown();
|
||||
return;
|
||||
}
|
||||
}
|
||||
private static void LoadConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
AppData.CurrentVersion = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
VKeyboard.Listen<System.Windows.Controls.TextBox>(e => e.Text);
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(configuration)
|
||||
.WriteTo.Sink(new RealTimeLogSink())
|
||||
.CreateLogger();
|
||||
AppData.CDMPort = configuration["SerialPort:CDMPort"];
|
||||
AppData.SensorPort = configuration["SerialPort:SensorPort"];
|
||||
StateMachineConfig = new StateMachineConfig();
|
||||
configuration.GetSection("StateMachine").Bind(StateMachineConfig);
|
||||
Log.Information("START APP");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.Windows.MessageBox.Show(ex.Message);
|
||||
}
|
||||
}
|
||||
private void LoadDualScreens()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Create instances of the windows you want to open
|
||||
var mainWindow = new MainWindow();
|
||||
|
||||
// Show both windows
|
||||
mainWindow.Show();
|
||||
|
||||
// Get all available screens
|
||||
var screens = Screen.AllScreens;
|
||||
|
||||
// Open the Main Window on the primary screen
|
||||
var primaryScreen = screens.FirstOrDefault(s => s.Primary) ?? screens.First();
|
||||
PositionWindowOnScreen(mainWindow, primaryScreen);
|
||||
mainWindow.Show();
|
||||
|
||||
// Open the Secondary Window on the secondary screen, if available
|
||||
if (screens.Length > 1)
|
||||
{
|
||||
var adminWindow = new AdminWindow(); // Replace this with your actual window class
|
||||
adminWindow.Show();
|
||||
var secondaryScreen = screens.First(s => !s.Primary);
|
||||
PositionWindowOnScreen(adminWindow, secondaryScreen);
|
||||
adminWindow.Show();
|
||||
}
|
||||
}catch (Exception ex)
|
||||
{
|
||||
Log.Fatal(ex,"START APP");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void PositionWindowOnScreen(Window window, Screen screen)
|
||||
{
|
||||
// Convert screen bounds to WPF units (96 DPI)
|
||||
var screenLeft = screen.WorkingArea.Left / (double)Screen.PrimaryScreen.WorkingArea.Width * SystemParameters.PrimaryScreenWidth;
|
||||
var screenTop = screen.WorkingArea.Top / (double)Screen.PrimaryScreen.WorkingArea.Height * SystemParameters.PrimaryScreenHeight;
|
||||
|
||||
// Set window position and state
|
||||
window.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||
window.Left = screenLeft;
|
||||
window.Top = screenTop;
|
||||
window.Width = screen.WorkingArea.Width;
|
||||
window.Height = screen.WorkingArea.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "0AU11qKXzf8=",
|
||||
"success": true,
|
||||
"projectFilePath": "D:\\SRC\\VirtualKeyboard\\VirtualKeyboard.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"logs": []
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,279 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
///
|
||||
|
||||
//public class CountSession
|
||||
//{
|
||||
// public int[] QuantityDenomi { get; set; }
|
||||
// public int[] SumDenomi { get; set; }
|
||||
|
||||
//}
|
||||
public partial class MainWindow : HandyControl.Controls.Window
|
||||
{
|
||||
SerialPort serialPort = new SerialPort();
|
||||
|
||||
private int[] denominations = { 500000, 200000, 100000, 50000, 20000, 10000, 5000, 2000, 1000, 500 };
|
||||
|
||||
List<CountSession> sessions = new List<CountSession>();
|
||||
public MainWindow()
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
serialPort.PortName = "COM3";
|
||||
serialPort.BaudRate = 9600;
|
||||
serialPort.Parity = Parity.Even;
|
||||
serialPort.DataBits = 8;
|
||||
serialPort.StopBits = StopBits.One;
|
||||
|
||||
//Subscrible to the DataReveied event
|
||||
|
||||
serialPort.DataReceived += new SerialDataReceivedEventHandler(SerialPort_DataReceived);
|
||||
|
||||
//serialPort.Open();
|
||||
}
|
||||
public long maxQuantitySheet = 10000;
|
||||
|
||||
|
||||
public int totalAllDenominations = 0;
|
||||
|
||||
public int flag = 0;
|
||||
|
||||
|
||||
public string hexReceivedString = "";
|
||||
|
||||
public void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
|
||||
{
|
||||
int bytesToRead = serialPort.BytesToRead;
|
||||
byte[] receivedBytes = new byte[bytesToRead];
|
||||
serialPort.Read(receivedBytes, 0, bytesToRead);
|
||||
|
||||
|
||||
//Convert to hex string
|
||||
|
||||
|
||||
string newHexString = BitConverter.ToString(receivedBytes).Replace("-", " ");
|
||||
|
||||
hexReceivedString = newHexString;
|
||||
|
||||
|
||||
}
|
||||
public async void btnCountStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
sessions.Add(new CountSession());
|
||||
|
||||
string deSenseExpectedString0 = "10 02 30 38 34 60 40 07 41 00 01 00 00 00 00 00 00 10 10 00 00 00 00 00 F0 12";
|
||||
string deSenseExpectedString1 = "10 02 30 38 34 60 40 07 41 00 01 00 00 00 00 00 00 10 10 00 00 01 00 01 F0 12";
|
||||
string deSenseExpectedString2 = "10 02 30 38 34 60 40 07 41 00 01 00 00 00 00 00 00 10 10 00 00 02 00 02 F0 12";
|
||||
string deSenseExpectedString3 = "10 02 30 38 34 60 40 07 41 00 01 00 00 00 00 00 00 10 10 00 00 03 00 03 F0 12";
|
||||
string deSenseExpectedString4 = "10 02 30 38 34 60 40 07 41 00 01 00 00 00 00 00 00 10 10 00 00 04 00 04 F0 12";
|
||||
string deSenseExpectedString5 = "10 02 30 38 34 60 40 07 41 00 01 00 00 00 00 00 00 10 10 00 00 05 00 05 F0 12";
|
||||
|
||||
|
||||
var countStart = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x73, 0x10, 0x03, 0x41 };
|
||||
serialPort.Write(countStart, 0, countStart.Length);
|
||||
|
||||
await Task.Delay(2500);
|
||||
|
||||
|
||||
|
||||
//int[] quantityValues = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
//int[] sessions[sessions.Count - 1].SumDenomi = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
|
||||
|
||||
|
||||
var deSense = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x60, 0x10, 0x03, 0x52 };
|
||||
|
||||
serialPort.Write(deSense, 0, deSense.Length);
|
||||
|
||||
await Task.Delay(300);
|
||||
|
||||
if (hexReceivedString.Contains(deSenseExpectedString0) || hexReceivedString.Contains(deSenseExpectedString1) || hexReceivedString.Contains(deSenseExpectedString2) || hexReceivedString.Contains(deSenseExpectedString3) || hexReceivedString.Contains(deSenseExpectedString4) || hexReceivedString.Contains(deSenseExpectedString5))
|
||||
{
|
||||
//Hexa string data received process
|
||||
string[] hexValues = hexReceivedString.Split(' ');
|
||||
|
||||
|
||||
int[] values = new int[hexValues.Length];
|
||||
|
||||
for (int i = 0; i < hexValues.Length; i++)
|
||||
{
|
||||
values[i] = Convert.ToInt32(hexValues[i], 16);
|
||||
}
|
||||
|
||||
//Take amount of each denomination
|
||||
|
||||
sessions[0].QuantityDenomi = values.Skip(26).Take(10).ToArray();
|
||||
|
||||
//Total money of each denomination.
|
||||
|
||||
|
||||
for (int i = 0; i < sessions[0].QuantityDenomi.Length; i++)
|
||||
{
|
||||
sessions[sessions.Count - 1].SumDenomi[i] = sessions[sessions.Count - 1].QuantityDenomi[i] * denominations[i];
|
||||
}
|
||||
//Total amount of each denomination
|
||||
|
||||
// Total money of all denominations
|
||||
totalAllDenominations = sessions[sessions.Count - 1].SumDenomi.Sum();
|
||||
|
||||
}
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
//Update UI
|
||||
txtTotalMoney.Text = totalAllDenominations.ToString();
|
||||
|
||||
quantityDenomi0.Text = sessions[sessions.Count - 1].QuantityDenomi[9].ToString();
|
||||
quantityDenomi1.Text = sessions[sessions.Count - 1].QuantityDenomi[8].ToString();
|
||||
quantityDenomi2.Text = sessions[sessions.Count - 1].QuantityDenomi[7].ToString();
|
||||
quantityDenomi3.Text = sessions[sessions.Count - 1].QuantityDenomi[6].ToString();
|
||||
quantityDenomi4.Text = sessions[sessions.Count - 1].QuantityDenomi[5].ToString();
|
||||
quantityDenomi5.Text = sessions[sessions.Count - 1].QuantityDenomi[4].ToString();
|
||||
quantityDenomi6.Text = sessions[sessions.Count - 1].QuantityDenomi[3].ToString();
|
||||
quantityDenomi7.Text = sessions[sessions.Count - 1].QuantityDenomi[2].ToString();
|
||||
quantityDenomi8.Text = sessions[sessions.Count - 1].QuantityDenomi[1].ToString();
|
||||
quantityDenomi9.Text = sessions[sessions.Count - 1].QuantityDenomi[0].ToString();
|
||||
|
||||
totalAmountQuantityDenomi0.Text = sessions[sessions.Count - 1].SumDenomi[9].ToString();
|
||||
totalAmountQuantityDenomi1.Text = sessions[sessions.Count - 1].SumDenomi[8].ToString();
|
||||
totalAmountQuantityDenomi2.Text = sessions[sessions.Count - 1].SumDenomi[7].ToString();
|
||||
totalAmountQuantityDenomi3.Text = sessions[sessions.Count - 1].SumDenomi[6].ToString();
|
||||
totalAmountQuantityDenomi4.Text = sessions[sessions.Count - 1].SumDenomi[5].ToString();
|
||||
totalAmountQuantityDenomi5.Text = sessions[sessions.Count - 1].SumDenomi[4].ToString();
|
||||
totalAmountQuantityDenomi6.Text = sessions[sessions.Count - 1].SumDenomi[3].ToString();
|
||||
totalAmountQuantityDenomi7.Text = sessions[sessions.Count - 1].SumDenomi[2].ToString();
|
||||
totalAmountQuantityDenomi8.Text = sessions[sessions.Count - 1].SumDenomi[1].ToString();
|
||||
totalAmountQuantityDenomi9.Text = sessions[sessions.Count - 1].SumDenomi[0].ToString();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void btnCheck_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//Xóa tiền đã đếm trong lần trước, cập nhật lại giao diện
|
||||
|
||||
|
||||
var check = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x76, 0x10, 0x03, 0x44 };
|
||||
serialPort.Write(check, 0, check.Length);
|
||||
}
|
||||
private void btnStoreStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var storeStart = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x75, 0x10, 0x03, 0x47 };
|
||||
serialPort.Write(storeStart, 0, storeStart.Length);
|
||||
}
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string deSenseDataRev01 = "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 00 00 01 70 00 10 03 35";
|
||||
string deSenseDataRev02 = "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 01 00 02 70 00 10 03 37";
|
||||
string deSenseDataRev03 = "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 02 00 03 70 00 10 03 35";
|
||||
string deSenseDataRev04 = "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 03 00 04 70 00 10 03 33";
|
||||
string deSenseDataRev05 = "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 04 00 05 70 00 10 03 35";
|
||||
string deSenseDataRev00 = "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 05 00 00 70 00 10 03 31";
|
||||
|
||||
string[] deSenseDataRevSatisfy = { "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 05 00 05 70 00 10 03 34", "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 04 00 04 70 00 10 03 34", "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 03 00 03 70 00 10 03 34", "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 02 00 02 70 00 10 03 34", "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 01 00 01 70 00 10 03 34", "10 02 30 32 30 60 40 04 41 00 00 00 00 00 00 00 00 10 10 00 00 00 00 00 70 00 10 03 34" };
|
||||
|
||||
|
||||
var deSense = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x60, 0x10, 0x03, 0x52 };
|
||||
serialPort.Write(deSense, 0, deSense.Length);
|
||||
|
||||
Thread.Sleep(100);
|
||||
|
||||
if (hexReceivedString == deSenseDataRev01)
|
||||
{
|
||||
flag = 1;
|
||||
var eventDataFixed_1 = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x01, 0x10, 0x03, 0x54 };
|
||||
|
||||
serialPort.Write(eventDataFixed_1, 0, eventDataFixed_1.Length);
|
||||
} else if (hexReceivedString == deSenseDataRev02)
|
||||
{
|
||||
flag = 1;
|
||||
var eventDataFixed_2 = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x02, 0x10, 0x03, 0x57 };
|
||||
|
||||
serialPort.Write(eventDataFixed_2, 0, eventDataFixed_2.Length);
|
||||
}
|
||||
else if (hexReceivedString == deSenseDataRev03)
|
||||
{
|
||||
flag = 1;
|
||||
var eventDataFixed_3 = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x03, 0x10, 0x03, 0x56 };
|
||||
|
||||
serialPort.Write(eventDataFixed_3, 0, eventDataFixed_3.Length);
|
||||
}
|
||||
else if (hexReceivedString == deSenseDataRev04)
|
||||
{
|
||||
flag = 1;
|
||||
var eventDataFixed_4 = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x04, 0x10, 0x03, 0x51 };
|
||||
|
||||
serialPort.Write(eventDataFixed_4, 0, eventDataFixed_4.Length);
|
||||
}
|
||||
else if (hexReceivedString == deSenseDataRev05)
|
||||
{
|
||||
flag = 1;
|
||||
var eventDataFixed_5 = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x05, 0x10, 0x03, 0x50 };
|
||||
|
||||
serialPort.Write(eventDataFixed_5, 0, eventDataFixed_5.Length);
|
||||
}
|
||||
else if (hexReceivedString == deSenseDataRev00)
|
||||
{
|
||||
flag = 1;
|
||||
var eventDataFixed_0 = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x00, 0x10, 0x03, 0x55 };
|
||||
|
||||
serialPort.Write(eventDataFixed_0, 0, eventDataFixed_0.Length);
|
||||
} else if (deSenseDataRevSatisfy.Contains(hexReceivedString))
|
||||
{
|
||||
flag = 1;
|
||||
};
|
||||
|
||||
|
||||
if(flag == 1)
|
||||
{
|
||||
var start = new byte[] { 0x10, 0x02, 0x30, 0x31, 0x33, 0x70, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x00, 0x10, 0x03, 0x48 }; //lock
|
||||
serialPort.Write(start, 0, start.Length);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
//Đặt lại tất cả , kết thúc phiên và sẵn sàng vào phiên mới
|
||||
|
||||
//int[] numbers = new int[] {1,2,3,4,5,6};
|
||||
//Array.Clear(numbers, 0, numbers.Length);
|
||||
var end = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x71, 0x10, 0x03, 0x43 };
|
||||
serialPort.Write(end, 0, end.Length);
|
||||
flag = 0;
|
||||
maxQuantitySheet = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using DE70_CMDv2;
|
||||
using SafeBagDE70.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CollectionUC.xaml
|
||||
/// </summary>
|
||||
public partial class InformationUC : UserControl
|
||||
{
|
||||
private bool _bContinue = false;
|
||||
private bool _bPlaySound = false;
|
||||
private List<Control> _controls = null;
|
||||
public InformationUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void ShowInfor(string strInfor, bool bContinue = false, bool bPlaySound=true,List<Control> controls=null)
|
||||
{
|
||||
lblInfor.Text = strInfor;
|
||||
_bContinue = bContinue;
|
||||
_bPlaySound = bPlaySound;
|
||||
_controls = controls;
|
||||
if (_bPlaySound)
|
||||
SoundManager.StartWarningSound();
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(_controls!=null)
|
||||
{
|
||||
foreach (var item in _controls)
|
||||
{
|
||||
item.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(_bContinue)
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen(false);
|
||||
else
|
||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AppData.cCmdRsp != null)
|
||||
AppData.cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v8.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v8.0": {}
|
||||
},
|
||||
"libraries": {}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<hc:Window x:Class="SafeBagDE70.WelcomeWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
ShowInTaskbar="False"
|
||||
ShowNonClientArea="False"
|
||||
IsFullScreen="True"
|
||||
Topmost="True"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Title="WelcomeWindow" Height="600" Width="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Top Section -->
|
||||
<StackPanel Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0">
|
||||
<Image Source="icon/logo.ico" Width="200" Height="200" Margin="0,10,0,10" Stretch="UniformToFill"/>
|
||||
<TextBlock Text="Xin chào! Hãy lựa chọn hình thức đăng nhập để tiếp tục" FontSize="24" FontWeight="Bold" TextAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Middle Section -->
|
||||
<Grid Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button hc:IconElement.Geometry="{StaticResource FullScreenGeometry}" Grid.Column="0" Grid.Row="0" x:Name="btnQRCodeLogin" Content="QR CODE" Width="200" Height="100" Margin="0,0,10,0" FontSize="20" FontWeight="Bold" Click="btnQRCodeLogin_Click"/>
|
||||
<Button Grid.Column="2" Grid.Row="0" x:Name="btnPinCodeLogin" Content="PIN CODE" Width="200" Height="100" Margin="10,0,0,0" Click="PinCodeButton_Click" FontSize="20" FontWeight="Bold"/>
|
||||
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="PinCodePanel">
|
||||
<PasswordBox x:Name="PinCodeBox" Width="300" Height="60" FontSize="20" HorizontalContentAlignment="Center" Margin="0,10,0,0"/>
|
||||
<TextBlock Text="Quên mã PIN?" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" Margin="0,5,0,0" MouseLeftButtonUp="ForgotPin_Click"/>
|
||||
<Button Content="Đăng nhập" Width="200" Height="40" Margin="0,10,0,0" Click="LoginButton_Click"/>
|
||||
<Label x:Name="lblPincodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="QrCodePanel">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Đưa QR Code của bạn vào đầu đọc" FontSize="20"/>
|
||||
<hc:LoadingCircle Background="Transparent" VerticalAlignment="Bottom" Width="50" Height="50" Margin="10"/>
|
||||
<Label x:Name="lblQRcodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Bottom Section -->
|
||||
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Text="TRỢ GIÚP" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" MouseLeftButtonUp="Help_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</hc:Window>
|
||||
@@ -0,0 +1,13 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net8.0-windows
|
||||
build_property.TargetPlatformMinVersion = 7.0
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = VirtualKeyboard_dsmyrzi2_wpftmp
|
||||
build_property.ProjectDir = C:\Users\DELL Precision 7530\Desktop\Test\VK\VK\WPFKeyboard\VirtualKeyboard\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
@@ -0,0 +1,20 @@
|
||||
<UserControl x:ClassModifier="internal"
|
||||
x:Class="VirtualKeyboard.Wpf.Views.VirtualKeyboardView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:VirtualKeyboard.Wpf"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="../ResourceDictionaries/KeyboardCore.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<Grid Background="{DynamicResource KeyboardBackgroundAccentBrush}">
|
||||
<ContentControl Content="{Binding KeyboardType, Converter={StaticResource KeyboardTypeConverter}}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,19 @@
|
||||
<UserControl x:Class="SafeBagDE70.ErrorUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<hc:SimpleStackPanel Background="White" VerticalAlignment="Center" Margin="20">
|
||||
<hc:HighlightTextBlock FontSize="20" FontWeight="Bold" Foreground="Red" Text="ĐÃ XẢY RA LỖI" HorizontalAlignment="Center"/>
|
||||
<Separator/>
|
||||
<hc:HighlightTextBlock x:Name="lblError" FontSize="20" TextWrapping="Wrap" FontWeight="Bold" Foreground="Blue" HorizontalAlignment="Center"/>
|
||||
<Separator/>
|
||||
<Grid Margin="10">
|
||||
<Button Grid.Column="0" Style="{StaticResource ButtonPrimary}" Content="THỬ LẠI" Height="50"/>
|
||||
</Grid>
|
||||
</hc:SimpleStackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.7.34202.233
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SafeBagDE70", "SafeBagDE70.csproj", "{DCA4F90E-EB1C-4038-BEAC-73BC15158E05}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VirtualKeyboard", "VirtualKeyboard\VirtualKeyboard.csproj", "{F7B9604B-FC5A-493E-98C1-38E54329E33F}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DCA4F90E-EB1C-4038-BEAC-73BC15158E05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DCA4F90E-EB1C-4038-BEAC-73BC15158E05}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DCA4F90E-EB1C-4038-BEAC-73BC15158E05}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DCA4F90E-EB1C-4038-BEAC-73BC15158E05}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F7B9604B-FC5A-493E-98C1-38E54329E33F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F7B9604B-FC5A-493E-98C1-38E54329E33F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F7B9604B-FC5A-493E-98C1-38E54329E33F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F7B9604B-FC5A-493E-98C1-38E54329E33F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {471DAFF3-9038-41B5-8763-7F24A56B5F19}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
// <auto-generated/>
|
||||
global using global::System;
|
||||
global using global::System.Collections.Generic;
|
||||
global using global::System.Linq;
|
||||
global using global::System.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
@@ -0,0 +1,95 @@
|
||||
using DE70_CMDv2;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AdminConfigurationUC.xaml
|
||||
/// </summary>
|
||||
public partial class AdminConfigurationUC : UserControl
|
||||
{
|
||||
public AdminConfigurationUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void btnResetCounter_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AppData.cCmdRsp != null)
|
||||
{
|
||||
Log.Information("[ADMIN] reset counter");
|
||||
CCmdRsp cCmdRsp = AppData.cCmdRsp;
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
//Event fix
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
|
||||
var currentMode = cCmdRsp.GetLockParam().mode;
|
||||
cCmdRsp.GetLockParam().mode = Mode.MODE_COLLECTION;
|
||||
cCmdRsp.SendLock();
|
||||
Thread.Sleep(10000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] != recvData.dat[16])
|
||||
{
|
||||
Log.Information("[ADMIN] reset counter success");
|
||||
lblStatus.Text = "TRẠNG THÁI: KHỞI TẠO BỘ ĐẾM THÀNH CÔNG";
|
||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
Task.Run(() =>
|
||||
{
|
||||
Thread.Sleep(2);
|
||||
lblStatus.Text = "";
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Information("[ADMIN] reset counter fail");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnOpenEscrow_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Log.Information("[ADMIN] Do Check");
|
||||
var mainWindow = ((MainWindow)Application.Current.MainWindow);
|
||||
if (mainWindow!=null)
|
||||
mainWindow.DoCheck();
|
||||
}
|
||||
|
||||
private void btnGetCDMState_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.GetCDMState();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net8.0-windows
|
||||
build_property.TargetPlatformMinVersion = 7.0
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = VirtualKeyboard_haw2ca4l_wpftmp
|
||||
build_property.ProjectDir = D:\SRC\VirtualKeyboard\
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
@@ -0,0 +1,113 @@
|
||||
<UserControl x:Class="SafeBagDE70.DepositUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Background="#9edaf7"
|
||||
Loaded="UserControl_Loaded"
|
||||
Unloaded="UserControl_Unloaded">
|
||||
<Border BorderThickness="1" BorderBrush="Gray" Margin="10">
|
||||
<Grid x:Name="gridMainPanel">
|
||||
<!--<ContentControl x:Name="MainContent" />-->
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Border BorderThickness="0" BorderBrush="Gray">
|
||||
<StackPanel Grid.Row="0" hc:BorderElement.Circular="True">
|
||||
<Label Content="Vietinbank"
|
||||
Background="Transparent"
|
||||
Foreground="#1d619b"
|
||||
BorderThickness="0"
|
||||
FontWeight="Bold"
|
||||
FontSize="30"
|
||||
Height="50"/>
|
||||
|
||||
<Label HorizontalAlignment="Center"
|
||||
x:Name="lblUser"
|
||||
Background="Transparent"
|
||||
Foreground="White"
|
||||
BorderThickness="0"
|
||||
FontSize="20"
|
||||
FontWeight="Bold"
|
||||
Height="50"/>
|
||||
<Border BorderThickness="1" BorderBrush="Gray">
|
||||
<Separator BorderThickness="2" BorderBrush="Gray"/>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Grid Grid.Row="1" x:Name="gridMain" VerticalAlignment="Center" Margin="5" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="300"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Button Grid.Row="0" HorizontalAlignment="Stretch" Content="BẮT ĐẦU" x:Name="btnStart" Click="btnStart_Click" FontSize="30" Height="80" />
|
||||
<Button Grid.Row="1" HorizontalAlignment="Stretch" Content="KẾT THÚC" x:Name="btnEnd" Click="btnEnd_Click" FontSize="30" Height="80"/>
|
||||
<Button Grid.Row="2" HorizontalAlignment="Stretch" Content="KT LẤY TÚI" x:Name="btnCollect" Click="btnCollect_Click" FontSize="30" Height="80"/>
|
||||
</Grid>
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
<RowDefinition Height="100"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" HorizontalAlignment="Stretch" Content="NỘP TIỀN" x:Name="btnCountStart" Click="btnCountStart_Click" FontSize="30" Height="80"/>
|
||||
<Button Grid.Row="1" HorizontalAlignment="Stretch" Content="KIỂM TRA" x:Name="btnCheck" Click="btnCheck_Click" FontSize="30" Height="80"/>
|
||||
<Button Grid.Row="2" HorizontalAlignment="Stretch" Content="LƯU TRỮ" x:Name="btnStoreStart" Click="btnStoreStart_Click" FontSize="30" Height="80" />
|
||||
</Grid>
|
||||
<Grid Grid.Column="1">
|
||||
<ListView HorizontalAlignment="Center" FontSize="30" Width="600" x:Name="lvCount" Style="{StaticResource ListViewBaseStyle}">
|
||||
<ListView.View>
|
||||
<GridView>
|
||||
<GridViewColumn Header="Mệnh giá"
|
||||
DisplayMemberBinding="{Binding Name}"
|
||||
Width="200"/>
|
||||
<GridViewColumn Header="Số lượng"
|
||||
DisplayMemberBinding="{Binding Quantity}"
|
||||
Width="200"/>
|
||||
<GridViewColumn Header="Thành tiền"
|
||||
DisplayMemberBinding="{Binding Value}"
|
||||
Width="200"/>
|
||||
</GridView>
|
||||
</ListView.View>
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Padding" Value="0"/>
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
<Setter Property="BorderBrush" Value="Gray"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
</ListView>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel Grid.Row="2">
|
||||
<Separator BorderThickness="2" BorderBrush="Gray"/>
|
||||
<Label Height="40" x:Name="lblStatus" Background="Transparent" BorderThickness="0" Foreground="Red" FontSize="20" Content="TRẠNG THÁI"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
</Border>
|
||||
</UserControl>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
<UserControl x:Class="SafeBagDE70.Admin.AdminMainUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70.Admin"
|
||||
d:DesignHeight="1024" d:DesignWidth="1280"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<!-- Define Rows and Columns -->
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50"/>
|
||||
<!-- Top Bar -->
|
||||
<RowDefinition Height="*"/>
|
||||
<!-- Main Content Area -->
|
||||
<RowDefinition Height="30"/>
|
||||
<!-- Footer -->
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<!-- Sidebar -->
|
||||
<ColumnDefinition Width="*"/>
|
||||
<!-- Main Content Area -->
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Top Bar -->
|
||||
<StackPanel Grid.Row="0" Grid.ColumnSpan="2" Orientation="Horizontal" Background="Gray" Height="50">
|
||||
<TextBlock Text="Admin Panel" VerticalAlignment="Center" Margin="10" Foreground="White" FontSize="20"/>
|
||||
<Button Content="Log Out"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,10,0"
|
||||
Click="LogoutButton_Click"
|
||||
Background="Red"
|
||||
Foreground="White" Width="100"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Sidebar -->
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Background="LightGray" VerticalAlignment="Top">
|
||||
<Button
|
||||
Content="Dashboard"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="40"
|
||||
Margin="10"
|
||||
Click="DashboardButton_Click"/>
|
||||
<Button
|
||||
Content="User Management"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="40"
|
||||
Margin="10"
|
||||
Click="UserManagementButton_Click"/>
|
||||
<Button
|
||||
Content="Settings"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="40"
|
||||
Margin="10"
|
||||
Click="SettingsButton_Click"/>
|
||||
<Button
|
||||
Content="Reports"
|
||||
HorizontalAlignment="Stretch"
|
||||
Height="40"
|
||||
Margin="10"
|
||||
Padding="10"
|
||||
Click="ReportsButton_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Main Content Area -->
|
||||
<ContentControl Grid.Row="1" Grid.Column="1" x:Name="MainContentControl" Margin="10"/>
|
||||
|
||||
<!-- Footer -->
|
||||
<StackPanel Grid.Row="2" Grid.ColumnSpan="2" Orientation="Horizontal" Background="Gray" Height="30">
|
||||
<TextBlock Text="Admin Panel - Version 1.0" VerticalAlignment="Center" Margin="10" Foreground="White"/>
|
||||
<TextBlock Text="Status: Connected" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0" Foreground="Green"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,19 @@
|
||||
<hc:Window x:Class="SafeBagDE70.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="465" Width="810"
|
||||
ShowInTaskbar="False"
|
||||
ShowNonClientArea="False"
|
||||
IsFullScreen="True">
|
||||
<Grid>
|
||||
<ContentControl Name="MainContentControl"/>
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
4a056bf95b46531a2877476e4e0992b8c717c7956a532dafc823bd29f67e8c0f
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,56 @@
|
||||
using DE70_CMDv2;
|
||||
using SafeBagDE70.Services;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CollectionUC.xaml
|
||||
/// </summary>
|
||||
public partial class MaintainanceUC : UserControl
|
||||
{
|
||||
private bool _bContinue = false;
|
||||
private bool _bPlaySound = false;
|
||||
public MaintainanceUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void ShowInfor(string strInfor, bool bContinue = false, bool bPlaySound=true)
|
||||
{
|
||||
lblInfor.Text = strInfor;
|
||||
_bContinue = bContinue;
|
||||
_bPlaySound = bPlaySound;
|
||||
if (_bPlaySound)
|
||||
SoundManager.StartWarningSound();
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(_bContinue)
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen(false);
|
||||
else
|
||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (AppData.cCmdRsp != null)
|
||||
AppData.cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
SoundManager.StopWarningSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,909 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
using SafeBagDE70.Model;
|
||||
using HandyControl.Tools;
|
||||
using System.Drawing.Printing;
|
||||
using System.Drawing;
|
||||
using static HandyControl.Tools.Interop.InteropValues;
|
||||
using SafeBagDE70.API;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using DE70_CMDv2;
|
||||
using System.Configuration;
|
||||
|
||||
|
||||
namespace SafeBagDE70
|
||||
{ //Summary
|
||||
|
||||
|
||||
public partial class DepositUC : UserControl
|
||||
{
|
||||
SerialPort serialPortDE70 = new SerialPort();
|
||||
SerialPort serialPortSensor= new SerialPort();
|
||||
|
||||
List<CountSession> sessions = new List<CountSession>();
|
||||
ObservableCollection<LvCountItem> lvCountItems = new ObservableCollection<LvCountItem>();
|
||||
private DispatcherTimer timer;
|
||||
private DispatcherTimer sensorTimer;
|
||||
|
||||
int countTimer = 0;
|
||||
CCmdRsp cCmdRsp = null;
|
||||
bool bInitialized = false;
|
||||
|
||||
|
||||
public DepositUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InitTransaction();
|
||||
|
||||
}
|
||||
public void InitTransaction()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (AppData.IsAuthenticated)
|
||||
{
|
||||
lblUser.Content = $"Xin chào khách hàng: {AppData.CurrentCustomerAccount.Name} (Gian hàng {AppData.CurrentCustomerAccount.CustomerId})";
|
||||
}
|
||||
|
||||
// LoginUsingQRCode();
|
||||
if (serialPortDE70.IsOpen) serialPortDE70.Close();
|
||||
if (serialPortSensor.IsOpen) serialPortSensor.Close();
|
||||
|
||||
serialPortDE70.ReadBufferSize = 4096;
|
||||
serialPortDE70.WriteBufferSize = 4096;
|
||||
cCmdRsp = new CCmdRsp(serialPortDE70);
|
||||
AppData.cCmdRsp = cCmdRsp;
|
||||
|
||||
serialPortDE70.PortName = "COM4";
|
||||
serialPortDE70.BaudRate = 9600;
|
||||
serialPortDE70.Parity = Parity.Even;
|
||||
serialPortDE70.DataBits = 8;
|
||||
serialPortDE70.StopBits = StopBits.One;
|
||||
serialPortDE70.ReadTimeout = 10000;
|
||||
serialPortDE70.WriteTimeout = 10000;
|
||||
|
||||
serialPortSensor.PortName = "COM3";
|
||||
serialPortSensor.BaudRate = 9600;
|
||||
serialPortSensor.Parity = Parity.None;
|
||||
serialPortSensor.DataBits = 8;
|
||||
serialPortSensor.StopBits = StopBits.One;
|
||||
serialPortSensor.ReadTimeout = 1000;
|
||||
serialPortSensor.WriteTimeout = 1000;
|
||||
|
||||
|
||||
//Subscrible to the DataReveied event
|
||||
if (!serialPortDE70.IsOpen)
|
||||
serialPortDE70.Open();
|
||||
|
||||
if (!serialPortSensor.IsOpen)
|
||||
serialPortSensor.Open();
|
||||
|
||||
bInitialized = InitSession();
|
||||
|
||||
timer = new DispatcherTimer();
|
||||
timer.Interval = new TimeSpan(0, 0, 10); //10 seconds
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
sensorTimer = new DispatcherTimer();
|
||||
sensorTimer.Interval = new TimeSpan(0, 0, 1); //1 seconds
|
||||
sensorTimer.Tick += SensorTimer_Tick;
|
||||
sensorTimer.Start();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowError("LỖI CỔNG KẾT NỐI, VUI LÒNG KIỂM TRA LẠI CỔNG KẾT NỐI");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void EndTransaction()
|
||||
{
|
||||
try
|
||||
{
|
||||
AppData.IsInTransaction = false;
|
||||
if (timer != null)
|
||||
{
|
||||
timer.Tick -= Timer_Tick;
|
||||
timer.Stop();
|
||||
}
|
||||
if (sensorTimer != null)
|
||||
{
|
||||
sensorTimer.Tick -= SensorTimer_Tick;
|
||||
sensorTimer.Stop();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
public void SetStep(int step)
|
||||
{
|
||||
switch(step)
|
||||
{
|
||||
case 0:
|
||||
btnStart.IsEnabled = true;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = false;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 1:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled =false;
|
||||
break;
|
||||
case 2:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 3:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitSessionCount()
|
||||
{
|
||||
if (lvCount.Items.Count == 11) {
|
||||
foreach(var item in lvCountItems)
|
||||
{
|
||||
item.Quantity = "0";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "1000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "2000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "5000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "10000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "20000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "50000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "100000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "200000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "Tổng",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems[10].Quantity = "0";
|
||||
lvCountItems[10].Value = "0";
|
||||
}
|
||||
|
||||
|
||||
lvCount.ItemsSource = lvCountItems;
|
||||
|
||||
//lvCountItems[0].Quantity = "10";
|
||||
}
|
||||
public long maxQuantitySheet = 10000;
|
||||
public int quantityStored = 0;
|
||||
public int totalAllDenominations = 0;
|
||||
public int posDenomi;
|
||||
public bool printerFlag = false;
|
||||
public static string? recvDataString;
|
||||
public int[] TempQuantity = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
public int[] TempNote = new int[5] { 0, 0, 0, 0, 0 };
|
||||
public int[] Notes = new int[5] { 0, 0, 0, 0, 0 };
|
||||
|
||||
private void SensorTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
GetSensorValue();
|
||||
if (AppData.IsInTransaction)
|
||||
{
|
||||
if (AppData.WDTCount == 30)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowTimeoutScreen();
|
||||
}
|
||||
else if (AppData.WDTCount == 60)
|
||||
{
|
||||
//Nhận tiền và Kết thúc
|
||||
StoreStart();
|
||||
EndSession();
|
||||
|
||||
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
AppData.IsInTransaction = false;
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
AppData.WDTCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Stopwatch watch = new Stopwatch();
|
||||
private void GetSensorValue()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
int state = 0;
|
||||
if (serialPortSensor.IsOpen == true)
|
||||
{
|
||||
//serialPortSensor.DiscardInBuffer();
|
||||
//serialPortSensor.DiscardOutBuffer();
|
||||
|
||||
serialPortSensor.Write(new byte[] { (byte)'S', 13, 10 }, 0, 3);
|
||||
var buffer = new byte[16];
|
||||
|
||||
int n = serialPortSensor.Read(buffer, 0, buffer.Length);
|
||||
|
||||
|
||||
for (int i = 1; i < n - 1; i++)
|
||||
{
|
||||
if ((buffer[i] == 13) && (buffer[i + 1] == 10))
|
||||
{
|
||||
state = buffer[i - 1] - 48;
|
||||
if (bInitialized)
|
||||
{
|
||||
if (state != 0)
|
||||
gridMain.IsEnabled = false;
|
||||
else
|
||||
gridMain.IsEnabled = true;
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
lblStatus.Content = "NGĂN KÉT: ĐÓNG, NGĂN TÚI: ĐÓNG";
|
||||
break;
|
||||
case 1:
|
||||
lblStatus.Content = "NGĂN KÉT: ĐÓNG, NGĂN TÚI: MỞ";
|
||||
break;
|
||||
case 2:
|
||||
lblStatus.Content = "NGĂN KÉT: MỞ, NGĂN TÚI: ĐÓNG";
|
||||
break;
|
||||
case 3:
|
||||
lblStatus.Content = "NGĂN KÉT: MỞ, NGĂN TÚI: MỞ";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// the code that you want to measure comes here
|
||||
watch.Stop();
|
||||
|
||||
var elapsedMs = watch.ElapsedMilliseconds;
|
||||
Debug.WriteLine(elapsedMs);
|
||||
watch.Start();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException("GetSensorValue", ex.ToString());
|
||||
if(serialPortSensor.IsOpen)
|
||||
serialPortSensor.Close();
|
||||
serialPortSensor.Open();
|
||||
serialPortSensor.DiscardInBuffer();
|
||||
serialPortSensor.DiscardOutBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
private void Timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
|
||||
APIModels.SendHealthCheck();
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
public int UpdateTotalQuantity()
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var item in lvCountItems)
|
||||
{
|
||||
if (item.Name != "Tổng")
|
||||
{
|
||||
int quantity = 0;
|
||||
if (int.TryParse(item.Quantity, out quantity))
|
||||
{
|
||||
total += quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int AutoSerialGet(SerialPort serialPort)
|
||||
{
|
||||
int ret;
|
||||
ushort seri_num = 0;
|
||||
ushort get_num = 0;
|
||||
bool endflg = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
ret = cCmdRsp.SendSerialSense();
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
ret = cCmdRsp.GetSerialNum(out seri_num);
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
// Serial number acquisition
|
||||
|
||||
if (cCmdRsp.ChkCntEnd())
|
||||
{
|
||||
endflg = true;
|
||||
Debug.WriteLine("END FLAG: "+cCmdRsp.recv_dat.dat[1]);
|
||||
}
|
||||
Debug.WriteLine("START");
|
||||
Debug.WriteLine($"Num Serial: {seri_num}");
|
||||
|
||||
while (get_num < seri_num)
|
||||
{
|
||||
get_num++;
|
||||
ret = cCmdRsp.SendGetSerial(get_num);
|
||||
|
||||
|
||||
switch (cCmdRsp.recv_dat.dat[18])
|
||||
{
|
||||
case 0x00: TempNote[0] ++; Notes[0] += TempNote[0]; break;
|
||||
case 0x02:
|
||||
//TempNote[1] ++;
|
||||
switch (cCmdRsp.recv_dat.dat[17])
|
||||
{
|
||||
case 0x00: TempQuantity[0]++; break;
|
||||
case 0x01: TempQuantity[1]++; break;
|
||||
case 0x02: TempQuantity[2]++; break;
|
||||
case 0x03: TempQuantity[3]++; break;
|
||||
case 0x04: TempQuantity[4]++; break;
|
||||
case 0x05: TempQuantity[5]++; break;
|
||||
case 0x06: TempQuantity[6]++; break;
|
||||
case 0x07: TempQuantity[7]++; break;
|
||||
case 0x08: TempQuantity[8]++; break;
|
||||
case 0x09: TempQuantity[9]++; break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 0x03: TempNote[2] ++; Notes[2] += TempNote[2]; break;
|
||||
case 0x0b: TempNote[3] ++; Notes[3] += TempNote[3]; break;
|
||||
case 0x0c: TempNote[4] ++; Notes[4] += TempNote[4]; break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("END");
|
||||
//Debug.WriteLine("Ellapsed Time: " + timeSpan.TotalSeconds);
|
||||
if (endflg)
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END GET SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END SEND SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void btnCountStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CountStart();
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
|
||||
private void CountStart()
|
||||
{
|
||||
printerFlag = false;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
try
|
||||
{
|
||||
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
AppData.LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CNTSTART);
|
||||
//var recvData = DE70_CMD.SendxxCmd((byte)CMD_BYTE.CMD_DE_CNTSTART, serialPort);
|
||||
|
||||
//Thread.Sleep(20000);
|
||||
if (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[2] != 43) { }
|
||||
do
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_SENSE);
|
||||
}
|
||||
while (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[1] == 0x09); //SR2 = 0x09 : Counting Status
|
||||
|
||||
//SR3 = 0x43 : Stacker full
|
||||
|
||||
AutoSerialGet(serialPortDE70);
|
||||
|
||||
if (sessions == null || sessions.Count == 0)
|
||||
{
|
||||
double tempSum = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCountItems[i].Quantity = TempQuantity[9 - i].ToString();
|
||||
tempSum += lvCountItems[i].getValue();
|
||||
}
|
||||
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = tempSum.ToString();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
double sum = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
|
||||
}
|
||||
|
||||
a += TempQuantity[9 - i];
|
||||
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sum += lvCountItems[i].getValue();
|
||||
|
||||
}
|
||||
//Update amount of money
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sum.ToString();
|
||||
|
||||
}
|
||||
SetStep(2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheck_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
AppData.LogAction(currentMethod, null);
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
double sumStored;
|
||||
|
||||
//TempNote[1] = 0;
|
||||
|
||||
if (sessions != null)
|
||||
{
|
||||
sumStored = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
//quantityStored += lvCountItems[i].getQuantity();
|
||||
}
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sumStored += lvCountItems[i].getValue();
|
||||
}
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sumStored.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
private void btnStoreStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
StoreStart();
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
|
||||
private void StoreStart()
|
||||
{
|
||||
printerFlag = true;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
AppData.LogAction(currentMethod, null);
|
||||
sessions.Add(new CountSession());
|
||||
|
||||
sessions[sessions.Count - 1].QuantityDenomi = (int[])TempQuantity.Clone();
|
||||
quantityStored = UpdateTotalQuantity();
|
||||
|
||||
Debug.WriteLine(quantityStored);
|
||||
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||
SetStep(3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
InitSession();
|
||||
AppData.IsInTransaction= true;
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
AppData.LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
|
||||
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
SetStep(1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
AppData.WDTCount = 0;
|
||||
}
|
||||
|
||||
private async void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.IsInTransaction = false;
|
||||
AppData.WDTCount = 0;
|
||||
EndSession();
|
||||
}
|
||||
|
||||
private void EndSession()
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
var totalQuantity = lvCountItems[10].Quantity;
|
||||
var totalValue = lvCountItems[10].Value;
|
||||
try
|
||||
{
|
||||
AppData.LogAction(currentMethod, null);
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
//SendData2Server
|
||||
var data2Send = new CountingData2Send
|
||||
{
|
||||
Sessions = sessions,
|
||||
MachineId = null,
|
||||
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
||||
MachineTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
RejectNotes = Notes[0],
|
||||
GenuineNotes = quantityStored,
|
||||
UnfitNotes = Notes[2],
|
||||
CounterfeitNotes = Notes[3],
|
||||
SuspendNotes = Notes[4]
|
||||
|
||||
};
|
||||
|
||||
SyncData(data2Send);
|
||||
//Reset all and ready to next session
|
||||
|
||||
if (printerFlag == true)
|
||||
{
|
||||
PrintReceipt();
|
||||
printerFlag = false;
|
||||
|
||||
}
|
||||
InitSession();
|
||||
//Debug.WriteLine("Reject Note: " + Notes[0] );
|
||||
//Debug.WriteLine("Genuine note stored: " + quantityStored);
|
||||
//Debug.WriteLine("Unfit note: " + Notes[2]);
|
||||
//Debug.WriteLine("Counterfeit: " + Notes[3]);
|
||||
//Debug.WriteLine("Suspend: " + Notes[4]);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AppData.LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
|
||||
|
||||
String strNotify = $"BẠN VỪA THỰC HIỆN TIỀN VÀO MÁY CDM:\r\n"
|
||||
+ $"SỐ LƯỢNG TỜ: {totalQuantity}\r\n"
|
||||
+ $"SỐ TIỀN: {totalValue} VND\r\n";
|
||||
|
||||
((MainWindow)Application.Current.MainWindow).ShowInformationScreen(strNotify);
|
||||
}
|
||||
|
||||
private async Task SyncData(CountingData2Send data2Send)
|
||||
{
|
||||
var history = Save2DB(data2Send);
|
||||
bool bSuccess = await APIModels.SendCountingData(data2Send);
|
||||
if (bSuccess)
|
||||
{
|
||||
history.IsSent = true;
|
||||
Update2DB(history);
|
||||
}
|
||||
}
|
||||
|
||||
public History Save2DB(CountingData2Send data2Send)
|
||||
{
|
||||
var data = JsonConvert.SerializeObject(data2Send);
|
||||
var history = new History
|
||||
{
|
||||
Data = data,
|
||||
DepositTime = DateTime.Now,
|
||||
IsSent = false,
|
||||
UserCode = AppData.CurrentCustomerAccount.CustomerId
|
||||
};
|
||||
try
|
||||
{
|
||||
using (var db = new CDMDbContext())
|
||||
{
|
||||
|
||||
db.Histories.Add(history);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return history;
|
||||
}
|
||||
public History Update2DB(History history)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
using (var db = new CDMDbContext())
|
||||
{
|
||||
db.Histories.Update(history);
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return history;
|
||||
}
|
||||
|
||||
private void ShowError(string strError)
|
||||
{
|
||||
//gridMain.IsEnabled = false;
|
||||
//btnCollect2.Visibility=Visibility.Collapsed;
|
||||
//panelError.Visibility = Visibility.Visible;
|
||||
//lblError.Text = strError;
|
||||
//((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
((MainWindow)Application.Current.MainWindow).ShowErrorScreen(strError);
|
||||
}
|
||||
|
||||
private bool InitSession()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Check status
|
||||
cCmdRsp.SendDeSense();
|
||||
var data = cCmdRsp.recv_dat.dat;
|
||||
int IsCassetteFull = 0;
|
||||
int IsNotesInEscrow = 0;
|
||||
IsCassetteFull = data[17] & 0x08;
|
||||
IsNotesInEscrow = data[4] & 0x01;
|
||||
|
||||
if (IsCassetteFull != 0)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowCollectionScreen();
|
||||
return false;
|
||||
}
|
||||
else if (IsNotesInEscrow != 0)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowInformationScreen("ĐỀ NGHỊ BỎ TIỀN TRONG NGĂN PHỤ ĐỂ TIẾP TỤC");
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
sessions.Clear();
|
||||
Array.Clear(TempNote, 0, TempNote.Length);
|
||||
Array.Clear(Notes, 0, Notes.Length);
|
||||
quantityStored = 0;
|
||||
maxQuantitySheet = 0;
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
SetStep(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
AppData.LogException("InitSession", ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void PrintReceipt()
|
||||
{
|
||||
var shopName = AppData.CurrentCustomerAccount.Name;
|
||||
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
||||
var tradingCode = "TRA04052024CDM";
|
||||
var storeAccountNumber = 686868686688;
|
||||
var currentTime = DateTime.Now;
|
||||
var printDocument = new PrintDocument();
|
||||
|
||||
System.Drawing.Image LogoAeonMall = System.Drawing.Image.FromFile("Logo\\logoAeonmall.png");
|
||||
System.Drawing.Image LogoVietin = System.Drawing.Image.FromFile("Logo\\logoVietin.png");
|
||||
|
||||
printDocument.PrinterSettings.PrinterName = "CUSTOM K80";
|
||||
printDocument.PrintPage += (sender, e) =>
|
||||
{
|
||||
int fontSize = 8;
|
||||
int lineSpace = 20;
|
||||
float marginLeft = 25;
|
||||
float marginTop = 5;
|
||||
float width = 275;
|
||||
float height = 280;
|
||||
|
||||
float LogoAeonWidth = 90; // Chiều rộng của LogoAeon
|
||||
float LogoAeonHeight = 30; // Chiều cao của LogoAeon
|
||||
float LogoAeonX = marginLeft + 25; // Đặt LogoAeon ở giữa theo chiều ngang
|
||||
float LogoAeonY = marginTop + 10; // Khoảng cách từ mép trên của viền đến LogoAeon
|
||||
|
||||
float LogoVietinWidth = 90; // Chiều rộng của LogoVietin
|
||||
float LogoVietinHeight = 30; // Chiều cao của LogoVietin
|
||||
float LogoVietinX = marginLeft + 165; // Đặt LogoVietin ở giữa theo chiều ngang
|
||||
float LogoVietinY = marginTop + 10; // Khoảng cách từ mép trên của viền đến LogoVietin
|
||||
|
||||
e.Graphics.DrawImage(LogoVietin, LogoVietinX, LogoVietinY, LogoVietinWidth, LogoVietinHeight);
|
||||
e.Graphics.DrawImage(LogoAeonMall, LogoAeonX, LogoAeonY, LogoAeonWidth, LogoAeonHeight);
|
||||
|
||||
|
||||
e.Graphics.DrawImage(LogoVietin, LogoVietinX, LogoVietinY, LogoVietinWidth, LogoVietinHeight);
|
||||
e.Graphics.DrawImage(LogoAeonMall, LogoAeonX, LogoAeonY, LogoAeonWidth, LogoAeonHeight);
|
||||
|
||||
e.Graphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.Color.Black, 1), marginLeft, marginTop, width, height);
|
||||
|
||||
|
||||
e.Graphics.DrawString("Biên nhận nộp tiền", new Font("Arial", 12, System.Drawing.FontStyle.Bold), System.Drawing.Brushes.Black, new PointF(80, 50));
|
||||
e.Graphics.DrawString("Mã máy CDM: ", new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 1 + 65));
|
||||
e.Graphics.DrawString("Thời gian giao dịch: " + currentTime.ToString("dd/MM/yyyy HH:mm:ss"), new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 2 + 65));
|
||||
e.Graphics.DrawString("Mã giao dịch: " + tradingCode, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 3 + 65));
|
||||
e.Graphics.DrawString("Mã Gian hàng: " + shopCode, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 4 + 65));
|
||||
e.Graphics.DrawString("Tên Gian hàng: " + shopName, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 5 + 65));
|
||||
e.Graphics.DrawString("Số tài khoản gian hàng: " + storeAccountNumber, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 6 + 65));
|
||||
e.Graphics.DrawString("Nội dung giao dịch: Nop doanh so tien mat_", new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 7 + 65));
|
||||
e.Graphics.DrawString(shopCode, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 8 + 65));
|
||||
e.Graphics.DrawString("Số tiền nộp: " + lvCountItems[10].Value, new Font("Arial", fontSize), System.Drawing.Brushes.Black, new PointF(50, lineSpace * 9 + 65));
|
||||
e.Graphics.DrawString("*****Xin cám ơn*****", new Font("Arial", 7), System.Drawing.Brushes.Black, new PointF(120, lineSpace * 10 + 65));
|
||||
// To send raw ESC/POS commands, you'd typically use e.Graphics.DrawString() with the command string,
|
||||
// or for more complex scenarios, directly manipulate the byte stream sent to the printer.
|
||||
};
|
||||
printDocument.Print();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
EndTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 105 KiB |
@@ -0,0 +1,840 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
using SafeBagDE70.Model;
|
||||
using HandyControl.Tools;
|
||||
using System.Drawing.Printing;
|
||||
using System.Drawing;
|
||||
using static HandyControl.Tools.Interop.InteropValues;
|
||||
using SafeBagDE70.API;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using DE70_CMDv2;
|
||||
using System.Configuration;
|
||||
|
||||
|
||||
namespace SafeBagDE70
|
||||
{ //Summary
|
||||
public class CountSession
|
||||
{
|
||||
public CountSession() {
|
||||
for(int i= 0; i < QuantityDenomi.Count(); i++)
|
||||
{
|
||||
QuantityDenomi[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < SumDenomi.Count(); i++)
|
||||
{
|
||||
SumDenomi[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < TempNotes.Count(); i++)
|
||||
{
|
||||
TempNotes[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int[] QuantityDenomi { get; set; } = new int[10];
|
||||
public int[] SumDenomi { get; set; } = new int[10];
|
||||
public bool IsStored = false;
|
||||
public int[] TempNotes { get; set; } = new int[5];
|
||||
|
||||
}
|
||||
|
||||
public class CountingData2Send
|
||||
{
|
||||
public string? TransactionCode { get; set; }
|
||||
public List<CountSession>? Sessions { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
public string? MachineId { get; set; }
|
||||
public string? MachineTime { get; set; }
|
||||
public int RejectNotes { get; set; }
|
||||
public int GenuineNotes { get; set; }
|
||||
public int UnfitNotes { get; set; }
|
||||
public int CounterfeitNotes { get; set; }
|
||||
public int SuspendNotes { get; set; }
|
||||
}
|
||||
|
||||
public partial class MainUserWindow : HandyControl.Controls.Window
|
||||
{
|
||||
SerialPort serialPortDE70 = new SerialPort();
|
||||
SerialPort serialPortSensor= new SerialPort();
|
||||
|
||||
List<CountSession> sessions = new List<CountSession>();
|
||||
ObservableCollection<LvCountItem> lvCountItems = new ObservableCollection<LvCountItem>();
|
||||
private DispatcherTimer timer;
|
||||
private DispatcherTimer sensorTimer;
|
||||
int countTimer = 0;
|
||||
CCmdRsp cCmdRsp = null;
|
||||
bool bInitialized = false;
|
||||
|
||||
public MainUserWindow()
|
||||
{
|
||||
//Need to update: auto detect COM Port
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
//string queuePath = ConfigurationManager.AppSettings["SensorPort"].ToString();
|
||||
AppData.Init();
|
||||
//this.gridMain.IsEnabled = false;
|
||||
|
||||
|
||||
InitApp();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowError("LỖI CỔNG KẾT NỐI, VUI LÒNG KIỂM TRA LẠI CỔNG KẾT NỐI");
|
||||
//MessageBox.Show("Cổng đang mở, kiểm tra lại cổng kết nối");
|
||||
//this.Close();
|
||||
}
|
||||
}
|
||||
public void InitApp()
|
||||
{
|
||||
LoginUsingQRCode();
|
||||
panelError.Visibility = Visibility.Collapsed;
|
||||
|
||||
serialPortDE70.ReadBufferSize = 4096;
|
||||
serialPortDE70.WriteBufferSize = 4096;
|
||||
cCmdRsp = new CCmdRsp(serialPortDE70);
|
||||
|
||||
serialPortDE70.PortName = AppData.CDMPort;
|
||||
serialPortDE70.BaudRate = 9600;
|
||||
serialPortDE70.Parity = Parity.Even;
|
||||
serialPortDE70.DataBits = 8;
|
||||
serialPortDE70.StopBits = StopBits.One;
|
||||
|
||||
serialPortSensor.PortName = AppData.SensorPort;
|
||||
serialPortSensor.BaudRate = 9600;
|
||||
serialPortSensor.Parity = Parity.None;
|
||||
serialPortSensor.DataBits = 8;
|
||||
serialPortSensor.StopBits = StopBits.One;
|
||||
|
||||
//Subscrible to the DataReveied event
|
||||
|
||||
serialPortDE70.Open();
|
||||
serialPortSensor.Open();
|
||||
|
||||
bInitialized = InitSession();
|
||||
|
||||
timer = new DispatcherTimer();
|
||||
timer.Interval = new TimeSpan(0, 0, 10); //10 seconds
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
sensorTimer = new DispatcherTimer();
|
||||
sensorTimer.Interval = new TimeSpan(0, 0, 1); //10 seconds
|
||||
sensorTimer.Tick += SensorTimer_Tick;
|
||||
sensorTimer.Start();
|
||||
}
|
||||
|
||||
public void ShutdownApp()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (serialPortDE70.IsOpen)
|
||||
serialPortDE70.Close();
|
||||
if (serialPortSensor.IsOpen)
|
||||
serialPortSensor.Close();
|
||||
|
||||
if (timer != null)
|
||||
{
|
||||
timer.Tick -= Timer_Tick;
|
||||
timer.Stop();
|
||||
}
|
||||
if (sensorTimer != null)
|
||||
{
|
||||
sensorTimer.Tick -= SensorTimer_Tick;
|
||||
sensorTimer.Stop();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
public void SetStep(int step)
|
||||
{
|
||||
switch(step)
|
||||
{
|
||||
case 0:
|
||||
btnStart.IsEnabled = true;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = false;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 1:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled =false;
|
||||
break;
|
||||
case 2:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 3:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitSessionCount()
|
||||
{
|
||||
lvCountItems.Clear();
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "1000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "2000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "5000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "10000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "20000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "50000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "100000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "200000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "Tổng",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems[10].Quantity = "0";
|
||||
lvCountItems[10].Value = "0";
|
||||
|
||||
lvCount.ItemsSource = lvCountItems;
|
||||
|
||||
//lvCountItems[0].Quantity = "10";
|
||||
}
|
||||
public long maxQuantitySheet = 10000;
|
||||
public int quantityStored = 0;
|
||||
public int totalAllDenominations = 0;
|
||||
public int posDenomi;
|
||||
public bool printerFlag = false;
|
||||
public static string? recvDataString;
|
||||
public int[] TempQuantity = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
public int[] TempNote = new int[5] { 0, 0, 0, 0, 0 };
|
||||
public int[] Notes = new int[5] { 0, 0, 0, 0, 0 };
|
||||
|
||||
private void SensorTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
int state = 0;
|
||||
if (serialPortSensor.IsOpen==true)
|
||||
{
|
||||
serialPortSensor.Write(new byte[] { (byte)'S', 13, 10 }, 0, 3);
|
||||
var buffer = new byte[16];
|
||||
|
||||
int n = serialPortSensor.Read(buffer, 0, buffer.Length);
|
||||
|
||||
for (int i = 1; i < n - 1; i++)
|
||||
{
|
||||
if ((buffer[i] == 13) && (buffer[i + 1] == 10))
|
||||
{
|
||||
state = buffer[i - 1]-48;
|
||||
if(bInitialized)
|
||||
{
|
||||
if (state != 0)
|
||||
gridMain.IsEnabled = false;
|
||||
else
|
||||
gridMain.IsEnabled = true;
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
lblStatus.Content = "Két: đóng, Túi: đóng";
|
||||
break;
|
||||
case 1:
|
||||
lblStatus.Content = "Két: đóng, Túi: đã bị lấy ra";
|
||||
break;
|
||||
case 2:
|
||||
lblStatus.Content = "Két: mở, Túi: đóng";
|
||||
break;
|
||||
case 3:
|
||||
lblStatus.Content = "Két: mở, Túi: đã bị lấy ra";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
private void Timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
|
||||
APIModels.SendHealthCheck();
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
public int UpdateTotalQuantity()
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var item in lvCountItems)
|
||||
{
|
||||
if (item.Name != "Tổng")
|
||||
{
|
||||
int quantity = 0;
|
||||
if (int.TryParse(item.Quantity, out quantity))
|
||||
{
|
||||
total += quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int AutoSerialGet(SerialPort serialPort)
|
||||
{
|
||||
int ret;
|
||||
ushort seri_num = 0;
|
||||
ushort get_num = 0;
|
||||
bool endflg = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
ret = cCmdRsp.SendSerialSense();
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
ret = cCmdRsp.GetSerialNum(out seri_num);
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
// Serial number acquisition
|
||||
|
||||
if (cCmdRsp.ChkCntEnd())
|
||||
{
|
||||
endflg = true;
|
||||
Debug.WriteLine("END FLAG: "+cCmdRsp.recv_dat.dat[1]);
|
||||
}
|
||||
Debug.WriteLine("START");
|
||||
Debug.WriteLine($"Num Serial: {seri_num}");
|
||||
|
||||
while (get_num < seri_num)
|
||||
{
|
||||
get_num++;
|
||||
ret = cCmdRsp.SendGetSerial(get_num);
|
||||
|
||||
|
||||
switch (cCmdRsp.recv_dat.dat[18])
|
||||
{
|
||||
case 0x00: TempNote[0] ++; Notes[0] += TempNote[0]; break;
|
||||
case 0x02:
|
||||
//TempNote[1] ++;
|
||||
switch (cCmdRsp.recv_dat.dat[17])
|
||||
{
|
||||
case 0x00: TempQuantity[0]++; break;
|
||||
case 0x01: TempQuantity[1]++; break;
|
||||
case 0x02: TempQuantity[2]++; break;
|
||||
case 0x03: TempQuantity[3]++; break;
|
||||
case 0x04: TempQuantity[4]++; break;
|
||||
case 0x05: TempQuantity[5]++; break;
|
||||
case 0x06: TempQuantity[6]++; break;
|
||||
case 0x07: TempQuantity[7]++; break;
|
||||
case 0x08: TempQuantity[8]++; break;
|
||||
case 0x09: TempQuantity[9]++; break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 0x03: TempNote[2] ++; Notes[2] += TempNote[2]; break;
|
||||
case 0x0b: TempNote[3] ++; Notes[3] += TempNote[3]; break;
|
||||
case 0x0c: TempNote[4] ++; Notes[4] += TempNote[4]; break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("END");
|
||||
//Debug.WriteLine("Ellapsed Time: " + timeSpan.TotalSeconds);
|
||||
if (endflg)
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END GET SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END SEND SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void btnCountStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
printerFlag = false;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
try
|
||||
{
|
||||
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CNTSTART);
|
||||
//var recvData = DE70_CMD.SendxxCmd((byte)CMD_BYTE.CMD_DE_CNTSTART, serialPort);
|
||||
|
||||
//Thread.Sleep(20000);
|
||||
if (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[2] != 43) { }
|
||||
do
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_SENSE);
|
||||
}
|
||||
while (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[1] == 0x09); //SR2 = 0x09 : Counting Status
|
||||
|
||||
//SR3 = 0x43 : Stacker full
|
||||
|
||||
AutoSerialGet(serialPortDE70);
|
||||
|
||||
if (sessions == null || sessions.Count == 0)
|
||||
{
|
||||
double tempSum = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCountItems[i].Quantity = TempQuantity[9 - i].ToString();
|
||||
tempSum += lvCountItems[i].getValue();
|
||||
}
|
||||
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = tempSum.ToString();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
double sum = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
|
||||
}
|
||||
|
||||
a += TempQuantity[9 - i];
|
||||
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sum += lvCountItems[i].getValue();
|
||||
|
||||
}
|
||||
//Update amount of money
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sum.ToString();
|
||||
|
||||
}
|
||||
SetStep(2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheck_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
double sumStored;
|
||||
|
||||
//TempNote[1] = 0;
|
||||
|
||||
if (sessions != null)
|
||||
{
|
||||
sumStored = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
//quantityStored += lvCountItems[i].getQuantity();
|
||||
}
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sumStored += lvCountItems[i].getValue();
|
||||
}
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sumStored.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
private void btnStoreStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
printerFlag = true;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
sessions.Add(new CountSession());
|
||||
|
||||
sessions[sessions.Count - 1].QuantityDenomi = (int[])TempQuantity.Clone();
|
||||
quantityStored = UpdateTotalQuantity();
|
||||
|
||||
Debug.WriteLine(quantityStored);
|
||||
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||
SetStep(3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
InitSession();
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
|
||||
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
SetStep(1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
LogAction(currentMethod, null);
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
//SendData2Server
|
||||
var data2Send = new CountingData2Send
|
||||
{
|
||||
Sessions = sessions,
|
||||
MachineId = null,
|
||||
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
||||
MachineTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
RejectNotes = Notes[0],
|
||||
GenuineNotes = quantityStored,
|
||||
UnfitNotes = Notes[2],
|
||||
CounterfeitNotes = Notes[3],
|
||||
SuspendNotes = Notes[4]
|
||||
|
||||
};
|
||||
var str = JsonConvert.SerializeObject(data2Send);
|
||||
|
||||
APIModels.SendCountingData(data2Send);
|
||||
//Reset all and ready to next session
|
||||
|
||||
if(printerFlag == true)
|
||||
{
|
||||
PrintReceipt();
|
||||
printerFlag = false;
|
||||
|
||||
}
|
||||
InitSession();
|
||||
//Debug.WriteLine("Reject Note: " + Notes[0] );
|
||||
//Debug.WriteLine("Genuine note stored: " + quantityStored);
|
||||
//Debug.WriteLine("Unfit note: " + Notes[2]);
|
||||
//Debug.WriteLine("Counterfeit: " + Notes[3]);
|
||||
//Debug.WriteLine("Suspend: " + Notes[4]);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
LoginUsingQRCode();
|
||||
|
||||
}
|
||||
private void ShowError(string strError)
|
||||
{
|
||||
gridMain.IsEnabled = false;
|
||||
btnCollect2.Visibility=Visibility.Collapsed;
|
||||
panelError.Visibility = Visibility.Visible;
|
||||
lblError.Text = strError;
|
||||
}
|
||||
|
||||
private bool InitSession()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Check status
|
||||
cCmdRsp.SendDeSense();
|
||||
var data = cCmdRsp.recv_dat.dat;
|
||||
int IsCassetteFull=data[17] & 0x08;
|
||||
if(IsCassetteFull != 0)
|
||||
{
|
||||
ShowError("TÚI ĐẦY, ĐỀ NGHỊ LẤY TÚI TRƯỚC KHI TIẾP TỤC THAO TÁC");
|
||||
btnCollect2.Visibility=Visibility.Visible;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
sessions.Clear();
|
||||
Array.Clear(TempNote, 0, TempNote.Length);
|
||||
Array.Clear(Notes, 0, Notes.Length);
|
||||
quantityStored = 0;
|
||||
maxQuantitySheet = 0;
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
SetStep(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogException("InitSession", ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void PrintReceipt()
|
||||
{
|
||||
var shopName = AppData.CurrentCustomerAccount.Name;
|
||||
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
||||
var tradingCode = "TRA04052024CDM";
|
||||
var storeAccountNumber = 686868686688;
|
||||
var currentTime = DateTime.Now;
|
||||
var printDocument = new PrintDocument();
|
||||
printDocument.PrinterSettings.PrinterName = "CUSTOM K80";
|
||||
printDocument.PrintPage += (sender, e) =>
|
||||
{
|
||||
e.Graphics.DrawString("Biên nhận nộp tiền", new Font("Arial", 15), System.Drawing.Brushes.Black, new PointF(80, 10));
|
||||
e.Graphics.DrawString("Mã máy CDM: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 60));
|
||||
e.Graphics.DrawString("Batch no: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 90));
|
||||
e.Graphics.DrawString("Thời gian GD: " + currentTime.ToString("dd/MM/yyyy HH:mm:ss"), new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 120));
|
||||
e.Graphics.DrawString("Mã GD: " + tradingCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 150));
|
||||
e.Graphics.DrawString("Mã gian hàng: " + shopCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 180));
|
||||
e.Graphics.DrawString("Tên gian hàng: " + shopName, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 210));
|
||||
e.Graphics.DrawString("STK gian hàng: " + storeAccountNumber, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 240));
|
||||
e.Graphics.DrawString("Số tiền nộp: " + lvCountItems[10].Value, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 270));
|
||||
e.Graphics.DrawString("*****Xin cám ơn******", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(100, 300));
|
||||
// To send raw ESC/POS commands, you'd typically use e.Graphics.DrawString() with the command string,
|
||||
// or for more complex scenarios, directly manipulate the byte stream sent to the printer.
|
||||
};
|
||||
printDocument.Print();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void LogAction(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("log.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
public void LogException(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("logException.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
private void LoginUsingQRCode()
|
||||
{
|
||||
var wnd = new WelcomeWindow();
|
||||
wnd.ShowDialog();
|
||||
|
||||
lblUser.Content = "";
|
||||
//var wnd = new QRCodeZebraWindow();
|
||||
//wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
var strQR = wnd.QRCodeContent;
|
||||
var strPincode = wnd.PinCode;
|
||||
if (AppData.customerAccounts!=null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if(strQR!=null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == strQR).FirstOrDefault();
|
||||
}
|
||||
else if(strPincode!=null)
|
||||
{
|
||||
strPincode = strPincode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
AppData.CurrentCustomerAccount = cca;
|
||||
lblUser.Content = $"Xin chào khách hàng: {cca.Name} (Gian hàng {cca.CustomerId})";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("QRCode không đúng, vui lòng thử lại");
|
||||
LoginUsingQRCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnLoginByPINCode_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var wnd = new PinCodeWindow();
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnCollect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
//Event fix
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
|
||||
var currentMode = cCmdRsp.GetLockParam().mode;
|
||||
cCmdRsp.GetLockParam().mode = Mode.MODE_COLLECTION;
|
||||
cCmdRsp.SendLock();
|
||||
Thread.Sleep(10000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] != recvData.dat[16])
|
||||
{
|
||||
ShowError("Khởi tạo bộ đếm thành công");
|
||||
ShutdownApp();
|
||||
InitApp();
|
||||
}
|
||||
//Thread.Sleep(5000);
|
||||
//cCmdRsp.GetLockParam().mode = currentMode;
|
||||
//cCmdRsp.SendLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CollectionUC.xaml
|
||||
/// </summary>
|
||||
public partial class ErrorUC : UserControl
|
||||
{
|
||||
public ErrorUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public void ShowInfor(string strInfor)
|
||||
{
|
||||
lblError.Text = strInfor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
using CoreScanner;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeWindow.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeUC : UserControl
|
||||
{
|
||||
public string? QRCodeContent = null;
|
||||
public string? PinCode = null;
|
||||
public bool IsAuthenticated = false;
|
||||
public CCoreScannerClass? cCoreScannerClass=null;
|
||||
public WelcomeUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitQRCodeScanner();
|
||||
Loaded += WelcomeUC_Loaded;
|
||||
}
|
||||
|
||||
private void WelcomeUC_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.IsAuthenticated = false;
|
||||
}
|
||||
|
||||
private void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string pin = PinCodeBox.Password;
|
||||
|
||||
if (ValidatePin(pin))
|
||||
{
|
||||
PinCode=PinCodeBox.Password.ToString();
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (PinCode != null)
|
||||
{
|
||||
var strPincode = PinCode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
AppData.IsAuthenticated=true;
|
||||
AppData.CurrentCustomerAccount=cca;
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
//DialogResult = true;
|
||||
//this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblPincodeError.Content = "PINCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid PIN. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ForgotPin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Forgot PIN clicked.");
|
||||
}
|
||||
|
||||
private void Help_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Help clicked.");
|
||||
}
|
||||
|
||||
private bool ValidatePin(string pin)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
private async void PinCodeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var onScreenKeyboardProcess = new ProcessStartInfo("osk.exe")
|
||||
{
|
||||
UseShellExecute = true
|
||||
};
|
||||
Process.Start(onScreenKeyboardProcess);
|
||||
try
|
||||
{
|
||||
//var progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
|
||||
//var keyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
|
||||
//Process.Start(keyboardPath);
|
||||
// AutomationElement.FromHandle(-1);
|
||||
|
||||
// string keyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
|
||||
// Process.Start(keyboardPath);
|
||||
//await Launcher.LaunchUriAsync(new Uri("ms-inputapp://"));
|
||||
|
||||
//var onScreenKeyboardProcess = new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
|
||||
//{
|
||||
// UseShellExecute = true
|
||||
//};
|
||||
//Process.Start(onScreenKeyboardProcess);
|
||||
|
||||
QrCodePanel.Visibility = Visibility.Collapsed;
|
||||
PinCodePanel.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void btnQRCodeLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PinCodePanel.Visibility = Visibility.Collapsed;
|
||||
QrCodePanel.Visibility=Visibility.Visible;
|
||||
cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
|
||||
|
||||
}
|
||||
public void InitQRCodeScanner()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Instantiate CoreScanner Class
|
||||
cCoreScannerClass = new CCoreScannerClass();
|
||||
|
||||
// Call Open API
|
||||
short[] scannerTypes = new short[1]; // Scanner Types you are interested in
|
||||
scannerTypes[0] = 1; // 1 for all scanner types
|
||||
short numberOfScannerTypes = 1; // Size of the scannerTypes array
|
||||
int status; // Extended API return code
|
||||
|
||||
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
|
||||
|
||||
// Subscribe for barcode events in cCoreScannerClass
|
||||
|
||||
|
||||
// Let's subscribe for events
|
||||
int opcode = 1001; // Method for Subscribe events
|
||||
string outXML; // XML Output
|
||||
string inXML = "<inArgs>" +
|
||||
"<cmdArgs>" +
|
||||
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
|
||||
"<arg-int>1</arg-int>" + // Comma separated event IDs
|
||||
"</cmdArgs>" +
|
||||
"</inArgs>";
|
||||
|
||||
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("Something wrong please check... " + exp.Message);
|
||||
}
|
||||
}
|
||||
private void OnBarcodeEvent(short eventType, ref string pscanData)
|
||||
{
|
||||
string xmlString = pscanData;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(xmlString);
|
||||
|
||||
XmlNode rawDataNode = xmlDoc.SelectSingleNode("//datalabel");
|
||||
string rawDataHex = rawDataNode.InnerText.Trim();
|
||||
|
||||
QRCodeContent = HexStringToString(rawDataHex);
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
||||
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (QRCodeContent != null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == QRCodeContent).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
AppData.IsAuthenticated = true;
|
||||
AppData.CurrentCustomerAccount = cca;
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblQRcodeError.Content = "QRCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static string HexStringToString(string hexString)
|
||||
{
|
||||
string[] hexValues = hexString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] bytes = new byte[hexValues.Length];
|
||||
|
||||
for (int i = 0; i < hexValues.Length; i++)
|
||||
{
|
||||
bytes[i] = Convert.ToByte(hexValues[i], 16);
|
||||
}
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<UserControl x:Class="SafeBagDE70.TimeoutUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<hc:SimpleStackPanel Background="White" VerticalAlignment="Center" Margin="20">
|
||||
<hc:HighlightTextBlock x:Name="lblInfor" Text="BẠN CÓ MUỐN TIẾP TỤC?" FontSize="20" TextWrapping="Wrap" FontWeight="Bold" Foreground="Blue" HorizontalAlignment="Center"/>
|
||||
<Separator/>
|
||||
<Grid Margin="10">
|
||||
<Button x:Name="btnEnd" Click="btnEnd_Click" Grid.Column="0" Style="{StaticResource ButtonPrimary}" Content="TIẾP TỤC" Height="50" Width="200"/>
|
||||
</Grid>
|
||||
</hc:SimpleStackPanel>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace VirtualKeyboard.Wpf.Views
|
||||
{
|
||||
/// <summary>
|
||||
/// Logika interakcji dla klasy KeyboardValueView.xaml
|
||||
/// </summary>
|
||||
partial class KeyboardValueView : UserControl
|
||||
{
|
||||
public KeyboardValueView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,229 @@
|
||||
using CoreScanner;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeWindow.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeUC : UserControl
|
||||
{
|
||||
public string? QRCodeContent = null;
|
||||
public string? PinCode = null;
|
||||
public bool IsAuthenticated = false;
|
||||
public CCoreScannerClass? cCoreScannerClass=null;
|
||||
public WelcomeUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitQRCodeScanner();
|
||||
Loaded += WelcomeUC_Loaded;
|
||||
}
|
||||
|
||||
private void WelcomeUC_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.IsAuthenticated = false;
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
AppData.IsAuthenticated = false;
|
||||
AppData.CurrentCustomerAccount = null;
|
||||
lblPincodeError.Content = "";
|
||||
PinCodeBox.Text = "";
|
||||
}
|
||||
|
||||
private void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string pin = PinCodeBox.Text;
|
||||
|
||||
if (ValidatePin(pin))
|
||||
{
|
||||
PinCode=PinCodeBox.Text.ToString();
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (PinCode != null)
|
||||
{
|
||||
var strPincode = PinCode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
AppData.IsAuthenticated=true;
|
||||
AppData.CurrentCustomerAccount=cca;
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
//DialogResult = true;
|
||||
//this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblPincodeError.Content = "PINCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid PIN. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ForgotPin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Forgot PIN clicked.");
|
||||
}
|
||||
|
||||
private void Help_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Help clicked.");
|
||||
}
|
||||
|
||||
private bool ValidatePin(string pin)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
private async void PinCodeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var onScreenKeyboardProcess = new ProcessStartInfo("osk.exe")
|
||||
{
|
||||
UseShellExecute = true
|
||||
};
|
||||
try
|
||||
{
|
||||
//var progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
|
||||
//var keyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
|
||||
//Process.Start(keyboardPath);
|
||||
// AutomationElement.FromHandle(-1);
|
||||
|
||||
// string keyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
|
||||
// Process.Start(keyboardPath);
|
||||
//await Launcher.LaunchUriAsync(new Uri("ms-inputapp://"));
|
||||
|
||||
//var onScreenKeyboardProcess = new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
|
||||
//{
|
||||
// UseShellExecute = true
|
||||
//};
|
||||
//Process.Start(onScreenKeyboardProcess);
|
||||
|
||||
QrCodePanel.Visibility = Visibility.Collapsed;
|
||||
PinCodePanel.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void btnQRCodeLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PinCodePanel.Visibility = Visibility.Collapsed;
|
||||
QrCodePanel.Visibility=Visibility.Visible;
|
||||
cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
|
||||
|
||||
}
|
||||
public void InitQRCodeScanner()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Instantiate CoreScanner Class
|
||||
cCoreScannerClass = new CCoreScannerClass();
|
||||
|
||||
// Call Open API
|
||||
short[] scannerTypes = new short[1]; // Scanner Types you are interested in
|
||||
scannerTypes[0] = 1; // 1 for all scanner types
|
||||
short numberOfScannerTypes = 1; // Size of the scannerTypes array
|
||||
int status; // Extended API return code
|
||||
|
||||
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
|
||||
|
||||
// Subscribe for barcode events in cCoreScannerClass
|
||||
|
||||
|
||||
// Let's subscribe for events
|
||||
int opcode = 1001; // Method for Subscribe events
|
||||
string outXML; // XML Output
|
||||
string inXML = "<inArgs>" +
|
||||
"<cmdArgs>" +
|
||||
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
|
||||
"<arg-int>1</arg-int>" + // Comma separated event IDs
|
||||
"</cmdArgs>" +
|
||||
"</inArgs>";
|
||||
|
||||
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("Something wrong please check... " + exp.Message);
|
||||
}
|
||||
}
|
||||
private void OnBarcodeEvent(short eventType, ref string pscanData)
|
||||
{
|
||||
string xmlString = pscanData;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(xmlString);
|
||||
|
||||
XmlNode rawDataNode = xmlDoc.SelectSingleNode("//datalabel");
|
||||
string rawDataHex = rawDataNode.InnerText.Trim();
|
||||
|
||||
QRCodeContent = HexStringToString(rawDataHex);
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
||||
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (QRCodeContent != null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == QRCodeContent).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
AppData.IsAuthenticated = true;
|
||||
AppData.CurrentCustomerAccount = cca;
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblQRcodeError.Content = "QRCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static string HexStringToString(string hexString)
|
||||
{
|
||||
string[] hexValues = hexString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] bytes = new byte[hexValues.Length];
|
||||
|
||||
for (int i = 0; i < hexValues.Length; i++)
|
||||
{
|
||||
bytes[i] = Convert.ToByte(hexValues[i], 16);
|
||||
}
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#pragma checksum "..\..\..\..\Views\KeyboardValueView.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "7CEB2F6BE0031A78F4843553F03A6F9656DD4608"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Controls.Ribbon;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Media.Effects;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Windows.Media.TextFormatting;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Shell;
|
||||
using VirtualKeyboard.Wpf.Controls;
|
||||
using VirtualKeyboard.Wpf.Views;
|
||||
|
||||
|
||||
namespace VirtualKeyboard.Wpf.Views {
|
||||
|
||||
|
||||
internal partial class KeyboardValueView : System.Windows.Controls.UserControl, System.Windows.Markup.IComponentConnector {
|
||||
|
||||
private bool _contentLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// InitializeComponent
|
||||
/// </summary>
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
|
||||
public void InitializeComponent() {
|
||||
if (_contentLoaded) {
|
||||
return;
|
||||
}
|
||||
_contentLoaded = true;
|
||||
System.Uri resourceLocater = new System.Uri("/VirtualKeyboard;component/views/keyboardvalueview.xaml", System.UriKind.Relative);
|
||||
|
||||
#line 1 "..\..\..\..\Views\KeyboardValueView.xaml"
|
||||
System.Windows.Application.LoadComponent(this, resourceLocater);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal System.Delegate _CreateDelegate(System.Type delegateType, string handler) {
|
||||
return System.Delegate.CreateDelegate(delegateType, this, handler);
|
||||
}
|
||||
|
||||
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("PresentationBuildTasks", "8.0.7.0")]
|
||||
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Design", "CA1033:InterfaceMethodsShouldBeCallableByChildTypes")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
|
||||
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
|
||||
this._contentLoaded = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AdminLoginUC.xaml
|
||||
/// </summary>
|
||||
public partial class AdminLoginUC : UserControl
|
||||
{
|
||||
public AdminLoginUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string username = UsernameTextBox.Text;
|
||||
string password = PasswordBox.Password;
|
||||
|
||||
// Simple authentication logic
|
||||
if (username == "admin" && password == "password") // Replace with actual logic
|
||||
{
|
||||
// Load Settings UserControl
|
||||
var mainWindow = (MainWindow)Window.GetWindow(this);
|
||||
//mainWindow.LoadUserControl(new SettingsUserControl());
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid username or password.", "Login Failed", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using DE70_CMDv2;
|
||||
using SafeBagDE70.Model;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
public static class AppData
|
||||
{
|
||||
public static string CDMPort = "COM4";
|
||||
public static string SensorPort = "COM3";
|
||||
public static Version? CurrentVersion = null;
|
||||
public static List<CustomerAccount>? customerAccounts = null;
|
||||
public static CustomerAccount? CurrentCustomerAccount{get;set;}
|
||||
public static CCmdRsp? cCmdRsp=null;
|
||||
public static bool IsAuthenticated = false;
|
||||
public static bool IsInTransaction = false;
|
||||
public static int WDTCount = 0;
|
||||
public static ObservableCollection<string> logCollection = new ObservableCollection<string>();
|
||||
public static ListView logListView = null;
|
||||
public static int MaxLogCount = 500;
|
||||
public static void Init()
|
||||
{
|
||||
|
||||
customerAccounts = new List<CustomerAccount>{
|
||||
new CustomerAccount{Name="NGUYỄN ĐÌNH THUẬN",CustomerId="HUE_0000000001",QRCode="HUE_0000000001",PINCode="H0001" },
|
||||
new CustomerAccount{Name="HOÀNG VĂN HIỆP",CustomerId="HUE_0000000002",QRCode="HUE_0000000002",PINCode="H0002" },
|
||||
new CustomerAccount{Name="PHẠM NGỌC HƯNG",CustomerId="HUE_0000000003",QRCode="HUE_0000000003",PINCode="H0003" },
|
||||
new CustomerAccount{Name="AMHUE-ESTELLETEST",CustomerId="00DZAMHUE0004",QRCode="00DZAMHUE0004",PINCode="H0004" },
|
||||
new CustomerAccount{Name="AMHUE-ECCOTEST",CustomerId="00DZAMHUE0005",QRCode="00DZAMHUE0005",PINCode="H0005" },
|
||||
new CustomerAccount{Name="AMHUE-ALDOTEST",CustomerId="00DZAMHUE0006",QRCode="00DZAMHUE0006",PINCode="H0006" },
|
||||
new CustomerAccount{Name="AMHUE-MLBTEST",CustomerId="00DZAMHUE0007",QRCode="00DZAMHUE0007",PINCode="H0007" },
|
||||
new CustomerAccount{Name="AMHUE-PEDROTEST",CustomerId="00DZAMHUE0008",QRCode="00DZAMHUE0008",PINCode="H0008" }
|
||||
};
|
||||
CurrentCustomerAccount = customerAccounts[0];
|
||||
}
|
||||
private static DateTime CutOffTime = new DateTime(1, 1, 1, 12, 0, 0); // 12:00 noon as cut-off time
|
||||
|
||||
public static void GetNewTransactionCode()
|
||||
{
|
||||
DateTime transactionDateTime = DateTime.Now;
|
||||
string merchantCode = CurrentCustomerAccount.CustomerId;
|
||||
|
||||
// Adjust transaction date if it's past cut-off time (12:00 noon)
|
||||
DateTime prevadjustedDate = CurrentCustomerAccount.TransactionTime.Hour >= CutOffTime.Hour ? transactionDateTime.Date : transactionDateTime.Date.AddDays(-1);
|
||||
|
||||
DateTime adjustedDate = transactionDateTime.Hour >= CutOffTime.Hour ? transactionDateTime.Date : transactionDateTime.Date.AddDays(-1);
|
||||
if ((adjustedDate - prevadjustedDate).Days > 0)
|
||||
{
|
||||
CurrentCustomerAccount.TransactionCount =1;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentCustomerAccount.TransactionCount++;
|
||||
}
|
||||
var transactionCount = CurrentCustomerAccount.TransactionCount;
|
||||
string datePart = adjustedDate.ToString("yyyyMMdd");
|
||||
string timePart = transactionDateTime.ToString("HHmmss");
|
||||
string transactionCountPart = transactionCount.ToString("D2"); // Ensure 2 digits
|
||||
|
||||
// Combine all parts to form the transaction ID
|
||||
string transactionId = $"{datePart}{timePart}{merchantCode}{transactionCountPart}";
|
||||
|
||||
CurrentCustomerAccount.TransactionCode = transactionId;
|
||||
CurrentCustomerAccount.TransactionTime = transactionDateTime;
|
||||
}
|
||||
|
||||
}
|
||||
public class CustomerAccount
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? CustomerId { get; set; }
|
||||
public string? QRCode { get; set; }
|
||||
public string? PINCode { get; set; }
|
||||
public int TransactionCount { get; set; } = 1;
|
||||
public DateTime TransactionTime { get; set; }
|
||||
public string TransactionCode { get; set; }
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,60 @@
|
||||
<UserControl x:Class="SafeBagDE70.WelcomeUC"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
x:Name="ucWelcome"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Top Section -->
|
||||
<StackPanel Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0">
|
||||
<Image Source="icon/logo.ico" Width="200" Height="200" Margin="0,10,0,10" Stretch="UniformToFill"/>
|
||||
<TextBlock Text="Xin chào! Hãy lựa chọn hình thức đăng nhập để tiếp tục" FontSize="24" FontWeight="Bold" TextAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Middle Section -->
|
||||
<Grid Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button hc:IconElement.Geometry="{StaticResource FullScreenGeometry}" Grid.Column="0" Grid.Row="0" x:Name="btnQRCodeLogin" Content="QR CODE" Width="200" Height="100" Margin="0,0,10,0" FontSize="20" FontWeight="Bold" Click="btnQRCodeLogin_Click"/>
|
||||
<Button Grid.Column="2" Grid.Row="0" x:Name="btnPinCodeLogin" Content="PIN CODE" Width="200" Height="100" Margin="10,0,0,0" Click="PinCodeButton_Click" FontSize="20" FontWeight="Bold"/>
|
||||
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="PinCodePanel">
|
||||
<TextBox x:Name="PinCodeBox" Width="300" Height="60" FontSize="20" HorizontalContentAlignment="Center" Margin="0,10,0,0"/>
|
||||
<TextBlock Text="Quên mã PIN?" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" Margin="0,5,0,0" MouseLeftButtonUp="ForgotPin_Click"/>
|
||||
<Button Content="Đăng nhập" Width="200" Height="40" Margin="0,10,0,0" Click="LoginButton_Click"/>
|
||||
<Label x:Name="lblPincodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="QrCodePanel">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Đưa QR Code của bạn vào đầu đọc" FontSize="20"/>
|
||||
<hc:LoadingCircle Background="Transparent" VerticalAlignment="Bottom" Width="50" Height="50" Margin="10"/>
|
||||
<Label x:Name="lblQRcodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Bottom Section -->
|
||||
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock x:Name="txtVersion" Text="TRỢ GIÚP" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" MouseLeftButtonUp="Help_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SafeBagDE70.StateMachine
|
||||
{
|
||||
public class StateMachineConfig
|
||||
{
|
||||
public List<string> States { get; set; }
|
||||
public List<Transition> Transitions { get; set; }
|
||||
public Dictionary<string, string> Actions { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using CoreScanner;
|
||||
using SafeBagDE70.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using System.Xml;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for QRCodeWindow.xaml
|
||||
/// </summary>
|
||||
public partial class QRCodeZebraWindow : HandyControl.Controls.Window
|
||||
{
|
||||
|
||||
public string QRCodeContent = null;
|
||||
public CCoreScannerClass cCoreScannerClass;
|
||||
public QRCodeZebraWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
Init();
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Instantiate CoreScanner Class
|
||||
cCoreScannerClass = new CCoreScannerClass();
|
||||
|
||||
// Call Open API
|
||||
short[] scannerTypes = new short[1]; // Scanner Types you are interested in
|
||||
scannerTypes[0] = 1; // 1 for all scanner types
|
||||
short numberOfScannerTypes = 1; // Size of the scannerTypes array
|
||||
int status; // Extended API return code
|
||||
|
||||
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
|
||||
|
||||
// Subscribe for barcode events in cCoreScannerClass
|
||||
cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
|
||||
// Let's subscribe for events
|
||||
int opcode = 1001; // Method for Subscribe events
|
||||
string outXML; // XML Output
|
||||
string inXML = "<inArgs>" +
|
||||
"<cmdArgs>" +
|
||||
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
|
||||
"<arg-int>1</arg-int>" + // Comma separated event IDs
|
||||
"</cmdArgs>" +
|
||||
"</inArgs>";
|
||||
|
||||
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("Something wrong please check... " + exp.Message);
|
||||
}
|
||||
}
|
||||
private void OnBarcodeEvent(short eventType, ref string pscanData)
|
||||
{
|
||||
string xmlString = pscanData;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(xmlString);
|
||||
|
||||
XmlNode rawDataNode = xmlDoc.SelectSingleNode("//datalabel");
|
||||
string rawDataHex = rawDataNode.InnerText.Trim();
|
||||
|
||||
QRCodeContent = HexStringToString(rawDataHex);
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
DialogResult = true;
|
||||
this.Close();
|
||||
});
|
||||
}
|
||||
|
||||
static string HexStringToString(string hexString)
|
||||
{
|
||||
string[] hexValues = hexString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] bytes = new byte[hexValues.Length];
|
||||
|
||||
for (int i = 0; i < hexValues.Length; i++)
|
||||
{
|
||||
bytes[i] = Convert.ToByte(hexValues[i], 16);
|
||||
}
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,62 @@
|
||||
using HandyControl.Tools.Extension;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SafeBagDE70.Admin
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AdminWindow.xaml
|
||||
/// </summary>
|
||||
public partial class AdminWindow : HandyControl.Controls.Window
|
||||
{
|
||||
LogViewerUC loguc;
|
||||
AdminConfigurationUC configuration;
|
||||
public AdminWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
loguc= new LogViewerUC(AppData.logCollection);
|
||||
configuration = new AdminConfigurationUC();
|
||||
this.MainContentControl.Content = loguc;
|
||||
}
|
||||
private void LogoutButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void UserManagementButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void DashboardButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.MainContentControl.Content = loguc;
|
||||
}
|
||||
|
||||
private void SettingsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ReportsButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void ConfigurationButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.MainContentControl.Content = configuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 78 KiB |
@@ -0,0 +1,23 @@
|
||||
<Application x:Class="SafeBagDE70.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/VirtualKeyboard;component/ResourceDictionaries/DefaultStyles.xaml"/>
|
||||
<hc:ThemeResources RequestedTheme="Light">
|
||||
<ResourceDictionary x:Key="Light" hc:ThemeDictionary.Key="Light">
|
||||
|
||||
<!-- Put the resources you want to use in the Light theme Here -->
|
||||
|
||||
<SolidColorBrush x:Key="PrimaryBrush" Color="Red" />
|
||||
<SolidColorBrush x:Key="AppBackgroundBrush" Color="LightBlue" />
|
||||
</ResourceDictionary>
|
||||
</hc:ThemeResources>
|
||||
<hc:Theme/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,9 @@
|
||||
D:\SRC\VirtualKeyboard\obj\Debug\net8.0-windows\GeneratedInternalTypeHelper.g.cs
|
||||
|
||||
FD:\SRC\VirtualKeyboard\DefaultKeyboardHost.xaml;;
|
||||
FD:\SRC\VirtualKeyboard\ResourceDictionaries\KeyboardCore.xaml;;
|
||||
FD:\SRC\VirtualKeyboard\Views\AlphabetView.xaml;;
|
||||
FD:\SRC\VirtualKeyboard\Views\KeyboardValueView.xaml;;
|
||||
FD:\SRC\VirtualKeyboard\Views\SpecialCharactersView.xaml;;
|
||||
FD:\SRC\VirtualKeyboard\Views\VirtualKeyboardView.xaml;;
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
using CoreScanner;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeWindow.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeUC : UserControl
|
||||
{
|
||||
public string? QRCodeContent = null;
|
||||
public string? PinCode = null;
|
||||
public bool IsAuthenticated = false;
|
||||
public CCoreScannerClass? cCoreScannerClass=null;
|
||||
public WelcomeUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitQRCodeScanner();
|
||||
Loaded += WelcomeUC_Loaded;
|
||||
}
|
||||
|
||||
private void WelcomeUC_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.IsAuthenticated = false;
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
AppData.IsAuthenticated = false;
|
||||
AppData.CurrentCustomerAccount = null;
|
||||
lblPincodeError.Content = "";
|
||||
PinCodeBox.Text = "";
|
||||
}
|
||||
|
||||
private void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string pin = PinCodeBox.Text;
|
||||
|
||||
if (ValidatePin(pin))
|
||||
{
|
||||
PinCode=PinCodeBox.Text.ToString();
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (PinCode != null)
|
||||
{
|
||||
var strPincode = PinCode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
AppData.IsAuthenticated=true;
|
||||
AppData.CurrentCustomerAccount=cca;
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
//DialogResult = true;
|
||||
//this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblPincodeError.Content = "PINCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid PIN. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ForgotPin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Forgot PIN clicked.");
|
||||
}
|
||||
|
||||
private void Help_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Help clicked.");
|
||||
}
|
||||
|
||||
private bool ValidatePin(string pin)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
private async void PinCodeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var onScreenKeyboardProcess = new ProcessStartInfo("osk.exe")
|
||||
{
|
||||
UseShellExecute = true
|
||||
};
|
||||
Process.Start(onScreenKeyboardProcess);
|
||||
try
|
||||
{
|
||||
//var progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
|
||||
//var keyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
|
||||
//Process.Start(keyboardPath);
|
||||
// AutomationElement.FromHandle(-1);
|
||||
|
||||
// string keyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
|
||||
// Process.Start(keyboardPath);
|
||||
//await Launcher.LaunchUriAsync(new Uri("ms-inputapp://"));
|
||||
|
||||
//var onScreenKeyboardProcess = new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
|
||||
//{
|
||||
// UseShellExecute = true
|
||||
//};
|
||||
//Process.Start(onScreenKeyboardProcess);
|
||||
|
||||
QrCodePanel.Visibility = Visibility.Collapsed;
|
||||
PinCodePanel.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void btnQRCodeLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PinCodePanel.Visibility = Visibility.Collapsed;
|
||||
QrCodePanel.Visibility=Visibility.Visible;
|
||||
cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
|
||||
|
||||
}
|
||||
public void InitQRCodeScanner()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Instantiate CoreScanner Class
|
||||
cCoreScannerClass = new CCoreScannerClass();
|
||||
|
||||
// Call Open API
|
||||
short[] scannerTypes = new short[1]; // Scanner Types you are interested in
|
||||
scannerTypes[0] = 1; // 1 for all scanner types
|
||||
short numberOfScannerTypes = 1; // Size of the scannerTypes array
|
||||
int status; // Extended API return code
|
||||
|
||||
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
|
||||
|
||||
// Subscribe for barcode events in cCoreScannerClass
|
||||
|
||||
|
||||
// Let's subscribe for events
|
||||
int opcode = 1001; // Method for Subscribe events
|
||||
string outXML; // XML Output
|
||||
string inXML = "<inArgs>" +
|
||||
"<cmdArgs>" +
|
||||
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
|
||||
"<arg-int>1</arg-int>" + // Comma separated event IDs
|
||||
"</cmdArgs>" +
|
||||
"</inArgs>";
|
||||
|
||||
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("Something wrong please check... " + exp.Message);
|
||||
}
|
||||
}
|
||||
private void OnBarcodeEvent(short eventType, ref string pscanData)
|
||||
{
|
||||
string xmlString = pscanData;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(xmlString);
|
||||
|
||||
XmlNode rawDataNode = xmlDoc.SelectSingleNode("//datalabel");
|
||||
string rawDataHex = rawDataNode.InnerText.Trim();
|
||||
|
||||
QRCodeContent = HexStringToString(rawDataHex);
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
|
||||
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (QRCodeContent != null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == QRCodeContent).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
AppData.IsAuthenticated = true;
|
||||
AppData.CurrentCustomerAccount = cca;
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblQRcodeError.Content = "QRCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
static string HexStringToString(string hexString)
|
||||
{
|
||||
string[] hexValues = hexString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] bytes = new byte[hexValues.Length];
|
||||
|
||||
for (int i = 0; i < hexValues.Length; i++)
|
||||
{
|
||||
bytes[i] = Convert.ToByte(hexValues[i], 16);
|
||||
}
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,769 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
using SafeBagDE70.Model;
|
||||
using HandyControl.Tools;
|
||||
using System.Drawing.Printing;
|
||||
using System.Drawing;
|
||||
using static HandyControl.Tools.Interop.InteropValues;
|
||||
using SafeBagDE70.API;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using DE70_CMDv2;
|
||||
using System.Configuration;
|
||||
|
||||
|
||||
namespace SafeBagDE70
|
||||
{ //Summary
|
||||
|
||||
|
||||
public partial class DepositUC : UserControl
|
||||
{
|
||||
SerialPort serialPortDE70 = new SerialPort();
|
||||
SerialPort serialPortSensor= new SerialPort();
|
||||
|
||||
List<CountSession> sessions = new List<CountSession>();
|
||||
ObservableCollection<LvCountItem> lvCountItems = new ObservableCollection<LvCountItem>();
|
||||
private DispatcherTimer timer;
|
||||
private DispatcherTimer sensorTimer;
|
||||
int countTimer = 0;
|
||||
CCmdRsp cCmdRsp = null;
|
||||
bool bInitialized = false;
|
||||
|
||||
public DepositUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitApp();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowError("LỖI CỔNG KẾT NỐI, VUI LÒNG KIỂM TRA LẠI CỔNG KẾT NỐI");
|
||||
}
|
||||
}
|
||||
public void InitApp()
|
||||
{
|
||||
// LoginUsingQRCode();
|
||||
|
||||
serialPortDE70.ReadBufferSize = 4096;
|
||||
serialPortDE70.WriteBufferSize = 4096;
|
||||
cCmdRsp = new CCmdRsp(serialPortDE70);
|
||||
AppData.cCmdRsp = cCmdRsp;
|
||||
|
||||
serialPortDE70.PortName = "COM4";
|
||||
serialPortDE70.BaudRate = 9600;
|
||||
serialPortDE70.Parity = Parity.Even;
|
||||
serialPortDE70.DataBits = 8;
|
||||
serialPortDE70.StopBits = StopBits.One;
|
||||
|
||||
serialPortSensor.PortName = "COM3";
|
||||
serialPortSensor.BaudRate = 9600;
|
||||
serialPortSensor.Parity = Parity.None;
|
||||
serialPortSensor.DataBits = 8;
|
||||
serialPortSensor.StopBits = StopBits.One;
|
||||
|
||||
//Subscrible to the DataReveied event
|
||||
if(!serialPortDE70.IsOpen)
|
||||
serialPortDE70.Open();
|
||||
|
||||
if (!serialPortSensor.IsOpen)
|
||||
serialPortSensor.Open();
|
||||
|
||||
bInitialized = InitSession();
|
||||
|
||||
timer = new DispatcherTimer();
|
||||
timer.Interval = new TimeSpan(0, 0, 10); //10 seconds
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
sensorTimer = new DispatcherTimer();
|
||||
sensorTimer.Interval = new TimeSpan(0, 0, 1); //10 seconds
|
||||
sensorTimer.Tick += SensorTimer_Tick;
|
||||
sensorTimer.Start();
|
||||
}
|
||||
|
||||
public void ShutdownApp()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (serialPortDE70.IsOpen)
|
||||
serialPortDE70.Close();
|
||||
if (serialPortSensor.IsOpen)
|
||||
serialPortSensor.Close();
|
||||
|
||||
if (timer != null)
|
||||
{
|
||||
timer.Tick -= Timer_Tick;
|
||||
timer.Stop();
|
||||
}
|
||||
if (sensorTimer != null)
|
||||
{
|
||||
sensorTimer.Tick -= SensorTimer_Tick;
|
||||
sensorTimer.Stop();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
public void SetStep(int step)
|
||||
{
|
||||
switch(step)
|
||||
{
|
||||
case 0:
|
||||
btnStart.IsEnabled = true;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = false;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 1:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled =false;
|
||||
break;
|
||||
case 2:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 3:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitSessionCount()
|
||||
{
|
||||
lvCountItems.Clear();
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "1000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "2000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "5000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "10000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "20000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "50000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "100000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "200000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "Tổng",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems[10].Quantity = "0";
|
||||
lvCountItems[10].Value = "0";
|
||||
|
||||
lvCount.ItemsSource = lvCountItems;
|
||||
|
||||
//lvCountItems[0].Quantity = "10";
|
||||
}
|
||||
public long maxQuantitySheet = 10000;
|
||||
public int quantityStored = 0;
|
||||
public int totalAllDenominations = 0;
|
||||
public int posDenomi;
|
||||
public bool printerFlag = false;
|
||||
public static string? recvDataString;
|
||||
public int[] TempQuantity = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
public int[] TempNote = new int[5] { 0, 0, 0, 0, 0 };
|
||||
public int[] Notes = new int[5] { 0, 0, 0, 0, 0 };
|
||||
|
||||
private void SensorTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
int state = 0;
|
||||
if (serialPortSensor.IsOpen==true)
|
||||
{
|
||||
serialPortSensor.Write(new byte[] { (byte)'S', 13, 10 }, 0, 3);
|
||||
var buffer = new byte[16];
|
||||
|
||||
int n = serialPortSensor.Read(buffer, 0, buffer.Length);
|
||||
|
||||
for (int i = 1; i < n - 1; i++)
|
||||
{
|
||||
if ((buffer[i] == 13) && (buffer[i + 1] == 10))
|
||||
{
|
||||
state = buffer[i - 1]-48;
|
||||
if(bInitialized)
|
||||
{
|
||||
if (state != 0)
|
||||
gridMain.IsEnabled = false;
|
||||
else
|
||||
gridMain.IsEnabled = true;
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
lblStatus.Content = "Két: đóng, Túi: đóng";
|
||||
break;
|
||||
case 1:
|
||||
lblStatus.Content = "Két: đóng, Túi: đã bị lấy ra";
|
||||
break;
|
||||
case 2:
|
||||
lblStatus.Content = "Két: mở, Túi: đóng";
|
||||
break;
|
||||
case 3:
|
||||
lblStatus.Content = "Két: mở, Túi: đã bị lấy ra";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
private void Timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
|
||||
APIModels.SendHealthCheck();
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
public int UpdateTotalQuantity()
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var item in lvCountItems)
|
||||
{
|
||||
if (item.Name != "Tổng")
|
||||
{
|
||||
int quantity = 0;
|
||||
if (int.TryParse(item.Quantity, out quantity))
|
||||
{
|
||||
total += quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int AutoSerialGet(SerialPort serialPort)
|
||||
{
|
||||
int ret;
|
||||
ushort seri_num = 0;
|
||||
ushort get_num = 0;
|
||||
bool endflg = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
ret = cCmdRsp.SendSerialSense();
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
ret = cCmdRsp.GetSerialNum(out seri_num);
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
// Serial number acquisition
|
||||
|
||||
if (cCmdRsp.ChkCntEnd())
|
||||
{
|
||||
endflg = true;
|
||||
Debug.WriteLine("END FLAG: "+cCmdRsp.recv_dat.dat[1]);
|
||||
}
|
||||
Debug.WriteLine("START");
|
||||
Debug.WriteLine($"Num Serial: {seri_num}");
|
||||
|
||||
while (get_num < seri_num)
|
||||
{
|
||||
get_num++;
|
||||
ret = cCmdRsp.SendGetSerial(get_num);
|
||||
|
||||
|
||||
switch (cCmdRsp.recv_dat.dat[18])
|
||||
{
|
||||
case 0x00: TempNote[0] ++; Notes[0] += TempNote[0]; break;
|
||||
case 0x02:
|
||||
//TempNote[1] ++;
|
||||
switch (cCmdRsp.recv_dat.dat[17])
|
||||
{
|
||||
case 0x00: TempQuantity[0]++; break;
|
||||
case 0x01: TempQuantity[1]++; break;
|
||||
case 0x02: TempQuantity[2]++; break;
|
||||
case 0x03: TempQuantity[3]++; break;
|
||||
case 0x04: TempQuantity[4]++; break;
|
||||
case 0x05: TempQuantity[5]++; break;
|
||||
case 0x06: TempQuantity[6]++; break;
|
||||
case 0x07: TempQuantity[7]++; break;
|
||||
case 0x08: TempQuantity[8]++; break;
|
||||
case 0x09: TempQuantity[9]++; break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 0x03: TempNote[2] ++; Notes[2] += TempNote[2]; break;
|
||||
case 0x0b: TempNote[3] ++; Notes[3] += TempNote[3]; break;
|
||||
case 0x0c: TempNote[4] ++; Notes[4] += TempNote[4]; break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("END");
|
||||
//Debug.WriteLine("Ellapsed Time: " + timeSpan.TotalSeconds);
|
||||
if (endflg)
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END GET SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END SEND SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void btnCountStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
printerFlag = false;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
try
|
||||
{
|
||||
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CNTSTART);
|
||||
//var recvData = DE70_CMD.SendxxCmd((byte)CMD_BYTE.CMD_DE_CNTSTART, serialPort);
|
||||
|
||||
//Thread.Sleep(20000);
|
||||
if (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[2] != 43) { }
|
||||
do
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_SENSE);
|
||||
}
|
||||
while (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[1] == 0x09); //SR2 = 0x09 : Counting Status
|
||||
|
||||
//SR3 = 0x43 : Stacker full
|
||||
|
||||
AutoSerialGet(serialPortDE70);
|
||||
|
||||
if (sessions == null || sessions.Count == 0)
|
||||
{
|
||||
double tempSum = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCountItems[i].Quantity = TempQuantity[9 - i].ToString();
|
||||
tempSum += lvCountItems[i].getValue();
|
||||
}
|
||||
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = tempSum.ToString();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
double sum = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
|
||||
}
|
||||
|
||||
a += TempQuantity[9 - i];
|
||||
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sum += lvCountItems[i].getValue();
|
||||
|
||||
}
|
||||
//Update amount of money
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sum.ToString();
|
||||
|
||||
}
|
||||
SetStep(2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheck_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
double sumStored;
|
||||
|
||||
//TempNote[1] = 0;
|
||||
|
||||
if (sessions != null)
|
||||
{
|
||||
sumStored = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
//quantityStored += lvCountItems[i].getQuantity();
|
||||
}
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sumStored += lvCountItems[i].getValue();
|
||||
}
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sumStored.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
private void btnStoreStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
printerFlag = true;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
sessions.Add(new CountSession());
|
||||
|
||||
sessions[sessions.Count - 1].QuantityDenomi = (int[])TempQuantity.Clone();
|
||||
quantityStored = UpdateTotalQuantity();
|
||||
|
||||
Debug.WriteLine(quantityStored);
|
||||
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||
SetStep(3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
InitSession();
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
|
||||
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
SetStep(1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
var totalQuantity = lvCountItems[10].Quantity;
|
||||
var totalValue = lvCountItems[11].Quantity;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
LogAction(currentMethod, null);
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
//SendData2Server
|
||||
var data2Send = new CountingData2Send
|
||||
{
|
||||
Sessions = sessions,
|
||||
MachineId = null,
|
||||
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
||||
MachineTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
RejectNotes = Notes[0],
|
||||
GenuineNotes = quantityStored,
|
||||
UnfitNotes = Notes[2],
|
||||
CounterfeitNotes = Notes[3],
|
||||
SuspendNotes = Notes[4]
|
||||
|
||||
};
|
||||
var str = JsonConvert.SerializeObject(data2Send);
|
||||
|
||||
APIModels.SendCountingData(data2Send);
|
||||
//Reset all and ready to next session
|
||||
|
||||
if(printerFlag == true)
|
||||
{
|
||||
PrintReceipt();
|
||||
printerFlag = false;
|
||||
|
||||
}
|
||||
InitSession();
|
||||
//Debug.WriteLine("Reject Note: " + Notes[0] );
|
||||
//Debug.WriteLine("Genuine note stored: " + quantityStored);
|
||||
//Debug.WriteLine("Unfit note: " + Notes[2]);
|
||||
//Debug.WriteLine("Counterfeit: " + Notes[3]);
|
||||
//Debug.WriteLine("Suspend: " + Notes[4]);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
String strNotify = $"BẠN VỪA THỰC HIỆN TIỀN VÀO MÁY CDM:\r\n"
|
||||
+ $"SỐ LƯỢNG TỜ: {totalQuantity}\r\n"
|
||||
+ $"SỐ TIỀN: {totalValue} VND\r\n";
|
||||
((MainWindow)Application.Current.MainWindow).ShowInformationScreen(strNotify);
|
||||
}
|
||||
private void ShowError(string strError)
|
||||
{
|
||||
//gridMain.IsEnabled = false;
|
||||
//btnCollect2.Visibility=Visibility.Collapsed;
|
||||
//panelError.Visibility = Visibility.Visible;
|
||||
//lblError.Text = strError;
|
||||
//((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
|
||||
((MainWindow)Application.Current.MainWindow).ShowErrorScreen(strError);
|
||||
}
|
||||
|
||||
private bool InitSession()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Check status
|
||||
cCmdRsp.SendDeSense();
|
||||
var data = cCmdRsp.recv_dat.dat;
|
||||
int IsCassetteFull=data[17] & 0x08;
|
||||
if(IsCassetteFull != 0)
|
||||
{
|
||||
((MainWindow)Application.Current.MainWindow).ShowCollectionScreen();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
sessions.Clear();
|
||||
Array.Clear(TempNote, 0, TempNote.Length);
|
||||
Array.Clear(Notes, 0, Notes.Length);
|
||||
quantityStored = 0;
|
||||
maxQuantitySheet = 0;
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
SetStep(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogException("InitSession", ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void PrintReceipt()
|
||||
{
|
||||
var shopName = AppData.CurrentCustomerAccount.Name;
|
||||
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
||||
var tradingCode = "TRA04052024CDM";
|
||||
var storeAccountNumber = 686868686688;
|
||||
var currentTime = DateTime.Now;
|
||||
var printDocument = new PrintDocument();
|
||||
printDocument.PrinterSettings.PrinterName = "CUSTOM K80";
|
||||
printDocument.PrintPage += (sender, e) =>
|
||||
{
|
||||
e.Graphics.DrawString("Biên nhận nộp tiền", new Font("Arial", 15), System.Drawing.Brushes.Black, new PointF(80, 10));
|
||||
e.Graphics.DrawString("Mã máy CDM: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 60));
|
||||
e.Graphics.DrawString("Batch no: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 90));
|
||||
e.Graphics.DrawString("Thời gian GD: " + currentTime.ToString("dd/MM/yyyy HH:mm:ss"), new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 120));
|
||||
e.Graphics.DrawString("Mã GD: " + tradingCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 150));
|
||||
e.Graphics.DrawString("Mã gian hàng: " + shopCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 180));
|
||||
e.Graphics.DrawString("Tên gian hàng: " + shopName, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 210));
|
||||
e.Graphics.DrawString("STK gian hàng: " + storeAccountNumber, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 240));
|
||||
e.Graphics.DrawString("Số tiền nộp: " + lvCountItems[10].Value, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 270));
|
||||
e.Graphics.DrawString("*****Xin cám ơn******", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(100, 300));
|
||||
// To send raw ESC/POS commands, you'd typically use e.Graphics.DrawString() with the command string,
|
||||
// or for more complex scenarios, directly manipulate the byte stream sent to the printer.
|
||||
};
|
||||
printDocument.Print();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void LogAction(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("log.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
public void LogException(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("logException.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
private void LoginUsingQRCode()
|
||||
{
|
||||
|
||||
}
|
||||
private void btnCollect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
//Event fix
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
|
||||
var currentMode = cCmdRsp.GetLockParam().mode;
|
||||
cCmdRsp.GetLockParam().mode = Mode.MODE_COLLECTION;
|
||||
cCmdRsp.SendLock();
|
||||
Thread.Sleep(10000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] != recvData.dat[16])
|
||||
{
|
||||
ShowError("Khởi tạo bộ đếm thành công");
|
||||
// ShutdownApp();
|
||||
// InitApp();
|
||||
}
|
||||
//Thread.Sleep(5000);
|
||||
//cCmdRsp.GetLockParam().mode = currentMode;
|
||||
//cCmdRsp.SendLock();
|
||||
}
|
||||
|
||||
private void UserControl_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShutdownApp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<hc:Window
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
x:Class="SafeBagDE70.QRCodeWindow"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ShowNonClientArea="False"
|
||||
mc:Ignorable="d"
|
||||
Title="QRCodeWindow" Height="400" Width="600">
|
||||
<Grid>
|
||||
<StackPanel VerticalAlignment="Center">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Đưa QR Code của bạn vào đầu đọc" FontSize="30"/>
|
||||
<hc:LoadingCircle VerticalAlignment="Bottom" Width="50" Height="50" Margin="10"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
</hc:Window>
|
||||
@@ -0,0 +1,344 @@
|
||||
using CoreScanner;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Automation;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeWindow.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeUC : UserControl
|
||||
{
|
||||
public string? PinCode = null;
|
||||
public bool IsAuthenticated = false;
|
||||
public CCoreScannerClass? cCoreScannerClass=null;
|
||||
public WelcomeUC()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitQRCodeScanner();
|
||||
Loaded += WelcomeUC_Loaded;
|
||||
}
|
||||
|
||||
private void WelcomeUC_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AppData.IsAuthenticated = false;
|
||||
txtVersion.Text = "Version " + AppData.CurrentVersion;
|
||||
}
|
||||
public void Init()
|
||||
{
|
||||
AppData.IsAuthenticated = false;
|
||||
AppData.CurrentCustomerAccount = null;
|
||||
lblPincodeError.Content = "";
|
||||
PinCodeBox.Text = "";
|
||||
}
|
||||
|
||||
private void LoginButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
string pin = PinCodeBox.Text;
|
||||
|
||||
if (ValidatePin(pin))
|
||||
{
|
||||
PinCode=PinCodeBox.Text.ToString();
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (PinCode != null)
|
||||
{
|
||||
var strPincode = PinCode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
AppData.IsAuthenticated=true;
|
||||
AppData.CurrentCustomerAccount=cca;
|
||||
AppData.GetNewTransactionCode();
|
||||
AppData.GetNewTransactionCode();
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
//DialogResult = true;
|
||||
//this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblPincodeError.Content = "PINCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Invalid PIN. Please try again.");
|
||||
}
|
||||
}
|
||||
|
||||
private void ForgotPin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Forgot PIN clicked.");
|
||||
}
|
||||
|
||||
private void Help_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MessageBox.Show("Phiên bản đang sử dụng là phiên bản mới nhất");
|
||||
}
|
||||
|
||||
private bool ValidatePin(string pin)
|
||||
{
|
||||
return true;
|
||||
|
||||
}
|
||||
private async void PinCodeButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//var onScreenKeyboardProcess = new ProcessStartInfo("osk.exe")
|
||||
//{
|
||||
// UseShellExecute = true
|
||||
//};
|
||||
try
|
||||
{
|
||||
//var progFiles = @"C:\Program Files\Common Files\Microsoft Shared\ink";
|
||||
//var keyboardPath = System.IO.Path.Combine(progFiles, "TabTip.exe");
|
||||
//Process.Start(keyboardPath);
|
||||
// AutomationElement.FromHandle(-1);
|
||||
|
||||
// string keyboardPath = @"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe";
|
||||
// Process.Start(keyboardPath);
|
||||
//await Launcher.LaunchUriAsync(new Uri("ms-inputapp://"));
|
||||
|
||||
//var onScreenKeyboardProcess = new ProcessStartInfo(@"C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe")
|
||||
//{
|
||||
// UseShellExecute = true
|
||||
//};
|
||||
//Process.Start(onScreenKeyboardProcess);
|
||||
|
||||
QrCodePanel.Visibility = Visibility.Collapsed;
|
||||
PinCodePanel.Visibility = Visibility.Visible;
|
||||
|
||||
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
}
|
||||
catch {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void btnQRCodeLogin_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PinCodePanel.Visibility = Visibility.Collapsed;
|
||||
QrCodePanel.Visibility=Visibility.Visible;
|
||||
cCoreScannerClass.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
|
||||
|
||||
}
|
||||
public void InitQRCodeScanner()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Instantiate CoreScanner Class
|
||||
cCoreScannerClass = new CCoreScannerClass();
|
||||
|
||||
// Call Open API
|
||||
short[] scannerTypes = new short[1]; // Scanner Types you are interested in
|
||||
scannerTypes[0] = 1; // 1 for all scanner types
|
||||
short numberOfScannerTypes = 1; // Size of the scannerTypes array
|
||||
int status; // Extended API return code
|
||||
|
||||
cCoreScannerClass.Open(0, scannerTypes, numberOfScannerTypes, out status);
|
||||
|
||||
// Subscribe for barcode events in cCoreScannerClass
|
||||
|
||||
|
||||
// Let's subscribe for events
|
||||
int opcode = 1001; // Method for Subscribe events
|
||||
string outXML; // XML Output
|
||||
string inXML = "<inArgs>" +
|
||||
"<cmdArgs>" +
|
||||
"<arg-int>1</arg-int>" + // Number of events you want to subscribe
|
||||
"<arg-int>1</arg-int>" + // Comma separated event IDs
|
||||
"</cmdArgs>" +
|
||||
"</inArgs>";
|
||||
|
||||
cCoreScannerClass.ExecCommand(opcode, ref inXML, out outXML, out status);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
Console.WriteLine("Something wrong please check... " + exp.Message);
|
||||
}
|
||||
}
|
||||
private void OnBarcodeEvent(short eventType, ref string pscanData)
|
||||
{
|
||||
string xmlString = pscanData;
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(xmlString);
|
||||
|
||||
XmlNode rawDataNode = xmlDoc.SelectSingleNode("//datalabel");
|
||||
string rawDataHex = rawDataNode.InnerText.Trim();
|
||||
|
||||
var QRCodeContentFull = HexStringToString(rawDataHex);
|
||||
string? CustomerID = null;
|
||||
VerifyQRCode(QRCodeContentFull, out CustomerID);
|
||||
if(CustomerID!=null)
|
||||
{
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (AppData.customerAccounts != null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if (CustomerID != null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == CustomerID).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
cCoreScannerClass.BarcodeEvent -= new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
|
||||
AppData.IsAuthenticated = true;
|
||||
AppData.CurrentCustomerAccount = cca;
|
||||
AppData.GetNewTransactionCode();
|
||||
((MainWindow)Application.Current.MainWindow).ShowDepositScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
lblQRcodeError.Content = "QRCODE không đúng, vui lòng thử lại";
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
private void VerifyQRCode(string decodedString,out string? ConsumerID)
|
||||
{
|
||||
ConsumerID = null;
|
||||
try
|
||||
{
|
||||
var qrCodeData = decodedString;
|
||||
// Extract the CRC from the QR code string
|
||||
string extractedCRC = qrCodeData.Substring(qrCodeData.Length - 4);
|
||||
// Get the data without the CRC part
|
||||
string dataWithoutCRC = qrCodeData.Substring(0, qrCodeData.Length - 8);
|
||||
|
||||
// Calculate CRC
|
||||
string calculatedCRC = CalculateCRC(dataWithoutCRC);
|
||||
|
||||
// Verify CRC
|
||||
if (extractedCRC.Equals(calculatedCRC, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
lblQRcodeError.Content = "CRC is valid.";
|
||||
});
|
||||
|
||||
Dictionary<string, (int Length, string Value)> fields = ExtractFields(qrCodeData);
|
||||
|
||||
foreach (var field in fields)
|
||||
{
|
||||
Console.WriteLine($"ID: {field.Key}, Length: {field.Value.Length}, Value: {field.Value.Value}");
|
||||
}
|
||||
var fields2 = ExtractFields(fields["38"].Value);
|
||||
var fields3 = ExtractFields(fields2["01"].Value);
|
||||
ConsumerID = fields3["01"].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
lblQRcodeError.Content = "CRC is invalid.";
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.Dispatcher.Invoke(() =>
|
||||
{
|
||||
lblQRcodeError.Content = e.Message;
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
Dictionary<string, (int Length, string Value)> ExtractFields(string qrCodeData)
|
||||
{
|
||||
Dictionary<string, (int Length, string Value)> fields = new Dictionary<string, (int Length, string Value)>();
|
||||
|
||||
int currentIndex = 0;
|
||||
|
||||
while (currentIndex < qrCodeData.Length)
|
||||
{
|
||||
// Extract ID
|
||||
string id = qrCodeData.Substring(currentIndex, 2);
|
||||
currentIndex += 2;
|
||||
|
||||
// Extract Length
|
||||
int length = int.Parse(qrCodeData.Substring(currentIndex, 2));
|
||||
currentIndex += 2;
|
||||
|
||||
// Extract Value
|
||||
string value = qrCodeData.Substring(currentIndex, length);
|
||||
currentIndex += length;
|
||||
|
||||
// Add the field to the dictionary
|
||||
fields[id] = (length, value);
|
||||
}
|
||||
|
||||
return fields;
|
||||
}
|
||||
string CalculateCRC(string data)
|
||||
{
|
||||
ushort polynomial = 0x1021; // CRC-16-CCITT polynomial
|
||||
ushort crc = 0xFFFF; // Initial value
|
||||
|
||||
// Convert the string to a byte array
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(data + "6304"); // Append "6304" for CRC calculation as per standard
|
||||
|
||||
foreach (byte b in bytes)
|
||||
{
|
||||
crc ^= (ushort)(b << 8);
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if ((crc & 0x8000) != 0)
|
||||
{
|
||||
crc = (ushort)((crc << 1) ^ polynomial);
|
||||
}
|
||||
else
|
||||
{
|
||||
crc <<= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure CRC is a 16-bit value
|
||||
crc &= 0xFFFF;
|
||||
|
||||
// Return CRC as a hexadecimal string
|
||||
return crc.ToString("X4");
|
||||
}
|
||||
static string HexStringToString(string hexString)
|
||||
{
|
||||
string[] hexValues = hexString.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] bytes = new byte[hexValues.Length];
|
||||
|
||||
for (int i = 0; i < hexValues.Length; i++)
|
||||
{
|
||||
bytes[i] = Convert.ToByte(hexValues[i], 16);
|
||||
}
|
||||
return Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,135 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using VirtualKeyboard.Wpf.Types;
|
||||
|
||||
namespace VirtualKeyboard.Wpf.ViewModels
|
||||
{
|
||||
class VirtualKeyboardViewModel : INotifyPropertyChanged
|
||||
{
|
||||
private string _keyboardText;
|
||||
public string KeyboardText {
|
||||
get => _keyboardText;
|
||||
set
|
||||
{
|
||||
_keyboardText = value;
|
||||
NotifyPropertyChanged(nameof(KeyboardText));
|
||||
}
|
||||
}
|
||||
private KeyboardType _keyboardType;
|
||||
public KeyboardType KeyboardType {
|
||||
get => _keyboardType;
|
||||
private set
|
||||
{
|
||||
_keyboardType = value;
|
||||
NotifyPropertyChanged(nameof(KeyboardType));
|
||||
}
|
||||
}
|
||||
private bool _uppercase;
|
||||
public bool Uppercase
|
||||
{
|
||||
get => _uppercase;
|
||||
private set
|
||||
{
|
||||
_uppercase = value;
|
||||
NotifyPropertyChanged(nameof(Uppercase));
|
||||
}
|
||||
}
|
||||
private int _caretPosition;
|
||||
public int CaretPosition
|
||||
{
|
||||
get => _caretPosition;
|
||||
set
|
||||
{
|
||||
if (value < 0) _caretPosition = 0;
|
||||
else if (value > KeyboardText.Length) _caretPosition = KeyboardText.Length;
|
||||
else _caretPosition = value;
|
||||
NotifyPropertyChanged(nameof(CaretPosition));
|
||||
}
|
||||
}
|
||||
private string _selectedValue;
|
||||
public string SelectedValue
|
||||
{
|
||||
get => _selectedValue;
|
||||
set
|
||||
{
|
||||
_selectedValue = value;
|
||||
NotifyPropertyChanged(nameof(SelectedValue));
|
||||
}
|
||||
}
|
||||
public Command AddCharacter { get; }
|
||||
public Command ChangeCasing { get; }
|
||||
public Command RemoveCharacter { get; }
|
||||
public Command ChangeKeyboardType { get; }
|
||||
public Command Accept { get; }
|
||||
|
||||
public VirtualKeyboardViewModel(string initialValue)
|
||||
{
|
||||
_keyboardText = initialValue;
|
||||
_keyboardType = KeyboardType.Alphabet;
|
||||
_uppercase = false;
|
||||
CaretPosition = _keyboardText.Length;
|
||||
|
||||
AddCharacter = new Command(a =>
|
||||
{
|
||||
if (a is string character)
|
||||
if (character.Length == 1)
|
||||
{
|
||||
if (Uppercase) character = character.ToUpper();
|
||||
if (!string.IsNullOrEmpty(SelectedValue))
|
||||
{
|
||||
RemoveSubstring(SelectedValue);
|
||||
KeyboardText = KeyboardText.Insert(CaretPosition, character);
|
||||
CaretPosition++;
|
||||
SelectedValue = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
KeyboardText = KeyboardText.Insert(CaretPosition, character);
|
||||
CaretPosition++;
|
||||
}
|
||||
}
|
||||
});
|
||||
ChangeCasing = new Command(a => Uppercase = !Uppercase);
|
||||
RemoveCharacter = new Command(a =>
|
||||
{
|
||||
if(!string.IsNullOrEmpty(SelectedValue))
|
||||
{
|
||||
RemoveSubstring(SelectedValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
var position = CaretPosition - 1;
|
||||
if (position >= 0)
|
||||
{
|
||||
KeyboardText = KeyboardText.Remove(position, 1);
|
||||
if (position < KeyboardText.Length) CaretPosition--;
|
||||
else CaretPosition = KeyboardText.Length;
|
||||
}
|
||||
}
|
||||
});
|
||||
ChangeKeyboardType = new Command(a =>
|
||||
{
|
||||
if (KeyboardType == KeyboardType.Alphabet) KeyboardType = KeyboardType.Special;
|
||||
else KeyboardType = KeyboardType.Alphabet;
|
||||
});
|
||||
Accept = new Command(a => VKeyboard.Close());
|
||||
}
|
||||
|
||||
private void RemoveSubstring(string substring)
|
||||
{
|
||||
var position = KeyboardText.IndexOf(substring);
|
||||
KeyboardText = KeyboardText.Remove(position, substring.Length);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
private void NotifyPropertyChanged(string prop)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(prop));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<hc:Window x:Class="SafeBagDE70.WelcomeWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:SafeBagDE70"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
ShowInTaskbar="False"
|
||||
ShowNonClientArea="False"
|
||||
IsFullScreen="True"
|
||||
Topmost="True"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Title="WelcomeWindow" Height="600" Width="800">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="4*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Top Section -->
|
||||
<StackPanel Grid.Row="0" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,0,0,0">
|
||||
<Image Source="icon/logo.ico" Width="200" Height="200" Margin="0,10,0,10" Stretch="UniformToFill"/>
|
||||
<TextBlock Text="Xin chào! Hãy lựa chọn hình thức đăng nhập để tiếp tục" FontSize="24" FontWeight="Bold" TextAlignment="Center"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Middle Section -->
|
||||
<Grid Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Button hc:IconElement.Geometry="{StaticResource FullScreenGeometry}" Grid.Column="0" Grid.Row="0" x:Name="btnQRCodeLogin" Content="QR CODE" Width="200" Height="100" Margin="0,0,10,0" FontSize="20" FontWeight="Bold" Click="btnQRCodeLogin_Click"/>
|
||||
<Button Grid.Column="2" Grid.Row="0" x:Name="btnPinCodeLogin" Content="PIN CODE" Width="200" Height="100" Margin="10,0,0,0" Click="PinCodeButton_Click" FontSize="20" FontWeight="Bold"/>
|
||||
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="PinCodePanel">
|
||||
<PasswordBox x:Name="PinCodeBox" Width="300" Height="60" FontSize="20" HorizontalContentAlignment="Center" Margin="0,10,0,0"/>
|
||||
<TextBlock Text="Quên mã PIN?" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" Margin="0,5,0,0" MouseLeftButtonUp="ForgotPin_Click"/>
|
||||
<Button Content="Đăng nhập" Width="200" Height="40" Margin="0,10,0,0" Click="LoginButton_Click"/>
|
||||
<Label x:Name="lblPincodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.ColumnSpan="3" Grid.Row="1" HorizontalAlignment="Center" Visibility="Collapsed" x:Name="QrCodePanel">
|
||||
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="Đưa QR Code của bạn vào đầu đọc" FontSize="20"/>
|
||||
<hc:LoadingCircle Background="Transparent" VerticalAlignment="Bottom" Width="50" Height="50" Margin="10"/>
|
||||
<Label x:Name="lblQRcodeError" Background="Transparent" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="Red" />
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
<!-- Bottom Section -->
|
||||
<StackPanel Grid.Row="2" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<TextBlock Text="TRỢ GIÚP" Foreground="Blue" TextDecorations="Underline" Cursor="Hand" MouseLeftButtonUp="Help_Click"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
</hc:Window>
|
||||
@@ -0,0 +1,104 @@
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using System.Windows.Documents;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SafeBagDE70.API
|
||||
{
|
||||
public static class APIModels
|
||||
{
|
||||
public static string URL = "https://203.171.20.94:9090/Safebag/";
|
||||
public static async void SendHealthCheck(string? ID=null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ID == null) ID = GetMACAddress();
|
||||
HttpClientHandler clientHandler = new HttpClientHandler();
|
||||
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
|
||||
|
||||
// Pass the handler to httpclient(from you are calling api)
|
||||
HttpClient httpClient = new HttpClient(clientHandler);
|
||||
using HttpResponseMessage response = await httpClient.GetAsync(URL + "HealthCheck?Id=" + ID);
|
||||
|
||||
if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static async Task<bool> SendCountingData(CountingData2Send data2Send)
|
||||
{
|
||||
bool bSuccess=false;
|
||||
try{
|
||||
HttpClientHandler clientHandler = new HttpClientHandler();
|
||||
clientHandler.ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => { return true; };
|
||||
|
||||
// Pass the handler to httpclient(from you are calling api)
|
||||
HttpClient httpClient = new HttpClient(clientHandler);
|
||||
string strJsonObj = JsonConvert.SerializeObject(data2Send);
|
||||
var content = new StringContent(strJsonObj, Encoding.UTF8, "application/json");
|
||||
|
||||
using HttpResponseMessage response = await httpClient.PostAsync(URL + "UpdateCountingData", content);
|
||||
|
||||
if (response.EnsureSuccessStatusCode().StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
var jsonResponse = await response.Content.ReadAsStringAsync();
|
||||
bSuccess = true;
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
return bSuccess;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static string GetMACAddress()
|
||||
{
|
||||
string? MACAdress = null;
|
||||
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
|
||||
{
|
||||
if (nic.OperationalStatus == OperationalStatus.Up)
|
||||
{
|
||||
MACAdress = AddressBytesToString(nic.GetPhysicalAddress().GetAddressBytes());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (MACAdress == null) MACAdress = "N/A";
|
||||
return MACAdress;
|
||||
}
|
||||
|
||||
private static string? AddressBytesToString(byte[] addressBytes)
|
||||
{
|
||||
if (addressBytes != null)
|
||||
{
|
||||
var str = string.Join(":", (from b in addressBytes
|
||||
select b.ToString("X2")).ToArray());
|
||||
return str;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,821 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Xml.Serialization;
|
||||
using System.Windows.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
using SafeBagDE70.Model;
|
||||
using HandyControl.Tools;
|
||||
using System.Drawing.Printing;
|
||||
using System.Drawing;
|
||||
using static HandyControl.Tools.Interop.InteropValues;
|
||||
using SafeBagDE70.API;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using DE70_CMDv2;
|
||||
using System.Configuration;
|
||||
|
||||
|
||||
namespace SafeBagDE70
|
||||
{ //Summary
|
||||
public class CountSession
|
||||
{
|
||||
public int[] QuantityDenomi { get; set; }
|
||||
public int[] SumDenomi { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class CountingData2Send
|
||||
{
|
||||
public List<CountSession>? Sessions { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
public string? MachineId { get; set; }
|
||||
public string? MachineTime { get; set; }
|
||||
public int RejectNotes { get; set; }
|
||||
public int GenuineNotes { get; set; }
|
||||
public int UnfitNotes { get; set; }
|
||||
public int CounterfeitNotes { get; set; }
|
||||
public int SuspendNotes { get; set; }
|
||||
}
|
||||
|
||||
public partial class MainUserWindow : HandyControl.Controls.Window
|
||||
{
|
||||
SerialPort serialPortDE70 = new SerialPort();
|
||||
SerialPort serialPortSensor= new SerialPort();
|
||||
|
||||
List<CountSession> sessions = new List<CountSession>();
|
||||
ObservableCollection<LvCountItem> lvCountItems = new ObservableCollection<LvCountItem>();
|
||||
private DispatcherTimer timer;
|
||||
private DispatcherTimer sensorTimer;
|
||||
int countTimer = 0;
|
||||
CCmdRsp cCmdRsp = null;
|
||||
bool bInitialized = false;
|
||||
|
||||
public MainUserWindow()
|
||||
{
|
||||
//Need to update: auto detect COM Port
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
//string queuePath = ConfigurationManager.AppSettings["SensorPort"].ToString();
|
||||
AppData.Init();
|
||||
//this.gridMain.IsEnabled = false;
|
||||
|
||||
|
||||
InitApp();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowError("LỖI CỔNG KẾT NỐI, VUI LÒNG KIỂM TRA LẠI CỔNG KẾT NỐI");
|
||||
//MessageBox.Show("Cổng đang mở, kiểm tra lại cổng kết nối");
|
||||
//this.Close();
|
||||
}
|
||||
}
|
||||
public void InitApp()
|
||||
{
|
||||
LoginUsingQRCode();
|
||||
panelError.Visibility = Visibility.Collapsed;
|
||||
|
||||
serialPortDE70.ReadBufferSize = 4096;
|
||||
serialPortDE70.WriteBufferSize = 4096;
|
||||
cCmdRsp = new CCmdRsp(serialPortDE70);
|
||||
|
||||
serialPortDE70.PortName = "COM4";
|
||||
serialPortDE70.BaudRate = 9600;
|
||||
serialPortDE70.Parity = Parity.Even;
|
||||
serialPortDE70.DataBits = 8;
|
||||
serialPortDE70.StopBits = StopBits.One;
|
||||
|
||||
serialPortSensor.PortName = "COM3";
|
||||
serialPortSensor.BaudRate = 9600;
|
||||
serialPortSensor.Parity = Parity.None;
|
||||
serialPortSensor.DataBits = 8;
|
||||
serialPortSensor.StopBits = StopBits.One;
|
||||
|
||||
//Subscrible to the DataReveied event
|
||||
|
||||
serialPortDE70.Open();
|
||||
serialPortSensor.Open();
|
||||
|
||||
bInitialized = InitSession();
|
||||
|
||||
timer = new DispatcherTimer();
|
||||
timer.Interval = new TimeSpan(0, 0, 10); //10 seconds
|
||||
timer.Tick += Timer_Tick;
|
||||
timer.Start();
|
||||
|
||||
sensorTimer = new DispatcherTimer();
|
||||
sensorTimer.Interval = new TimeSpan(0, 0, 1); //10 seconds
|
||||
sensorTimer.Tick += SensorTimer_Tick;
|
||||
sensorTimer.Start();
|
||||
}
|
||||
|
||||
public void ShutdownApp()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (serialPortDE70.IsOpen)
|
||||
serialPortDE70.Close();
|
||||
if (serialPortSensor.IsOpen)
|
||||
serialPortSensor.Close();
|
||||
|
||||
if (timer != null)
|
||||
{
|
||||
timer.Tick -= Timer_Tick;
|
||||
timer.Stop();
|
||||
}
|
||||
if (sensorTimer != null)
|
||||
{
|
||||
sensorTimer.Tick -= SensorTimer_Tick;
|
||||
sensorTimer.Stop();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
public void SetStep(int step)
|
||||
{
|
||||
switch(step)
|
||||
{
|
||||
case 0:
|
||||
btnStart.IsEnabled = true;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = false;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 1:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = false;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = false;
|
||||
btnEnd.IsEnabled =false;
|
||||
break;
|
||||
case 2:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = false;
|
||||
break;
|
||||
case 3:
|
||||
btnStart.IsEnabled = false;
|
||||
btnCheck.IsEnabled = true;
|
||||
btnCountStart.IsEnabled = true;
|
||||
btnStoreStart.IsEnabled = true;
|
||||
btnEnd.IsEnabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void InitSessionCount()
|
||||
{
|
||||
lvCountItems.Clear();
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "1000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "2000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "5000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "10000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "20000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "50000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "100000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "200000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "500000",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems.Add(new LvCountItem
|
||||
{
|
||||
Name = "Tổng",
|
||||
Quantity = "0"
|
||||
});
|
||||
lvCountItems[10].Quantity = "0";
|
||||
lvCountItems[10].Value = "0";
|
||||
|
||||
lvCount.ItemsSource = lvCountItems;
|
||||
|
||||
//lvCountItems[0].Quantity = "10";
|
||||
}
|
||||
public long maxQuantitySheet = 10000;
|
||||
public int quantityStored = 0;
|
||||
public int totalAllDenominations = 0;
|
||||
public int posDenomi;
|
||||
public bool printerFlag = false;
|
||||
public static string? recvDataString;
|
||||
public int[] TempQuantity = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
public int[] TempNote = new int[5] { 0, 0, 0, 0, 0 };
|
||||
public int[] Notes = new int[5] { 0, 0, 0, 0, 0 };
|
||||
|
||||
private void SensorTimer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
int state = 0;
|
||||
if (serialPortSensor.IsOpen==true)
|
||||
{
|
||||
serialPortSensor.Write(new byte[] { (byte)'S', 13, 10 }, 0, 3);
|
||||
var buffer = new byte[16];
|
||||
|
||||
int n = serialPortSensor.Read(buffer, 0, buffer.Length);
|
||||
|
||||
for (int i = 1; i < n - 1; i++)
|
||||
{
|
||||
if ((buffer[i] == 13) && (buffer[i + 1] == 10))
|
||||
{
|
||||
state = buffer[i - 1]-48;
|
||||
if(bInitialized)
|
||||
{
|
||||
if (state != 0)
|
||||
gridMain.IsEnabled = false;
|
||||
else
|
||||
gridMain.IsEnabled = true;
|
||||
}
|
||||
switch (state)
|
||||
{
|
||||
case 0:
|
||||
lblStatus.Content = "Két: đóng, Túi: đóng";
|
||||
break;
|
||||
case 1:
|
||||
lblStatus.Content = "Két: đóng, Túi: đã bị lấy ra";
|
||||
break;
|
||||
case 2:
|
||||
lblStatus.Content = "Két: mở, Túi: đóng";
|
||||
break;
|
||||
case 3:
|
||||
lblStatus.Content = "Két: mở, Túi: đã bị lấy ra";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
private void Timer_Tick(object? sender, EventArgs e)
|
||||
{
|
||||
timer.IsEnabled = false;
|
||||
|
||||
APIModels.SendHealthCheck();
|
||||
|
||||
timer.IsEnabled = true;
|
||||
}
|
||||
public int UpdateTotalQuantity()
|
||||
{
|
||||
int total = 0;
|
||||
foreach (var item in lvCountItems)
|
||||
{
|
||||
if (item.Name != "Tổng")
|
||||
{
|
||||
int quantity = 0;
|
||||
if (int.TryParse(item.Quantity, out quantity))
|
||||
{
|
||||
total += quantity;
|
||||
}
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public int AutoSerialGet(SerialPort serialPort)
|
||||
{
|
||||
int ret;
|
||||
ushort seri_num = 0;
|
||||
ushort get_num = 0;
|
||||
bool endflg = false;
|
||||
|
||||
while (true)
|
||||
{
|
||||
ret = cCmdRsp.SendSerialSense();
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
ret = cCmdRsp.GetSerialNum(out seri_num);
|
||||
if (ret == Constants.E_OK)
|
||||
{
|
||||
// Serial number acquisition
|
||||
|
||||
if (cCmdRsp.ChkCntEnd())
|
||||
{
|
||||
endflg = true;
|
||||
Debug.WriteLine("END FLAG: "+cCmdRsp.recv_dat.dat[1]);
|
||||
}
|
||||
Debug.WriteLine("START");
|
||||
Debug.WriteLine($"Num Serial: {seri_num}");
|
||||
|
||||
while (get_num < seri_num)
|
||||
{
|
||||
get_num++;
|
||||
ret = cCmdRsp.SendGetSerial(get_num);
|
||||
|
||||
|
||||
switch (cCmdRsp.recv_dat.dat[18])
|
||||
{
|
||||
case 0x00: TempNote[0] ++; Notes[0] += TempNote[0]; break;
|
||||
case 0x02:
|
||||
//TempNote[1] ++;
|
||||
switch (cCmdRsp.recv_dat.dat[17])
|
||||
{
|
||||
case 0x00: TempQuantity[0]++; break;
|
||||
case 0x01: TempQuantity[1]++; break;
|
||||
case 0x02: TempQuantity[2]++; break;
|
||||
case 0x03: TempQuantity[3]++; break;
|
||||
case 0x04: TempQuantity[4]++; break;
|
||||
case 0x05: TempQuantity[5]++; break;
|
||||
case 0x06: TempQuantity[6]++; break;
|
||||
case 0x07: TempQuantity[7]++; break;
|
||||
case 0x08: TempQuantity[8]++; break;
|
||||
case 0x09: TempQuantity[9]++; break;
|
||||
|
||||
}
|
||||
break;
|
||||
case 0x03: TempNote[2] ++; Notes[2] += TempNote[2]; break;
|
||||
case 0x0b: TempNote[3] ++; Notes[3] += TempNote[3]; break;
|
||||
case 0x0c: TempNote[4] ++; Notes[4] += TempNote[4]; break;
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("END");
|
||||
//Debug.WriteLine("Ellapsed Time: " + timeSpan.TotalSeconds);
|
||||
if (endflg)
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END GET SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine("END SEND SERIAL: "+ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void btnCountStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
printerFlag = false;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
try
|
||||
{
|
||||
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CNTSTART);
|
||||
//var recvData = DE70_CMD.SendxxCmd((byte)CMD_BYTE.CMD_DE_CNTSTART, serialPort);
|
||||
|
||||
//Thread.Sleep(20000);
|
||||
if (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[2] != 43) { }
|
||||
do
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_SENSE);
|
||||
}
|
||||
while (cCmdRsp.recv_dat != null && cCmdRsp.recv_dat.dat[1] == 0x09); //SR2 = 0x09 : Counting Status
|
||||
|
||||
//SR3 = 0x43 : Stacker full
|
||||
|
||||
AutoSerialGet(serialPortDE70);
|
||||
|
||||
if (sessions == null || sessions.Count == 0)
|
||||
{
|
||||
double tempSum = 0;
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
lvCountItems[i].Quantity = TempQuantity[9 - i].ToString();
|
||||
tempSum += lvCountItems[i].getValue();
|
||||
}
|
||||
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = tempSum.ToString();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
double sum = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
|
||||
}
|
||||
|
||||
a += TempQuantity[9 - i];
|
||||
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sum += lvCountItems[i].getValue();
|
||||
|
||||
}
|
||||
//Update amount of money
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sum.ToString();
|
||||
|
||||
}
|
||||
SetStep(2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCheck_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_CANCEL);
|
||||
|
||||
double sumStored;
|
||||
|
||||
//TempNote[1] = 0;
|
||||
|
||||
if (sessions != null)
|
||||
{
|
||||
sumStored = 0;
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
int a = 0;
|
||||
for (int j = 0; j < sessions.Count; j++)
|
||||
{
|
||||
|
||||
a += sessions[j].QuantityDenomi[9 - i];
|
||||
//quantityStored += lvCountItems[i].getQuantity();
|
||||
}
|
||||
lvCountItems[i].Quantity = a.ToString();
|
||||
sumStored += lvCountItems[i].getValue();
|
||||
}
|
||||
lvCountItems[10].Quantity = UpdateTotalQuantity().ToString();
|
||||
lvCountItems[10].Value = sumStored.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
private void btnStoreStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
printerFlag = true;
|
||||
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
LogAction(currentMethod, null);
|
||||
sessions.Add(new CountSession());
|
||||
|
||||
sessions[sessions.Count - 1].QuantityDenomi = (int[])TempQuantity.Clone();
|
||||
quantityStored = UpdateTotalQuantity();
|
||||
|
||||
Debug.WriteLine(quantityStored);
|
||||
|
||||
Array.Clear(TempQuantity, 0, TempQuantity.Length);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_STORESTART);
|
||||
SetStep(3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
InitSession();
|
||||
try
|
||||
{
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
LogAction(currentMethod, null);
|
||||
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_SENSE);
|
||||
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
SetStep(1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void btnEnd_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string currentMethod = MethodBase.GetCurrentMethod().Name;
|
||||
|
||||
try
|
||||
{
|
||||
LogAction(currentMethod, null);
|
||||
serialPortDE70.DiscardInBuffer();
|
||||
serialPortDE70.DiscardOutBuffer();
|
||||
|
||||
//SendData2Server
|
||||
var data2Send = new CountingData2Send
|
||||
{
|
||||
Sessions = sessions,
|
||||
MachineId = null,
|
||||
UserId = AppData.CurrentCustomerAccount.CustomerId,
|
||||
MachineTime = DateTime.Now.ToString("yyyyMMddHHmmss"),
|
||||
RejectNotes = Notes[0],
|
||||
GenuineNotes = quantityStored,
|
||||
UnfitNotes = Notes[2],
|
||||
CounterfeitNotes = Notes[3],
|
||||
SuspendNotes = Notes[4]
|
||||
|
||||
};
|
||||
var str = JsonConvert.SerializeObject(data2Send);
|
||||
|
||||
APIModels.SendCountingData(data2Send);
|
||||
//Reset all and ready to next session
|
||||
|
||||
if(printerFlag == true)
|
||||
{
|
||||
PrintReceipt();
|
||||
printerFlag = false;
|
||||
|
||||
}
|
||||
InitSession();
|
||||
//Debug.WriteLine("Reject Note: " + Notes[0] );
|
||||
//Debug.WriteLine("Genuine note stored: " + quantityStored);
|
||||
//Debug.WriteLine("Unfit note: " + Notes[2]);
|
||||
//Debug.WriteLine("Counterfeit: " + Notes[3]);
|
||||
//Debug.WriteLine("Suspend: " + Notes[4]);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogException(currentMethod, ex.ToString());
|
||||
}
|
||||
LoginUsingQRCode();
|
||||
|
||||
}
|
||||
private void ShowError(string strError)
|
||||
{
|
||||
gridMain.IsEnabled = false;
|
||||
btnCollect2.Visibility=Visibility.Collapsed;
|
||||
panelError.Visibility = Visibility.Visible;
|
||||
lblError.Text = strError;
|
||||
}
|
||||
|
||||
private bool InitSession()
|
||||
{
|
||||
try
|
||||
{
|
||||
//Check status
|
||||
cCmdRsp.SendDeSense();
|
||||
var data = cCmdRsp.recv_dat.dat;
|
||||
int IsCassetteFull=data[17] & 0x08;
|
||||
if(IsCassetteFull != 0)
|
||||
{
|
||||
ShowError("TÚI ĐẦY, ĐỀ NGHỊ LẤY TÚI TRƯỚC KHI TIẾP TỤC THAO TÁC");
|
||||
btnCollect2.Visibility=Visibility.Visible;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitSessionCount();
|
||||
sessions.Clear();
|
||||
Array.Clear(TempNote, 0, TempNote.Length);
|
||||
Array.Clear(Notes, 0, Notes.Length);
|
||||
quantityStored = 0;
|
||||
maxQuantitySheet = 0;
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
SetStep(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogException("InitSession", ex.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void PrintReceipt()
|
||||
{
|
||||
var shopName = AppData.CurrentCustomerAccount.Name;
|
||||
var shopCode = AppData.CurrentCustomerAccount.CustomerId;
|
||||
var tradingCode = "TRA04052024CDM";
|
||||
var storeAccountNumber = 686868686688;
|
||||
var currentTime = DateTime.Now;
|
||||
var printDocument = new PrintDocument();
|
||||
printDocument.PrinterSettings.PrinterName = "CUSTOM K80";
|
||||
printDocument.PrintPage += (sender, e) =>
|
||||
{
|
||||
e.Graphics.DrawString("Biên nhận nộp tiền", new Font("Arial", 15), System.Drawing.Brushes.Black, new PointF(80, 10));
|
||||
e.Graphics.DrawString("Mã máy CDM: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 60));
|
||||
e.Graphics.DrawString("Batch no: ", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 90));
|
||||
e.Graphics.DrawString("Thời gian GD: " + currentTime.ToString("dd/MM/yyyy HH:mm:ss"), new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 120));
|
||||
e.Graphics.DrawString("Mã GD: " + tradingCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 150));
|
||||
e.Graphics.DrawString("Mã gian hàng: " + shopCode, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 180));
|
||||
e.Graphics.DrawString("Tên gian hàng: " + shopName, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 210));
|
||||
e.Graphics.DrawString("STK gian hàng: " + storeAccountNumber, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 240));
|
||||
e.Graphics.DrawString("Số tiền nộp: " + lvCountItems[10].Value, new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(50, 270));
|
||||
e.Graphics.DrawString("*****Xin cám ơn******", new Font("Arial", 9), System.Drawing.Brushes.Black, new PointF(100, 300));
|
||||
// To send raw ESC/POS commands, you'd typically use e.Graphics.DrawString() with the command string,
|
||||
// or for more complex scenarios, directly manipulate the byte stream sent to the printer.
|
||||
};
|
||||
printDocument.Print();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void LogAction(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("log.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
public void LogException(string strAction, string? strData)
|
||||
{
|
||||
if (strData != null) strData = "Data: " + strData;
|
||||
File.AppendAllText("logException.txt", "\r\n" + DateTime.Now.ToString("yyyyMMddHHmmss: ") +
|
||||
"Action: " + strAction + " " + strData);
|
||||
}
|
||||
|
||||
private void LoginUsingQRCode()
|
||||
{
|
||||
var wnd = new WelcomeWindow();
|
||||
wnd.ShowDialog();
|
||||
|
||||
lblUser.Content = "";
|
||||
//var wnd = new QRCodeZebraWindow();
|
||||
//wnd.ShowDialog();
|
||||
if (wnd.DialogResult == true)
|
||||
{
|
||||
var strQR = wnd.QRCodeContent;
|
||||
var strPincode = wnd.PinCode;
|
||||
if (AppData.customerAccounts!=null)
|
||||
{
|
||||
CustomerAccount? cca = null;
|
||||
if(strQR!=null)
|
||||
{
|
||||
cca = AppData.customerAccounts.Where(x => x.QRCode == strQR).FirstOrDefault();
|
||||
}
|
||||
else if(strPincode!=null)
|
||||
{
|
||||
strPincode = strPincode.ToUpper();
|
||||
cca = AppData.customerAccounts.Where(x => x.PINCode == strPincode).FirstOrDefault();
|
||||
}
|
||||
|
||||
if (cca != null)
|
||||
{
|
||||
AppData.CurrentCustomerAccount = cca;
|
||||
lblUser.Content = $"Xin chào khách hàng: {cca.Name} (Gian hàng {cca.CustomerId})";
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("QRCode không đúng, vui lòng thử lại");
|
||||
LoginUsingQRCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnLoginByPINCode_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var wnd = new PinCodeWindow();
|
||||
wnd.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnCollect_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendXXCmd((byte)Command.CMD_DE_UNLOCK);
|
||||
Thread.Sleep(1000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
//Event fix
|
||||
var recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] == recvData.dat[16])
|
||||
{
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
else
|
||||
{
|
||||
cCmdRsp.SendEventFix(recvData.dat[16]);
|
||||
cCmdRsp.SendLock();
|
||||
}
|
||||
|
||||
var currentMode = cCmdRsp.GetLockParam().mode;
|
||||
cCmdRsp.GetLockParam().mode = Mode.MODE_COLLECTION;
|
||||
cCmdRsp.SendLock();
|
||||
Thread.Sleep(10000);
|
||||
cCmdRsp.SendDeSense();
|
||||
Thread.Sleep(1000);
|
||||
recvData = cCmdRsp.recv_dat;
|
||||
|
||||
if (recvData.dat[14] != recvData.dat[16])
|
||||
{
|
||||
ShowError("Khởi tạo bộ đếm thành công");
|
||||
ShutdownApp();
|
||||
InitApp();
|
||||
}
|
||||
//Thread.Sleep(5000);
|
||||
//cCmdRsp.GetLockParam().mode = currentMode;
|
||||
//cCmdRsp.SendLock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
static public class DE70Commands
|
||||
{
|
||||
//public static string ReadyToCountResponse = "40 07 41 00 01 00 00 00 00 00 00 10 00";
|
||||
public static string CountingResponse = "40 09 41 01 01 00 00 00 00 00 00 10 00";
|
||||
public static string ExceptionResponse = "40 07 41 10 10 01 00 00 00 00 00 00 10 10 00 00";
|
||||
public static string DESenseResponse1 = "40 04 41 00 00 00 00 00 00 00 00 10 00 00 00 00 01 70 00";
|
||||
public static string DESenseResponse2 = "40 04 41 00 00 00 00 00 00 00 00 10 00 00 01 00 02 70 00 ";
|
||||
public static string DESenseResponse3 = "40 04 41 00 00 00 00 00 00 00 00 10 00 00 02 00 03 70 00 ";
|
||||
public static string DESenseResponse4 = "40 04 41 00 00 00 00 00 00 00 00 10 00 00 03 00 04 70 00 ";
|
||||
public static string DESenseResponse5 = "40 04 41 00 00 00 00 00 00 00 00 10 00 00 04 00 05 70 00 ";
|
||||
public static string DESenseResponse0 = "40 04 41 00 00 00 00 00 00 00 00 10 00 00 05 00 00 70 00 ";
|
||||
|
||||
public static string[] DESenseSatisfyResponse = { "40 04 41 00 00 00 00 00 00 00 00 10 00 00 05 00 05 70 00",
|
||||
"40 04 41 00 00 00 00 00 00 00 00 10 00 00 04 00 04 70 00",
|
||||
"40 04 41 00 00 00 00 00 00 00 00 10 00 00 03 00 03 70 00",
|
||||
"40 04 41 00 00 00 00 00 00 00 00 10 00 00 02 00 02 70 00",
|
||||
"40 04 41 00 00 00 00 00 00 00 00 10 00 00 01 00 01 70 00",
|
||||
"40 04 41 00 00 00 00 00 00 00 00 10 00 00 00 00 00 70 00" };
|
||||
|
||||
//public static byte[] CountStartCmd= new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x73, 0x10, 0x03, 0x41 };
|
||||
//public static byte[] DESenseCmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x60, 0x10, 0x03, 0x52 };
|
||||
//public static byte[] UnlockCmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x71, 0x10, 0x03, 0x43 };
|
||||
//public static byte[] CancelCmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x76, 0x10, 0x03, 0x44 };
|
||||
//public static byte[] StoreStartCmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x31, 0x75, 0x10, 0x03, 0x47 };
|
||||
public static byte[] LockCmd = new byte[] { 0x10, 0x02, 0x30, 0x31, 0x33, 0x70, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x09, 0x00, 0x01, 0x01, 0x00, 0x10, 0x03, 0x48 };
|
||||
|
||||
//Event data fix
|
||||
|
||||
public static byte[] EventDataFixed_01_Cmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x01, 0x10, 0x03, 0x54 };
|
||||
public static byte[] EventDataFixed_02_Cmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x02, 0x10, 0x03, 0x57 };
|
||||
public static byte[] EventDataFixed_03_Cmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x03, 0x10, 0x03, 0x56 };
|
||||
public static byte[] EventDataFixed_04_Cmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x04, 0x10, 0x03, 0x51 };
|
||||
public static byte[] EventDataFixed_05_Cmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x05, 0x10, 0x03, 0x50 };
|
||||
public static byte[] EventDataFixed_00_Cmd = new byte[] { 0x10, 0x02, 0x30, 0x30, 0x33, 0x65, 0x00, 0x00, 0x10, 0x03, 0x55 };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,290 @@
|
||||
using DE70_CMDv2;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SafeBagDE70.Model;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace SafeBagDE70
|
||||
{
|
||||
public static class AppData
|
||||
{
|
||||
public static string CDMPort = "COM4";
|
||||
public static string SensorPort = "COM3";
|
||||
public static Version? CurrentVersion = null;
|
||||
public static List<CustomerAccount>? customerAccounts = null;
|
||||
public static CustomerAccount? CurrentCustomerAccount{get;set;}
|
||||
public static CCmdRsp? cCmdRsp=null;
|
||||
public static bool IsAuthenticated = false;
|
||||
public static bool IsInTransaction = false;
|
||||
public static int WDTCount = 0;
|
||||
public static ObservableCollection<string> logCollection = new ObservableCollection<string>();
|
||||
public static ListView logListView = null;
|
||||
public static int MaxLogCount = 500;
|
||||
public static void Init()
|
||||
{
|
||||
|
||||
customerAccounts = new List<CustomerAccount>{
|
||||
new CustomerAccount{Name="NGUYỄN ĐÌNH THUẬN",CustomerId="HUE_0000000001",QRCode="HUE_0000000001",PINCode="H0001" },
|
||||
new CustomerAccount{Name="HOÀNG VĂN HIỆP",CustomerId="HUE_0000000002",QRCode="HUE_0000000002",PINCode="H0002" },
|
||||
new CustomerAccount{Name="PHẠM NGỌC HƯNG",CustomerId="HUE_0000000003",QRCode="HUE_0000000003",PINCode="H0003" },
|
||||
new CustomerAccount{Name="AMHUE-ESTELLETEST",CustomerId="00DZAMHUE0004",QRCode="00DZAMHUE0004",PINCode="H0004" },
|
||||
new CustomerAccount{Name="AMHUE-ECCOTEST",CustomerId="00DZAMHUE0005",QRCode="00DZAMHUE0005",PINCode="H0005" },
|
||||
new CustomerAccount{Name="AMHUE-ALDOTEST",CustomerId="00DZAMHUE0006",QRCode="00DZAMHUE0006",PINCode="H0006" },
|
||||
new CustomerAccount{Name="AMHUE-MLBTEST",CustomerId="00DZAMHUE0007",QRCode="00DZAMHUE0007",PINCode="H0007" },
|
||||
new CustomerAccount{Name="AMHUE-PEDROTEST",CustomerId="00DZAMHUE0008",QRCode="00DZAMHUE0008",PINCode="H0008" }
|
||||
};
|
||||
CurrentCustomerAccount = customerAccounts[0];
|
||||
CDMSTATE=new CDMSTATE();
|
||||
}
|
||||
public static CDMSTATE? CDMSTATE = null;
|
||||
private static DateTime CutOffTime = new DateTime(1, 1, 1, 12, 0, 0); // 12:00 noon as cut-off time
|
||||
|
||||
public static void GetNewTransactionCode()
|
||||
{
|
||||
DateTime transactionDateTime = DateTime.Now;
|
||||
string merchantCode = CurrentCustomerAccount.CustomerId;
|
||||
|
||||
// Adjust transaction date if it's past cut-off time (12:00 noon)
|
||||
DateTime prevadjustedDate = CurrentCustomerAccount.TransactionTime.Hour >= CutOffTime.Hour ? transactionDateTime.Date : transactionDateTime.Date.AddDays(-1);
|
||||
|
||||
DateTime adjustedDate = transactionDateTime.Hour >= CutOffTime.Hour ? transactionDateTime.Date : transactionDateTime.Date.AddDays(-1);
|
||||
if ((adjustedDate - prevadjustedDate).Days > 0)
|
||||
{
|
||||
CurrentCustomerAccount.TransactionCount =1;
|
||||
}
|
||||
else
|
||||
{
|
||||
CurrentCustomerAccount.TransactionCount++;
|
||||
}
|
||||
var transactionCount = CurrentCustomerAccount.TransactionCount;
|
||||
string datePart = adjustedDate.ToString("yyyyMMdd");
|
||||
string timePart = transactionDateTime.ToString("HHmmss");
|
||||
string transactionCountPart = transactionCount.ToString("D2"); // Ensure 2 digits
|
||||
|
||||
// Combine all parts to form the transaction ID
|
||||
string transactionId = $"{datePart}{timePart}{merchantCode}{transactionCountPart}";
|
||||
|
||||
CurrentCustomerAccount.TransactionCode = transactionId;
|
||||
CurrentCustomerAccount.TransactionTime = transactionDateTime;
|
||||
}
|
||||
public static CDMSTATE? GetCDMState()
|
||||
{
|
||||
if(cCmdRsp!=null)
|
||||
{
|
||||
cCmdRsp.SendDeSense();
|
||||
string strSend = cCmdRsp.GetSendDat(false);
|
||||
string strRecv = cCmdRsp.GetRecvDat();
|
||||
Log.Information($"[SEND] {strSend}");
|
||||
Log.Information($"[RECV] {strRecv}");
|
||||
var data = cCmdRsp.recv_dat.dat;
|
||||
if(AppData.CDMSTATE!=null)
|
||||
{
|
||||
AppData.CDMSTATE.IsCassetteFull = data[17] & 0x08;
|
||||
AppData.CDMSTATE.IsNotesInEscrow = data[4] & 0x01;
|
||||
AppData.CDMSTATE.IsRejectPocketFull = data[3] & 0x40;
|
||||
AppData.CDMSTATE.IsNotesInRejectPocket = data[3] & 0x10;
|
||||
AppData.CDMSTATE.IsNotesInHopper = data[3] & 0x01;
|
||||
AppData.CDMSTATE.RequestTime = DateTime.Now;
|
||||
AppData.CDMSTATE.SR1 = data[0];
|
||||
AppData.CDMSTATE.SR2 = data[1];
|
||||
AppData.CDMSTATE.SR3 = data[2];
|
||||
}
|
||||
|
||||
}
|
||||
return AppData.CDMSTATE;
|
||||
}
|
||||
|
||||
}
|
||||
public class CustomerAccount
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? CustomerId { get; set; }
|
||||
public string? QRCode { get; set; }
|
||||
public string? PINCode { get; set; }
|
||||
public int TransactionCount { get; set; } = 1;
|
||||
public DateTime TransactionTime { get; set; }
|
||||
public string TransactionCode { get; set; }
|
||||
}
|
||||
public class CountSession
|
||||
{
|
||||
public CountSession()
|
||||
{
|
||||
for (int i = 0; i < QuantityDenomi.Count(); i++)
|
||||
{
|
||||
QuantityDenomi[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < SumDenomi.Count(); i++)
|
||||
{
|
||||
SumDenomi[i] = 0;
|
||||
}
|
||||
for (int i = 0; i < TempNotes.Count(); i++)
|
||||
{
|
||||
TempNotes[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public int[] QuantityDenomi { get; set; } = new int[10];
|
||||
public int[] SumDenomi { get; set; } = new int[10];
|
||||
public bool IsStored = false;
|
||||
public int[] TempNotes { get; set; } = new int[5];
|
||||
|
||||
}
|
||||
|
||||
public class CountingData2Send
|
||||
{
|
||||
public string? TransactionCode { get; set; }
|
||||
public List<CountSession>? Sessions { get; set; }
|
||||
public string? UserId { get; set; }
|
||||
public string? MachineId { get; set; }
|
||||
public string? MachineTime { get; set; }
|
||||
public int RejectNotes { get; set; }
|
||||
public int GenuineNotes { get; set; }
|
||||
public int UnfitNotes { get; set; }
|
||||
public int CounterfeitNotes { get; set; }
|
||||
public int SuspendNotes { get; set; }
|
||||
public int CountingState { get; set; }//0-Normal End, 1-Timeout End
|
||||
}
|
||||
|
||||
public class NotesInSession : INotifyPropertyChanged
|
||||
{
|
||||
|
||||
private int _GenuineNotes;
|
||||
public int GenuineNotes
|
||||
{
|
||||
get
|
||||
{
|
||||
return _GenuineNotes;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_GenuineNotes != value)
|
||||
{
|
||||
_GenuineNotes = value;
|
||||
OnPropertyChanged(nameof(GenuineNotes));
|
||||
}
|
||||
}
|
||||
}
|
||||
private int _RejectNotes;
|
||||
public int RejectNotes
|
||||
{
|
||||
get
|
||||
{
|
||||
return _RejectNotes;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_RejectNotes != value)
|
||||
{
|
||||
_RejectNotes = value;
|
||||
OnPropertyChanged(nameof(RejectNotes));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
public class CDMSTATE : INotifyPropertyChanged
|
||||
{
|
||||
public int IsCassetteFull = 0;
|
||||
public int IsNotesInEscrow = 0;
|
||||
public int IsRejectPocketFull = 0;
|
||||
public int IsNotesInRejectPocket = 0;
|
||||
public int IsNotesInHopper = 0;
|
||||
private byte _SR1;
|
||||
public byte SR1 {
|
||||
get
|
||||
{
|
||||
return _SR1;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_SR1 != value)
|
||||
{
|
||||
_SR1 = value;
|
||||
UpdateCDMStatus();
|
||||
OnPropertyChanged(nameof(SR1));
|
||||
}
|
||||
}
|
||||
}
|
||||
private byte _SR2;
|
||||
public byte SR2
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SR2;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_SR2 != value)
|
||||
{
|
||||
_SR2 = value;
|
||||
UpdateCDMStatus();
|
||||
OnPropertyChanged(nameof(SR2));
|
||||
}
|
||||
}
|
||||
}
|
||||
private byte _SR3;
|
||||
public byte SR3
|
||||
{
|
||||
get
|
||||
{
|
||||
return _SR3;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_SR3 != value)
|
||||
{
|
||||
_SR3 = value;
|
||||
UpdateCDMStatus();
|
||||
OnPropertyChanged(nameof(SR3));
|
||||
}
|
||||
}
|
||||
}
|
||||
public void UpdateCDMStatus()
|
||||
{
|
||||
if (AppData.cCmdRsp != null) {
|
||||
CDMStatus = RequestTime.ToString("yyyyMMdd HHmmss")+ " SR1: " + AppData.cCmdRsp.GetSR1Summary(SR1) + " SR2: " + AppData.cCmdRsp.GetSR2Summary(SR2);
|
||||
}
|
||||
}
|
||||
private string? _CDMStatus;
|
||||
public string? CDMStatus
|
||||
{
|
||||
get
|
||||
{
|
||||
return _CDMStatus;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_CDMStatus != value)
|
||||
{
|
||||
_CDMStatus = value;
|
||||
|
||||
OnPropertyChanged(nameof(CDMStatus));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DateTime RequestTime = DateTime.Now;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace VirtualKeyboard.Wpf.Types
|
||||
{
|
||||
enum UppercaseMode
|
||||
{
|
||||
None,
|
||||
FirstUpper,
|
||||
AlwaysUpper
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user