Пример #1
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            string id = ((Button)sender).Tag.ToString();

            if (_context.GetCurrentEmpID() == id)
            {
                MessageBox.Show("Không được xóa tài khoản của bản thân!");
                return;
            }

            if (id == "E001")
            {
                MessageBox.Show("Đây là tài khoản gốc, không thể xóa!");
                return;
            }

            BUS_Employees busEmp = new BUS_Employees();
            string        name   = busEmp.GetEmpNameByID(id);

            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window = new Window
            {
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None,
                Title                 = "Xóa tài khoản",
                Content               = new PopupDeleteConfirm($"Bạn có chắc chắn muốn xóa tài khoản {id}\ncủa nhân viên {name} không?", id, 1),
                Width                 = 420,
                Height                = 210,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();

            int empCount = busEmp.CountEmployees();

            if (empCount % limitRow == 0)
            {
                lblMaxPage.Content = empCount / limitRow;
            }
            else
            {
                lblMaxPage.Content = empCount / limitRow + 1;
            }
            if (currentPage > (int)lblMaxPage.Content)
            {
                tbNumPage.Text = (--currentPage).ToString();
            }

            if (currentPage == (int)lblMaxPage.Content)
            {
                btnPageNext.IsEnabled = false;
            }
            else
            {
                btnPageNext.IsEnabled = true;
            }

            if (currentPage == 1)
            {
                btnPagePre.IsEnabled = false;
            }
            else
            {
                btnPagePre.IsEnabled = true;
            }

            ReloadDGAccount();
            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
        }
Пример #2
0
        private void cbCheck_Click(object sender, RoutedEventArgs e)
        {
            string id    = ((CheckBox)sender).Tag.ToString();
            bool?  state = ((CheckBox)sender).IsChecked;

            if (state == false)
            {
                if (_context.GetCurrentEmpID() == id)
                {
                    MessageBox.Show("Không được vô hiệu hóa tài khoản của bản thân!");
                    ((CheckBox)sender).IsChecked = true;
                    return;
                }

                if ("E001" == id)
                {
                    MessageBox.Show("Đây là tài khoản gốc, không được vô hiệu hóa!");
                    ((CheckBox)sender).IsChecked = true;
                    return;
                }
            }
            BUS_Employees busEmp = new BUS_Employees();
            string        name   = busEmp.GetEmpNameByID(id);

            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window;

            if (state == true)
            {
                window = new Window
                {
                    ResizeMode            = ResizeMode.NoResize,
                    WindowStyle           = WindowStyle.None,
                    Title                 = "Kích hoạt tài khoản",
                    Content               = new PopupDeleteConfirm($"Bạn có chắc chắn muốn kích hoạt tài khoản {id} \n của nhân viên {name} không?", id, 3),
                    Width                 = 380,
                    Height                = 210,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                }
            }
            ;
            else
            {
                window = new Window
                {
                    ResizeMode            = ResizeMode.NoResize,
                    WindowStyle           = WindowStyle.None,
                    Title                 = "Vô hiệu hóa tài khoản",
                    Content               = new PopupDeleteConfirm($"Bạn có chắc chắn muốn vô hiệu hóa tài khoản \n{id} của nhân viên {name} không?", id, 4),
                    Width                 = 380,
                    Height                = 210,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen
                }
            };
            window.ShowDialog();
            LoadData();
            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
        }
Пример #3
0
        public string GetCurrentEmpName()
        {
            BUS_Employees bus = new BUS_Employees();

            return(bus.GetEmpNameByID(this.currentEmpID));
        }