Add project files.

This commit is contained in:
Admin
2024-09-02 10:03:23 +07:00
parent 42def0d4aa
commit 6219298497
361 changed files with 58423 additions and 0 deletions
@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
@@ -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.Password = "";
}
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,128 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Linq;
using System.Net.Mail;
using System.Net.WebSockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using SafeBagDE70;
namespace SafeBagDE70.Model
{
public class LvCountItem : INotifyPropertyChanged
{
private string _Name { get; set; }
public string Name
{
get
{
int deno = 0;
var str = _Name;
if (int.TryParse(_Name, out deno))
{
str = String.Format(CultureInfo.InvariantCulture,
"{0:#,#.##}", deno);
}
return str;
}
set
{
if (_Name != value)
{
_Name = value;
OnPropertyChanged(nameof(Name));
}
}
}
private string _Quantity { get; set; }
public string Quantity
{
get => _Quantity;
set
{
if(_Quantity != value)
{
_Quantity = value;
OnPropertyChanged(nameof(Quantity));
double deno = 0;
double.TryParse(_Name, out deno);
var str = getValue().ToString();
if (str == "") str = "0";
Value = str;
//if(double.TryParse(_Name, out deno))
//{
// var str = getValue().ToString();
// if (str == "") str = "0";
// Value = str;
//}
}
}
}
public double getValue()
{
double deno = 0;
double.TryParse(_Name, out deno);
double quant = 0;
double.TryParse(_Quantity, out quant);
return (deno * quant);
}
private string _Value;
public string Value
{
get
{
var str = _Value;
int val = 0;
if (int.TryParse(_Value, out val))
{
str = String.Format(CultureInfo.InvariantCulture,
"{0:#,#.##}", val);
if(str=="")str= "0";
}
return str;
}
set
{
if (_Value != value)
{
_Value = value;
OnPropertyChanged(nameof(Value));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
public class SessionQuantity
{
private List<int[]> subSessionQuantities = new List<int[]>();
public void AddSubSession(int[] subSessionQuantity)
{
subSessionQuantities.Add(subSessionQuantity);
}
public void RemoveLastSubSession()
{
subSessionQuantities.RemoveAt(subSessionQuantities.Count - 1);
}
public int GetQuantity(int index)
{
int _totalQuantity = 0;
foreach (var item in subSessionQuantities)
{
_totalQuantity += item[index];
}
return _totalQuantity;
}
}
}