public MainViewModel() { LoadedWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { IsLoaded = true; LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); }); //MessageBox.Show("Đã vào trong MainViewModel -> DataContext của mainwindow.xaml"); UnitCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UnitWindow wd = new UnitWindow(); wd.ShowDialog(); }); // SuplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SuplierWindow wd = new SuplierWindow(); wd.ShowDialog(); }); // CustomerCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CustomerWindow wd = new CustomerWindow(); wd.ShowDialog(); }); // }
private void InitializeUnitWindowCommand() { UnitWindowCommand = new RelayCommand <object>( sender => { return(true); }, sender => { UnitWindow unitWindow = new UnitWindow(); unitWindow.ShowDialog(); }); }
public MainViewModel() { IsLoaded = false; LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { IsLoaded = true; if (p == null) { return; } p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); if (loginWindow.DataContext == null) { return; } var loginVM = loginWindow.DataContext as LoginViewModel; if (loginVM.IsLogin) { p.Show(); } else { p.Close(); } }); UnitCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UnitWindow window = new UnitWindow(); window.ShowDialog(); }); SupplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SupplierWindow window = new SupplierWindow(); window.ShowDialog(); }); }
private void ButtonAddItem_Click(object sender, RoutedEventArgs e) { if (ChaptersDataGrid.SelectedItem != null && ChaptersDataGrid.SelectedItem.ToString() != "{NewItemPlaceholder}") { this.edit = false; UnitWindow unitWindow = new UnitWindow(edit, selRow, index_capitulo); unitWindow.ShowDialog(); clsUnitarios obj = new clsUnitarios(); dt_unitarios = obj.CargarUnitarios(index_capitulo); dt_unitarios.Columns[0].ColumnName = "ITEM ID"; dt_unitarios.Columns[1].ColumnName = "DESCRIPTION"; dt_unitarios.Columns[2].ColumnName = "UNIT"; dt_unitarios.Columns[3].ColumnName = "QUANTITY"; dt_unitarios.Columns[4].ColumnName = "CHAPTER ID"; ItemsDataGrid.ItemsSource = dt_unitarios.DefaultView; } }
public MainWindowViewModel() { LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { isLoaded = true; if (p == null) { return; } p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); if (loginWindow.DataContext == null) { return; } var loginVM = loginWindow.DataContext as LoginWindowViewModel; if (loginVM.IsLogin) { p.Show(); } else { p.Close(); } }); OpenUnitWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UnitWindow unitWindow = new UnitWindow(); unitWindow.ShowDialog(); }); OpenSuppliersWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SuppliersWindow sW = new SuppliersWindow(); sW.ShowDialog(); }); OpenCustomersWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CustomersWindow cW = new CustomersWindow(); cW.ShowDialog(); }); OpenProductsWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ProductsWindow pW = new ProductsWindow(); pW.ShowDialog(); }); OpenUsersWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UsersWindow pW = new UsersWindow(); pW.ShowDialog(); }); OpenInputWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { InputWindow pW = new InputWindow(); pW.ShowDialog(); }); OpenOutputWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { OutputWindow pW = new OutputWindow(); pW.ShowDialog(); }); }
public MainViewModel() { LoadedWindowCommand = new RelayCommand <Window>(p => { return(true); }, p => { if (p == null) { return; } p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); if (loginWindow.DataContext == null) { return; } var loginVM = loginWindow.DataContext as LoginViewModel; if (loginVM.isLogin) { p.Show(); } else { p.Close(); } }); UnitCommand = new RelayCommand <object>(p => { return(true); }, p => { UnitWindow wd = new UnitWindow(); wd.ShowDialog(); }); SuplierCommand = new RelayCommand <object>(p => { return(true); }, p => { SuplierWindow wd = new SuplierWindow(); wd.ShowDialog(); }); CustomerCommand = new RelayCommand <object>(p => { return(true); }, p => { CustomerWindow wd = new CustomerWindow(); wd.ShowDialog(); }); ObjectCommand = new RelayCommand <object>(p => { return(true); }, p => { ObjectWindow wd = new ObjectWindow(); wd.ShowDialog(); }); UserCommand = new RelayCommand <object>(p => { return(true); }, p => { UserWindow wd = new UserWindow(); wd.ShowDialog(); }); InputCommand = new RelayCommand <object>(p => { return(true); }, p => { InputWindow wd = new InputWindow(); wd.ShowDialog(); }); OutputCommand = new RelayCommand <object>(p => { return(true); }, p => { OutputWindow wd = new OutputWindow(); wd.ShowDialog(); }); }
// mọi thứ xử lý sẽ nằm trong này public MainViewModel() { if (!IsLoaded) { LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { IsLoaded = true; if (p == null) { return; } p.Hide(); LoginWindow login = new LoginWindow(); login.ShowDialog(); if (login.DataContext == null) { return; } var LoginVM = login.DataContext as LoginViewModel; if (LoginVM.IsLogin) { p.Show(); LoadTonKhoData(); } else { p.Close(); } }); UnitCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UnitWindow unit = new UnitWindow(); unit.ShowDialog(); }); SuplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SuplierWindow suplier = new SuplierWindow(); suplier.ShowDialog(); }); CustomerCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CustomerWindow suplier = new CustomerWindow(); suplier.ShowDialog(); }); ObjectCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ObjectWindow suplier = new ObjectWindow(); suplier.ShowDialog(); }); UserCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UserWindow suplier = new UserWindow(); suplier.ShowDialog(); }); InputCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { InputWindow suplier = new InputWindow(); suplier.ShowDialog(); }); OutnputCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { OutputWindow suplier = new OutputWindow(); suplier.ShowDialog(); }); } }
// mọi thứ xử lý sẽ nằm trong này public MainViewModel() { LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { Isloaded = true; p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); p.Show(); } ); UnitCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UnitWindow wd = new UnitWindow(); wd.ShowDialog(); }); SupplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SupplierWindow wd = new SupplierWindow(); wd.ShowDialog(); }); CustomerCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CustomerWindow wd = new CustomerWindow(); wd.ShowDialog(); }); ObjectCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ObjectWindow wd = new ObjectWindow(); wd.ShowDialog(); }); UserCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UserWindow wd = new UserWindow(); wd.ShowDialog(); }); InputCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { InputWindow wd = new InputWindow(); wd.ShowDialog(); }); OutputCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { OutputWindow wd = new OutputWindow(); wd.ShowDialog(); }); }
public MainViewModel() { ImportWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } ImportWindow wd = new ImportWindow(); wd.ShowDialog(); }); SellWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { SellWindow wd = new SellWindow(); wd.ShowDialog(); }); CustomerWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } CustomerWindow wd = new CustomerWindow(); wd.ShowDialog(); }); ProductWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } ProductWindow wd = new ProductWindow(); wd.ShowDialog(); }); SupplierWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } SupplierWindow wd = new SupplierWindow(); wd.ShowDialog(); }); StatisticalWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } StatisticalWindow wd = new StatisticalWindow(); wd.ShowDialog(); }); UnitWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } UnitWindow wd = new UnitWindow(); wd.ShowDialog(); }); UserListWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } UserListWindow wd = new UserListWindow(); wd.ShowDialog(); }); AccountCreateWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } AccountCreateWindow wd = new AccountCreateWindow(); wd.ShowDialog(); }); BillWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (_UserIDRole != 1) { LoadDialogErrorNotPermission(); return; } BillWindow wd = new BillWindow(); wd.ShowDialog(); }); LoadMainWindow = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (!isLoaded) { isLoaded = true; if (p == null) { return; } p.Hide(); LoginWindow wd = new LoginWindow(); wd.ShowDialog(); var loginViewModel = wd.DataContext as LoginViewModel; if (loginViewModel == null) { return; } if (loginViewModel.isLogin) { loadUserCurrentLogin(); p.Show(); } else { p.Close(); } } }); LoadEditCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { LoadDialogAccountEdit(); }); }
public MainViewModel() { IsLoadCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { Isload = true; p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); /// Khi no dang nhap thanh con moi hien thi main if (loginWindow.DataContext == null) { return; } var loginModel = loginWindow.DataContext as LoginViewModel; if (loginModel.isLogin) { p.Show(); } else { p.Close(); } }); UnitCommand = new RelayCommand <Window>((p) => true, (p) => { UnitWindow wd = new UnitWindow(); wd.ShowDialog(); }); SuplierCommand = new RelayCommand <Window>((p) => true, (p) => { SuplierWindow wd = new SuplierWindow(); wd.ShowDialog(); }); UserCommand = new RelayCommand <Window>((p) => true, (p) => { UserWindow wd = new UserWindow(); wd.ShowDialog(); }); }
public MainWindowViewModel() { LoadMainWindowCommand = new RelayCommand <Window>(p => { return(p == null ? false : true); }, p => { LoadStockInTradeData(); }); LoadChildWindowCommand = new RelayCommand <Button>(p => { return(p == null ? false : true); }, p => { switch (p.Name) { case "btnStockin": InputWindow inputWindow = new InputWindow(); FrameworkElement window1 = Window.GetWindow(p); var temp1 = window1 as Window; inputWindow.Owner = temp1; inputWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Import; inputWindow.ShowDialog(); break; case "btnStockout": OutputWindow outputWindow = new OutputWindow(); FrameworkElement window2 = Window.GetWindow(p); var temp2 = window2 as Window; outputWindow.Owner = temp2; outputWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Export; outputWindow.ShowDialog(); break; case "btnSupplies": SuppliesWindow suppliesWindow = new SuppliesWindow(); FrameworkElement window3 = Window.GetWindow(p); var temp3 = window3 as Window; suppliesWindow.Owner = temp3; suppliesWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.PackageVariantClosed; suppliesWindow.ShowDialog(); break; case "btnUnit": UnitWindow unitWindow = new UnitWindow(); FrameworkElement window4 = Window.GetWindow(p); var temp4 = window4 as Window; unitWindow.Owner = temp4; unitWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.ChartScatterPlotHexbin; unitWindow.ShowDialog(); break; case "btnSupplier": SupplierWindow supplierWindow = new SupplierWindow(); FrameworkElement window5 = Window.GetWindow(p); var temp5 = window5 as Window; supplierWindow.Owner = temp5; supplierWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.Factory; supplierWindow.ShowDialog(); break; case "btnCustomer": CustomerWindow customerWindow = new CustomerWindow(); FrameworkElement window6 = Window.GetWindow(p); var temp6 = window6 as Window; customerWindow.Owner = temp6; customerWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.AccountMultiple; customerWindow.ShowDialog(); break; case "btnUser": UserWindow userWindow = new UserWindow(); FrameworkElement window7 = Window.GetWindow(p); var temp7 = window7 as Window; userWindow.Owner = temp7; userWindow.controlBar.packIcon.Kind = MaterialDesignThemes.Wpf.PackIconKind.AccountEdit; userWindow.ShowDialog(); break; } }); }
public MainViewModel() { IsSort = false; LoadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) => { if (p == null) { return; } p.Hide(); LoginWindow loginWindow = new LoginWindow(); loginWindow.ShowDialog(); if (loginWindow.DataContext == null) { return; } var loginVM = loginWindow.DataContext as LoginViewModel; if (loginVM.IsLogin) { p.Show(); LoadTonKhoData(); name = loginVM.UserNames; } else { p.Close(); } } ); UnitCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UnitWindow wd = new UnitWindow(); UnitViewModel vm = new UnitViewModel(); wd.DataContext = vm; wd.ShowDialog(); }); SuplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SuplierWindow wd = new SuplierWindow(); SuplierViewModel vm = new SuplierViewModel(); wd.DataContext = vm; wd.ShowDialog(); }); CustomerCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CustomerWindow wd = new CustomerWindow(); CustomerViewModel vm = new CustomerViewModel(); wd.DataContext = vm; wd.ShowDialog(); }); ObjectCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ObjectWindow wd = new ObjectWindow(); ObjectViewModel vm = new ObjectViewModel(); wd.DataContext = vm; wd.ShowDialog(); }); UserCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { UserWindow wd = new UserWindow(); UserViewModel vm = new UserViewModel(); wd.DataContext = vm; wd.ShowDialog(); }); InputCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { InputWindow wd = new InputWindow(); InputViewModel vm = new InputViewModel(); wd.DataContext = vm; wd.ShowDialog(); }); OutputCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { OutputWindow wd = new OutputWindow(); OutputViewModel vm = new OutputViewModel(); wd.DataContext = vm; wd.ShowDialog(); }); UpdateCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { LoadTonKhoData(); }); ExportExcelCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { ExportExcel(); }); SearchCommand = new RelayCommand <TextBox>((p) => { return(true); }, (p) => { CollectionViewSource.GetDefaultView(TonKhoList).Refresh(); }); timkiemCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(TonKhoList); view.Filter = UserFilter; }); #region Sort SortDisplaynameCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { //lấy ra danh sách tồn kho đang hiển thị CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(TonKhoList); if (IsSort) { //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Descending)); view.SortDescriptions.Clear(); //xóa sắp xếp cũ để thực hiện lại việc sắp xếp view.SortDescriptions.Add(new SortDescription("Object.DisplayName", ListSortDirection.Ascending)); // thực hiện việc sắp xếp tăng dần } else { //view.SortDescriptions.Remove(new SortDescription("Object.DisplayName", ListSortDirection.Ascending)); view.SortDescriptions.Clear(); view.SortDescriptions.Add(new SortDescription("Object.DisplayName", ListSortDirection.Descending)); } IsSort = !IsSort; }); SortCountCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(TonKhoList); if (IsSort) { //view.SortDescriptions.Remove(new SortDescription("Count", ListSortDirection.Descending)); view.SortDescriptions.Clear(); view.SortDescriptions.Add(new SortDescription("Count", ListSortDirection.Ascending)); } else { //view.SortDescriptions.Remove(new SortDescription("Count", ListSortDirection.Ascending)); view.SortDescriptions.Clear(); view.SortDescriptions.Add(new SortDescription("Count", ListSortDirection.Descending)); } IsSort = !IsSort; }); STTCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(TonKhoList); if (IsSort) { //view.SortDescriptions.Remove(new SortDescription("Count", ListSortDirection.Descending)); view.SortDescriptions.Clear(); view.SortDescriptions.Add(new SortDescription("STT", ListSortDirection.Ascending)); } else { //view.SortDescriptions.Remove(new SortDescription("Count", ListSortDirection.Ascending)); view.SortDescriptions.Clear(); view.SortDescriptions.Add(new SortDescription("STT", ListSortDirection.Descending)); } IsSort = !IsSort; }); #endregion }