Пример #1
0
        // Метод открытия окон, в зависимости от типа аккаунта
        public static bool OpenWindow(Accounts Acc)
        {
            // Если аккаунт не пустой, то открой окно
            if (Acc != null)
            {
                Window wind; // Окно

                // Если аккаунт администратор, то открой окно администратора
                if (Acc.idStatus == 2)
                {
                    wind = new AdminWindow();
                    wind.Show();

                    return(true);
                }
                // Если аккаунт рабочего, то открой окно рабочего
                else if (Acc.idStatus == 1)
                {
                    wind = new SellerWindow();
                    wind.Show();

                    return(true);
                }
            }

            return(false); // В случае, если не удалось открыть окно
        }
        private void login_Click(object sender, RoutedEventArgs e)
        {
            string       name     = username.Text;
            string       passwd   = password.Password;
            IEmployeeDao dao      = new EmployeeDao();
            Employee     employee = dao.getEmployeeWithPasswd(name, passwd);

            if (employee == null)
            {
                MessageBox.Show("账号名或密码不正确");
                return;
            }
            string identity = employee.Identity;

            if (identity == "经理")
            {
                MainManager manager = new MainManager(employee);
                manager.Show();
            }
            else if (identity == "采购员")
            {
                BuyerWindow buyer = new BuyerWindow(employee);
                buyer.Show();
            }
            else if (identity == "收银员")
            {
                SellerWindow sell = new SellerWindow(employee);
                sell.Show();
            }
            else if (identity == "移货员")
            {
                MoverWindow mover = new MoverWindow(employee);
                mover.Show();
            }

            this.Close();
        }