Exemplo n.º 1
0
 public VMloginClient()
 {
     btn = new btn();
     CloseLoginClient = new RelayCommand <object>(p => { return(true); }, p => {
         VMmain.MainWindow.Visibility = System.Windows.Visibility.Visible;
     });
 }
Exemplo n.º 2
0
        void initialization()
        {
            btn            = new btn();
            GetMainWindow  = new RelayCommand <object>(p => { return(true); }, p => { MainWindow = p as Window; });
            ShowControlBar = new RelayCommand <object>(p => { return(true); }, p => { if ((p as ControlBar_z).Opacity != 100)
                                                                                      {
                                                                                          (p as ControlBar_z).Opacity = 99;
                                                                                      }
                                                       });
            HideControlBar = new RelayCommand <object>(p => { return(true); }, p => { if ((p as ControlBar_z).Opacity != 100)
                                                                                      {
                                                                                          (p as ControlBar_z).Opacity = 0;
                                                                                      }
                                                       });
            GetControlBar = new RelayCommand <object>(p => { return(true); }, p => { ControlBar = (p as ControlBar_z); });

            GetContentMainWindow = new RelayCommand <object>(p => { return(true); }, p => { ContentMainWindow = p as ContentControl; });
            OpenLoginClient      = new RelayCommand <object>(p => { return(true); }, p =>
            {
                MainWindow.Visibility   = Visibility.Collapsed;
                LoginClient loginClient = new LoginClient();
                loginClient.ShowDialog();
                //MainWindow.Visibility = Visibility.Visible;
            });

            OpenWindowAdministration = new RelayCommand <object>(p => { return(true); }, p =>
            {
                MainWindow.Visibility = Visibility.Collapsed;
                Login login           = new Login(); login.ShowDialog();
            });
            OpenSetting            = new RelayCommand <object>(p => { return(true); }, p => { var a = new settingdata(); a.ShowDialog(); });
            changeConnectionString = new RelayCommand <object>(p => { return(true); }, p => { connectionString = strConnect; });
            CheckConnectionString  = new RelayCommand <object>(p => { return(true); }, p =>
            {
                try
                {
                    var connection = new MySqlConnection(strConnect);
                    connection.Open();
                    MessageBox.Show("kết Nối Database thành công");
                    connection.Close();
                }
                catch
                {
                    MessageBox.Show("Kết nối thất bại!,xin tra lại connection string");
                }
            });
            CloseMainWindow = new RelayCommand <object>(p => { return(true); }, p => { Application.Current.Shutdown(); });
        }
Exemplo n.º 3
0
        void initialization()
        {
            btn = new btn();
            newAdministration = new Administration();
            userNameSignIn    = "gamoet1";
            connectionString  = VMmain.connectionString;
            connectionString  = @"server=127.0.0.1;database=gamo;user id=root;password=22022000;port=3306";
            ShowMainWindow    = new RelayCommand <object>(p => { return(true); }, p => { if (VMmain.MainWindow != null)
                                                                                         {
                                                                                             VMmain.MainWindow.Visibility = Visibility.Visible;
                                                                                         }
                                                          });
            GetPasswordSignIn  = new RelayCommand <PasswordBox>(p => { return(true); }, p => { passwordSignIn = p; });
            GetPasswordSignUp  = new RelayCommand <PasswordBox>(p => { return(true); }, p => { passwordSignUp = p; });
            GetRPasswordSignUp = new RelayCommand <PasswordBox>(p => { return(true); }, p => { RPasswordSignUP = p; });
            SignIn             = new RelayCommand <object>(p => { return(true); }, p =>
            {
                var a = loginIsSignIn(connectionString, TableName.Administration);
                if (a)
                {
                    if (VMmain.MainWindow != null)
                    {
                        var content  = new Content_z();
                        var vm       = content.DataContext as VMcontent_z;
                        vm.HideAdmin = Visibility.Visible;
                        vm.HideUser  = Visibility.Collapsed;
                        VMmain.ContentMainWindow.Content = content;

                        VMmain.ControlBar.Opacity = 100;
                        (p as Login).Close();
                    }
                }
            });
            SignUp = new RelayCommand <object>(p => { return(true); }, p => { loginIssignUp(connectionString, TableName.Administration); });
            ClearNewAdministration = new RelayCommand <object>(p => { return(true); }, p => {
                warning = "";
                OnPropertyChanged("warning");
                newAdministration.ClearData(); OnPropertyChanged("newAdministration");
            });
        }
