Пример #1
0
        public BanHang_ViewModel()
        {
            Global.Ins.isXuLy      = false;
            Global.Ins.PhieuDHXuLY = null;
            LoadDatabase();

            GetMaHDCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                MaHD = Global.Ins.autoGenerateHoaDon();
            });

            HuyCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                LoadDatabase();
                Global.Ins.isXuLy      = false;
                Global.Ins.PhieuDHXuLY = null;
            });

            ThemGioHangCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                ThemGioHang();
                TinhTien();
            });

            BoRaGioHangCommand = new RelayCommand <Window>((p) => { if (SelectedMatHang == null)
                                                                    {
                                                                        return(false);
                                                                    }
                                                                    return(true); }, (p) => {
                BoHang();
            });

            DialogOK = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                DialogOpen = false;
            });

            XacNhanCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                TaoHoaDon();
            });

            XemDatOnlineCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                XuLyPhieuOnline();
            });

            QLHDCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                QuanLyHoaDon_Window win = new QuanLyHoaDon_Window();
                win.ShowDialog();
            });

            CheckSDTCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                CheckSDT();
            });
            KhachHangCommand = new RelayCommand <Window>((p) => { if (!String.IsNullOrEmpty(MaPhieuDH))
                                                                  {
                                                                      return(false);
                                                                  }
                                                                  return(true); }, (p) => {
                if (ButtonKhachHang == "Xác thực khách hàng")
                {
                    SDT             = "";
                    TenKhachHang    = "";
                    EnableKhachHang = false;
                    XacThuc         = Visibility.Visible;
                    ButtonKhachHang = "Hủy xác thực";
                }
                else
                {
                    SDT             = "";
                    TenKhachHang    = "";
                    EnableKhachHang = true;
                    XacThuc         = Visibility.Hidden;
                    ButtonKhachHang = "Xác thực khách hàng";
                }
            });
        }
        public ThayDoiQuyDinh_ViewModel()
        {
            LoadSomeVariables();
            LoadDatabaseMucThuong();
            LoadHeSoLamThem();
            LoadBangPhuCap();
            BindingPhuCap();

            MucThuongSelectionChangedCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
            });
            PhuCapSelectionChangedCommand    = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                BindingPhuCap();
            });
            DialogOK = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                DialogOpen = false;
            });
            DialogOKMT = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                if (Title == "THÊM MỨC THƯỞNG")
                {
                    XacNhanThemMucThuong();
                }
                else
                {
                    XacNhanSuaMucThuong();
                }
            });
            DialogHuyMT = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                DialogThemMTOpen = false;
            });
            DialogOKXoaMT = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                XacNhanXoaMT();
            });
            DialogHuyXoaMT = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                DialogXoaMTOpen = false;
            });
            ThemMucThuongCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                DialogThemMTOpen = true;
                NhapTenMucThuong = "";
                NhapTienThuong   = "";
                Title            = "THÊM MỨC THƯỞNG";
            });
            SuaMucThuongCommand = new RelayCommand <Window>((p) => { if (SelectedMucThuong == null)
                                                                     {
                                                                         return(false);
                                                                     }
                                                                     return(true); }, (p) => {
                DialogThemMTOpen = true;
                NhapTenMucThuong = SelectedMucThuong.TenMucThuong;
                NhapTienThuong   = Global.Ins.filterNumber(SelectedMucThuong.LuongThuong).ToString();
                Title            = "SỬA MỨC THƯỞNG";
            });
            XoaMucThuongCommand = new RelayCommand <Window>((p) => { if (SelectedMucThuong == null)
                                                                     {
                                                                         return(false);
                                                                     }
                                                                     return(true); }, (p) =>
            {
                DialogXoaMTOpen = true;
            });

            ReloadCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                DialogOpen = true;
                IconModal  = "CheckCircleOutline";
                ThongBao   = "Không có gì mới để reload";
            });

            XacNhanHeSoCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                ThayDoiHeSo();
            });

            XacNhanPhuCapCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => {
                ThayDoiPhuCap();
            });
        }