Files
DE70/Admin/UserManageUC.xaml.cs
2024-09-21 16:02:30 +07:00

87 lines
2.6 KiB
C#

using Microsoft.Extensions.Logging;
using SafeBagDE70.API;
using SafeBagDE70.Model;
using Serilog;
using Serilog.Core;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
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 LogViewerUC.xaml
/// </summary>
public partial class UserManageUC : UserControl
{
private ObservableCollection<string> _logItems = new ObservableCollection<string>();
public UserManageUC()
{
InitializeComponent();
}
private void LogInfoButton_Click(object sender, RoutedEventArgs e)
{
}
private async void btnGetUsers_Click(object sender, RoutedEventArgs e)
{
try
{
if(AppData.IsInTransaction)
{
lblStatus.Foreground = new SolidColorBrush(Colors.Red);
lblStatus.Content = "Vui lòng kết thúc giao dịch để thực hiện chức năng này";
}
else
{
int nUpdatedCustomers=await AppData.UpdateCustomers();
lblStatus.Foreground = new SolidColorBrush(Colors.Green);
lblStatus.Content = "Updated customers: " + nUpdatedCustomers;
}
AppData.InitUsers();
}
catch(Exception ex)
{
lblStatus.Foreground = new SolidColorBrush(Colors.Red);
lblStatus.Content= ex.Message;
}
}
private void btnSyncTransaction_Click(object sender, RoutedEventArgs e)
{
AppData.ResendData();
}
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e)
{
string searchTerm = SearchBox.Text.ToLower();
// Filter items based on search term
var filteredItems = AppData.customerAccounts.Where(item => item.Name.ToLower().Contains(searchTerm)|| item.CustomerId.ToLower().Contains(searchTerm)).ToList();
ListViewItems.ItemsSource = filteredItems;
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
ListViewItems.ItemsSource = AppData.customerAccounts;
}
}
}