Exemplo n.º 4
0
        void InitializeComponent()
        {
            // str = VMmain.connectionString;
            AdminName   = "gamoet1";
            btn         = new btn();
            newItemz    = new Itemz();// khởi tạo đầu tiên
            itemDisplay = new Itemz();
            {
                ListItem = new ObservableCollection <Itemz>();
                CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(ListItem);
                view.Filter = UserFilter;
            }

            DeletePathImageItem = new RelayCommand <object>(p => { return(true); }, p => { DeleteFilePathImage(AdminName, TableName.historyOfData, TypeDIU.Delete, str); });
            OpenCreateItem      = new RelayCommand <object>(p => { return(true); }, p => { warning = ""; OnPropertyChanged("warning"); });
            LoadDefaultListItem = new RelayCommand <object>(p => { return(true); }, p => { UpdateListItem(AdminName, TableName.Saltyfood, str); DefaultDisplayItems(); });
            GetComboBox         = new RelayCommand <object>(p => { return(true); }, p =>
            {
                TypeOfItem = p as ComboBox;
                //UpdateDataListItem("saltyfood", str); // mặc đinh load đồ ăn mặn
            });
            SearchOfNameItem = new RelayCommand <object>(p => { return(true); }, p => { CollectionViewSource.GetDefaultView(ListItem).Refresh(); });
            SelectItem       = new RelayCommand <ListView>(p => { return(true); }, p =>
            {
                if (p.SelectedItem != null)
                {
                    DisplayItems(p.SelectedItem as Itemz);
                }
            });

            OpenDialogImageCreateItem = new RelayCommand <object>(p => { return(true); }, p =>
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == true)
                {
                    newItemz.pathImage = openFileDialog.FileName;
                    OnPropertyChanged("newItemz");
                }
            });
            OpenDialogImageEditItem = new RelayCommand <object>(p => { return(true); }, p =>
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                if (openFileDialog.ShowDialog() == true)
                {
                    itemDisplay.pathImage = openFileDialog.FileName;
                    OnPropertyChanged("itemDisplay");
                }
            });


            CommandCreateItem = new RelayCommand <object>(p => { return(true); }, p =>
            {
                if (TypeOfItem.SelectedIndex == 0)
                {
                    CreateItem(AdminName, TableName.Saltyfood, str);
                    // DefaultDisplayItems();
                }
                else if (TypeOfItem.SelectedIndex == 1)
                {
                    CreateItem(AdminName, TableName.Desserts, str);
                    //DefaultDisplayItems();
                }
                else if (TypeOfItem.SelectedIndex == 2)
                {
                    CreateItem(AdminName, TableName.Drink, str);
                    //DefaultDisplayItems();
                }
            });
            //OpenCreateItem = new RelayCommand<object>(p => { return true; }, p => { });
            CloseViewCreateItem = new RelayCommand <object>(p => { return(true); }, p =>
            {
                newItemz.id = newItemz.namez = newItemz.price = newItemz.sale
                                                                    = newItemz.information = newItemz.timeLine = newItemz.repaiTime = newItemz.pathImage = null;
                OnPropertyChanged("newItemz");
            });


            UpdateDataOfEditItem = new RelayCommand <object>(p => { return(true); }, p =>
            {
                var a = p as ListView;
                if (itemDisplay.id == "unknow")
                {
                    MessageBox.Show("không có dữ liệu để cập nhập"); DefaultDisplayItems();
                }
                else if (TypeOfItem.SelectedIndex == 0)
                {
                    EditItem(AdminName, TableName.Saltyfood, str);
                }
                else if (TypeOfItem.SelectedIndex == 1)
                {
                    EditItem(AdminName, TableName.Desserts, str);
                }
                else if (TypeOfItem.SelectedIndex == 2)
                {
                    EditItem(AdminName, TableName.Drink, str);
                }
            });


            SelectDispalayListItem = new RelayCommand <object>(p => { return(true); }, p =>
            {
                if (TypeOfItem.SelectedIndex == 0)
                {
                    UpdateListItem(AdminName, TableName.Saltyfood, str);
                    DefaultDisplayItems();
                }
                else if (TypeOfItem.SelectedIndex == 1)
                {
                    UpdateListItem(AdminName, TableName.Desserts, str);
                    DefaultDisplayItems();
                }
                else if (TypeOfItem.SelectedIndex == 2)
                {
                    UpdateListItem(AdminName, TableName.Drink, str);
                    DefaultDisplayItems();
                }
            });

            DeleteOneItem = new RelayCommand <object>(p => { return(true); }, p =>
            {
                if (TypeOfItem.SelectedIndex == 0)
                {
                    DeleteItem(AdminName, TableName.Saltyfood, str, itemDisplay);
                }
                else if (TypeOfItem.SelectedIndex == 1)
                {
                    DeleteItem(AdminName, TableName.Desserts, str, itemDisplay);
                }
                else if (TypeOfItem.SelectedIndex == 2)
                {
                    DeleteItem(AdminName, TableName.Drink, str, itemDisplay);
                }
            });
        }