Di chuyển usercontrol vào thư mục usercontrol

This commit is contained in:
Nguyen Dinh Thuan
2024-09-21 06:51:23 +07:00
parent cc2560cb3a
commit 046a23dd9f
21 changed files with 5 additions and 5 deletions
+20
View File
@@ -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>
+33
View File
@@ -0,0 +1,33 @@
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();
}
public void Init()
{
}
}
}
+212
View File
@@ -0,0 +1,212 @@
<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"
xmlns:conv="clr-namespace:SafeBagDE70.Converters"
mc:Ignorable="d"
Width="1280"
Height="1024"
Background="#F0F0F0"
Loaded="UserControl_Loaded"
Unloaded="UserControl_Unloaded">
<UserControl.Resources>
<conv: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>
File diff suppressed because it is too large Load Diff
+236
View File
@@ -0,0 +1,236 @@
<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"
xmlns:conv="clr-namespace:SafeBagDE70.Converters"
mc:Ignorable="d"
Width="1280"
Height="1024"
Background="#F0F0F0"
Loaded="UserControl_Loaded"
Unloaded="UserControl_Unloaded">
<UserControl.Resources>
<conv: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="120"/>
<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="20"
Height="40"/>
<Label HorizontalAlignment="Center"
x:Name="lblUser"
Background="Transparent"
Foreground="White"
BorderThickness="0"
FontSize="20"
FontWeight="Bold"
Height="40"/>
<Label HorizontalAlignment="Center"
x:Name="lblTransactionCode"
Background="Transparent"
Foreground="White"
BorderThickness="0"
FontSize="20"
FontWeight="Bold"
Height="40"/>
<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">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="50"/>
</Grid.RowDefinitions>
<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.Row="1" x:Name="spNotesInSession">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Height="50" FontSize="20" FontWeight="Bold" BorderBrush="Transparent" Background="Transparent" Content="Số tờ hợp lệ"/>
<Label Grid.Column="1" Height="50" FontSize="20" FontWeight="Bold" BorderBrush="Transparent" Background="Transparent" x:Name="lblGenuineNotesInSession" Content="{Binding GenuineNotes}"/>
<Label Grid.Column="2" Height="50" FontSize="20" FontWeight="Bold" BorderBrush="Transparent" Background="Transparent" Content="Không hợp lệ"/>
<Label Grid.Column="3" Height="50" FontSize="20" FontWeight="Bold" BorderBrush="Transparent" Background="Transparent" x:Name="lblRejectNotesInSession" Content="{Binding RejectNotes}"/>
</Grid>
</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>
File diff suppressed because it is too large Load Diff
+211
View File
@@ -0,0 +1,211 @@
<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:converter="clr-namespace:SafeBagDE70.Converters"
mc:Ignorable="d"
Width="1280"
Height="1024"
Background="#F0F0F0"
Loaded="UserControl_Loaded"
Unloaded="UserControl_Unloaded">
<UserControl.Resources>
<converter: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 Content="Vietinbank"
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>
File diff suppressed because it is too large Load Diff
+21
View File
@@ -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>
+48
View File
@@ -0,0 +1,48 @@
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 EndSessionUC : UserControl
{
public EndSessionUC()
{
InitializeComponent();
}
public void ShowInfor(string strInfor)
{
lblInfor.Text = strInfor;
}
private void btnEnd_Click(object sender, RoutedEventArgs e)
{
AppData.WDTCount = 0;
//var state= ((MainWindow)Application.Current.MainWindow).GetDepositScreen().GetPrevioustState();
// ((MainWindow)Application.Current.MainWindow).GetDepositScreen().TransitionToState(state);
((MainWindow)Application.Current.MainWindow).ResetTimers();
((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);
}
}
}
+18
View File
@@ -0,0 +1,18 @@
<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"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<StackPanel Background="White" VerticalAlignment="Center" Margin="20">
<TextBlock FontSize="30" FontWeight="Bold" Foreground="Red" Text="ĐÃ XẢY RA LỖI" HorizontalAlignment="Center"/>
<Separator/>
<TextBlock x:Name="lblError" FontSize="30" TextWrapping="Wrap" FontWeight="Bold" Foreground="Blue" HorizontalAlignment="Center"/>
<Separator/>
<Grid Margin="10">
<Button x:Name="btnRetry" Click="btnRetry_Click" Grid.Column="0" Content="THỬ LẠI" Height="50"/>
</Grid>
</StackPanel>
</UserControl>
+40
View File
@@ -0,0 +1,40 @@
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 ErrorUC : UserControl
{
public ErrorUC()
{
InitializeComponent();
}
public void ShowInfor(string strInfor)
{
lblError.Text = strInfor;
SoundManager.StartWarningSound();
}
private void btnRetry_Click(object sender, RoutedEventArgs e)
{
SoundManager.StopWarningSound();
((MainWindow)Application.Current.MainWindow).ShowWelcomeScreen();
}
}
}
+17
View File
@@ -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>
+70
View File
@@ -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();
}
}
}
+22
View File
@@ -0,0 +1,22 @@
<UserControl x:Class="SafeBagDE70.MaintainanceUC"
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 DỪNG HOẠT ĐỘNG, ĐANG THỰC HIỆN THAO TÁC NGHIỆP VỤ"
FontSize="30"
TextWrapping="Wrap"
TextAlignment="Center"
FontWeight="Bold"
Foreground="Red"
HorizontalAlignment="Center"/>
<Separator/>
</hc:SimpleStackPanel>
</UserControl>
+60
View File
@@ -0,0 +1,60 @@
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);
((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();
}
}
}
+17
View File
@@ -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>
+48
View File
@@ -0,0 +1,48 @@
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;
//var state= ((MainWindow)Application.Current.MainWindow).GetDepositScreen().GetPrevioustState();
// ((MainWindow)Application.Current.MainWindow).GetDepositScreen().TransitionToState(state);
((MainWindow)Application.Current.MainWindow).ResetTimers();
((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);
}
}
}
+66
View File
@@ -0,0 +1,66 @@
<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 x:Name="gridMain" Visibility="Collapsed">
<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>
<Grid x:Name="gridInfor">
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock x:Name="txtInfor" Text="ĐANG KHỞI TẠO, VUI LÒNG ĐỢI" Foreground="Blue" FontSize="24" />
</StackPanel>
</Grid>
</Grid>
</UserControl>
+349
View File
@@ -0,0 +1,349 @@
using CoreScanner;
using SafeBagDE70.API;
using Serilog;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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;
using System.Xml.Linq;
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 = "";
QrCodePanel.Visibility = Visibility.Collapsed;
}
public void ShowLogin()
{
gridInfor.Visibility = Visibility.Collapsed;
gridMain.Visibility = Visibility.Visible;
}
public void ShowInfor(string strMessage)
{
gridInfor.Visibility = Visibility.Visible;
gridMain.Visibility = Visibility.Collapsed;
txtInfor.Text = strMessage;
txtInfor.Foreground = new SolidColorBrush(Colors.DarkRed);
}
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.CreateNewTransactionCode();
((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)
{
try
{
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);
short numberOfScanners; // Number of scanners expect to be used
int[] connectedScannerIDList = new int[255]; // List of scanner IDs to be returned
string outXML;
cCoreScannerClass.GetScanners(out numberOfScanners, connectedScannerIDList, out outXML, out status);
if (numberOfScanners > 0)
{
// 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);
}
else
{
Log.Information("Không tìm thấy đầu đọc QR");
AppData.DeviceStatus.OtherError = 1;
AppData.DeviceStatus.Description = "Không tìm thấy đầu đọc QR";
APIModels.SendEvent(AppData.DeviceStatus);
}
}
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.CreateNewTransactionCode();
((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);
}
}
}