Exemplo n.º 1
0
        private void Staff_Clicked(object sender, RoutedEventArgs e)
        {
            this.Hide();
            StaffWindow staffWindow = new StaffWindow(this);

            staffWindow.Show();
        }
Exemplo n.º 2
0
        // mọi thứ xử lý sẽ nằm trong này
        public MainViewModel()
        {
            //mở các window
            loadedWindowCommand = new RelayCommand <Window>((p) => { return(true); }, (p) =>
            {
                isLoginLoaded = true;
                if (p == null)
                {
                    return;
                }
                p.Hide();
                LoginWindow loginWindow = new LoginWindow();
                loginWindow.ShowDialog();

                if (loginWindow.DataContext == null)
                {
                    return;
                }
                //lấy quyền truy cập
                var loginVM = loginWindow.DataContext as LoginViewModel;
                level       = loginVM.level;
                if (loginVM.isLogin)
                {
                    p.Show();
                }
                else
                {
                    p.Close();
                }
                p.Show();
            });
            goodsCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                var w = new GoodsWindow();
                w.ShowDialog();
            });
            staffCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                if (true == level)
                {
                    var w = new StaffWindow();
                    w.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Bạn không có quyền truy cập mục này!");
                }
            });
            supplierCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                var w = new SupplierWindow();
                w.ShowDialog();
            });
            customerCommand = new RelayCommand <object>((p) => { return(true); }, (p) =>
            {
                var w = new CustomerWindow();
                w.ShowDialog();
            });
        }
        private void MainLoop()
        {
            while (true)
            {
                Auth        auth;
                LoginWindow loginWindow = new LoginWindow();
                loginWindow.ShowDialog();
                Console.WriteLine(loginWindow.DialogResult);
                if (loginWindow.DialogResult == true)
                {
                    auth = loginWindow.Tag as Auth;
                    if (auth.Permission == "student")
                    {
                        StudentWindow studentWindow = new StudentWindow(auth);
                        studentWindow.ShowDialog();
                        Console.WriteLine(studentWindow.DialogResult);
                        if (studentWindow.DialogResult == true)
                        {
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }
                    else if (auth.Permission == "staff")
                    {
                        StaffWindow staffWindow = new StaffWindow(auth);
                        staffWindow.ShowDialog();
                        Console.WriteLine(staffWindow.DialogResult);
                        if (staffWindow.DialogResult == true)
                        {
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            Environment.Exit(0);
        }
Exemplo n.º 4
0
        private void StaffWindowList()
        {
            StaffWindow newStaffWindow = new StaffWindow();

            newStaffWindow.Show();
        }
Exemplo n.º 5
0
 public Window1(StaffWindow staffWindow)
 {
     InitializeComponent();
     this.staffWindow = staffWindow;
 }
Exemplo n.º 6
0
        private async void Application_Startup(object sender, StartupEventArgs e)
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            Enum.TryParse <DatabaseType>(configFile.AppSettings.Settings["DatabaseType"].Value, out var databaseType);

            SetFolderPaths(databaseType);

            switch (databaseType)
            {
            case DatabaseType.Unknown:
                SetUpDatabase();
                return;

            case DatabaseType.File:
                var result = ProvideMSAccessPassword();
                if (result == false)
                {
                    Environment.Exit(0);
                    return;
                }
                break;

            case DatabaseType.Server:
                result = CheckServerDatabase();
                if (result == false)
                {
                    Environment.Exit(0);
                    return;
                }
                break;
            }

            ConfigurationHelper.ProtectConfiguration();

            if (!Directory.Exists(ImageFolderDirectory))
            {
                MessageBox.Show("There's no network folder. Press OK to enter the setup", "No network folder", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                var window = new DatabaseSetupWindow();
                window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                window.ShowInTaskbar         = true;

                var result = window.ShowDialog();

                if (result != true)
                {
                    MessageBox.Show("You cannot use this system without a network folder", "No network folder", MessageBoxButton.OK, MessageBoxImage.Stop);
                }

                Environment.Exit(0);

                return;
            }

            if (!Directory.Exists(ImageFolderPath))
            {
                Directory.CreateDirectory(ImageFolderPath);
            }

            var userService = new UserService();
            int usersCount  = await userService.CountUsersAsync();

            if (usersCount == 0)
            {
                MessageBox.Show("No users yet. Press OK to add a superuser", "No users", MessageBoxButton.OK, MessageBoxImage.Exclamation);

                var userWindow = new StaffWindow
                {
                    PresetUserType = UserType.Superuser
                };
                userWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                userWindow.WindowStyle           = WindowStyle.ToolWindow;
                userWindow.Title         = "Add superuser";
                userWindow.ShowInTaskbar = true;

                userWindow.ShowDialog();

                usersCount = await userService.CountUsersAsync();

                if (usersCount == 0)
                {
                    MessageBox.Show("You cannot use this system without a user", "No users", MessageBoxButton.OK, MessageBoxImage.Stop);

                    Environment.Exit(0);

                    return;
                }
            }
        }
Exemplo n.º 7
0
        // mọi thứ xử lý sẽ nằm trong này
        public MainViewModel()
        {
            LoadedWindowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => {
                Isloaded = true;
                LoginWindow loginWindow = new LoginWindow();
                loginWindow.ShowDialog();
            });

            StaffCommand    = new RelayCommand <object>((p) => { return(true); }, (p) => { StaffWindow wd = new StaffWindow(); wd.ShowDialog(); });
            FoodCommand     = new RelayCommand <object>((p) => { return(true); }, (p) => { FoodWindow wd = new FoodWindow(); wd.ShowDialog(); });
            BillCommand     = new RelayCommand <object>((p) => { return(true); }, (p) => { BillWindow wd = new BillWindow(); wd.ShowDialog(); });
            FoodTypeCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { FoodTypeWindow wd = new FoodTypeWindow(); wd.ShowDialog(); });
        }