Exemple #1
0
        private void can_Back_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            this.Hide();
            ViewWareHouse ViewWare = new ViewWareHouse();

            ViewWare.Show();
        }
        private void can_WareHouse_MouseDown(object sender, MouseButtonEventArgs e)
        {
            main            = new MainWindow();
            main.Visibility = Visibility.Collapsed;
            ViewWareHouse viewWare = new ViewWareHouse();

            viewWare.can_Delete.Visibility          = Visibility.Collapsed;
            viewWare.can_AddWarehouse.Visibility    = Visibility.Collapsed;
            viewWare.can_UpdateWarehouse.Visibility = Visibility.Collapsed;
            viewWare.can_btn.Visibility             = Visibility.Collapsed;
            viewWare.Btn_Close.Visibility           = Visibility.Collapsed;
            viewWare.can_Back.Visibility            = Visibility.Visible;
            viewWare.ShowDialog();
        }
        private void can_btn_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            connect = new CTUConnection();

            if (cmbx_Department.SelectedIndex == 0)
            {
                main = new MainWindow();
                connect.LoginAccountEmployee(Txt_Username.Text, Txt_Password.Password, int.Parse(cmbx_Department.SelectedValue.ToString()));
                main.Btn_Motorcycle.Visibility  = Visibility.Collapsed;
                main.Btn_OldVehicles.Visibility = Visibility.Collapsed;
                main.Btn_Parts.Visibility       = Visibility.Collapsed;
                main.Btn_Service.Visibility     = Visibility.Collapsed;
                Department      = 1;
                main.Department = Department;

                if (connect.Count == 1)
                {
                    if (connect.table.Rows[0][7].ToString() == "1")
                    {
                        main.TxtBlk_Department.Text = string.Format("New vehicle department (Administrator)");
                        RoleType      = "Administrator";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "2")
                    {
                        main.TxtBlk_Department.Text = string.Format("New vehicle department (Manager)");
                        RoleType      = "Manager";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "3")
                    {
                        main.TxtBlk_Department.Text = string.Format("New vehicle department (SalesMan)");
                        RoleType      = "SalesMan";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "4")
                    {
                        main.TxtBlk_Department.Text = string.Format("New vehicle department (Mechanic)");
                        RoleType      = "Mechanic";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "5")
                    {
                        main.TxtBlk_Department.Text = string.Format("New vehicle department (Surbordinate)");
                        RoleType      = "Surbordinate";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }
                }
            }

            else if (cmbx_Department.SelectedIndex == 1)
            {
                main = new MainWindow();
                connect.LoginAccountEmployee(Txt_Username.Text, Txt_Password.Password, int.Parse(cmbx_Department.SelectedValue.ToString()));
                main.Btn_Motorcycle.Visibility  = Visibility.Collapsed;
                main.Btn_NewVehicles.Visibility = Visibility.Collapsed;
                main.Btn_Parts.Visibility       = Visibility.Collapsed;
                main.Btn_Service.Visibility     = Visibility.Collapsed;
                Department      = 2;
                main.Department = Department;

                if (connect.Count == 1)
                {
                    if (connect.table.Rows[0][7].ToString() == "1")
                    {
                        main.TxtBlk_Department.Text = string.Format("Used/demo vehicle department (Administrator)");
                        RoleType      = "Administrator";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "2")
                    {
                        main.TxtBlk_Department.Text = string.Format("Used/demo vehicle department (Manager)");
                        RoleType      = "Manager";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "3")
                    {
                        main.TxtBlk_Department.Text = string.Format("Used/demo vehicle department (SalesMan)");
                        RoleType      = "SalesMan";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "4")
                    {
                        main.TxtBlk_Department.Text = string.Format("Used/demo vehicle department (Mechanic)");
                        RoleType      = "Mechanic";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "5")
                    {
                        main.TxtBlk_Department.Text = string.Format("Used/demo vehicle department (Surbordinate)");
                        RoleType      = "Surbordinate";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }
                }
            }

            else if (cmbx_Department.SelectedIndex == 2)
            {
                main = new MainWindow();
                connect.LoginAccountEmployee(Txt_Username.Text, Txt_Password.Password, int.Parse(cmbx_Department.SelectedValue.ToString()));
                main.Btn_Motorcycle.Visibility  = Visibility.Collapsed;
                main.Btn_OldVehicles.Visibility = Visibility.Collapsed;
                main.Btn_Parts.Visibility       = Visibility.Collapsed;
                main.Btn_NewVehicles.Visibility = Visibility.Collapsed;
                main.Btn_TestDrive.Visibility   = Visibility.Collapsed;
                Department      = 3;
                main.Department = Department;

                if (connect.Count == 1)
                {
                    if (connect.table.Rows[0][7].ToString() == "1")
                    {
                        main.TxtBlk_Department.Text = string.Format("Service department (Administrator)");
                        RoleType      = "Administrator";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "2")
                    {
                        main.TxtBlk_Department.Text = string.Format("Service department (Manager)");
                        RoleType      = "Manager";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "3")
                    {
                        main.TxtBlk_Department.Text = string.Format("Service department (SalesMan)");
                        RoleType      = "SalesMan";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "4")
                    {
                        main.TxtBlk_Department.Text = string.Format("Service department (Mechanic)");
                        RoleType      = "Mechanic";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "5")
                    {
                        main.TxtBlk_Department.Text = string.Format("Service department (Surbordinate)");
                        RoleType      = "Surbordinate";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }
                }
            }

            else if (cmbx_Department.SelectedIndex == 3)
            {
                main = new MainWindow();
                connect.LoginAccountEmployee(Txt_Username.Text, Txt_Password.Password, int.Parse(cmbx_Department.SelectedValue.ToString()));
                main.Btn_Motorcycle.Visibility  = Visibility.Collapsed;
                main.Btn_OldVehicles.Visibility = Visibility.Collapsed;
                main.Btn_NewVehicles.Visibility = Visibility.Collapsed;
                main.Btn_Service.Visibility     = Visibility.Collapsed;
                main.Btn_TestDrive.Visibility   = Visibility.Collapsed;
                Department      = 4;
                main.Department = Department;

                if (connect.Count == 1)
                {
                    if (connect.table.Rows[0][7].ToString() == "1")
                    {
                        main.TxtBlk_Department.Text = string.Format("Parts department (Administrator)");
                        RoleType      = "Administrator";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "2")
                    {
                        main.TxtBlk_Department.Text = string.Format("Parts department (Manager)");
                        RoleType      = "Manager";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "3")
                    {
                        main.TxtBlk_Department.Text = string.Format("Parts department (SalesMan)");
                        RoleType      = "SalesMan";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "4")
                    {
                        main.TxtBlk_Department.Text = string.Format("Parts department (Mechanic)");
                        RoleType      = "Mechanic";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "5")
                    {
                        main.TxtBlk_Department.Text = string.Format("Parts department (Surbordinate)");
                        RoleType      = "Surbordinate";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }
                }
            }

            else if (cmbx_Department.SelectedIndex == 4)
            {
                main = new MainWindow();
                connect.LoginAccountEmployee(Txt_Username.Text, Txt_Password.Password, int.Parse(cmbx_Department.SelectedValue.ToString()));
                main.Btn_NewVehicles.Visibility = Visibility.Collapsed;
                main.Btn_OldVehicles.Visibility = Visibility.Collapsed;
                main.Btn_Parts.Visibility       = Visibility.Collapsed;
                main.Btn_Service.Visibility     = Visibility.Collapsed;
                main.Btn_TestDrive.Visibility   = Visibility.Collapsed;
                main.Btn_Invoice.Visibility     = Visibility.Collapsed;
                Department      = 5;
                main.Department = Department;


                if (connect.Count == 1)
                {
                    if (connect.table.Rows[0][7].ToString() == "1")
                    {
                        main.TxtBlk_Department.Text = string.Format("Motorcycle department (Administrator)");
                        RoleType      = "Administrator";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "2")
                    {
                        main.TxtBlk_Department.Text = string.Format("Motorcycle department (Manager)");
                        RoleType      = "Manager";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "3")
                    {
                        main.TxtBlk_Department.Text = string.Format("Motorcycle department (SalesMan)");
                        RoleType      = "SalesMan";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "4")
                    {
                        main.TxtBlk_Department.Text = string.Format("Motorcycle department (Mechanic)");
                        RoleType      = "Mechanic";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "5")
                    {
                        main.TxtBlk_Department.Text = string.Format("Motorcycle department (Surbordinate)");
                        RoleType      = "Surbordinate";
                        main.RoleType = RoleType;
                        this.Hide();
                        main.ShowDialog();
                    }
                }
            }

            else if (cmbx_Department.SelectedIndex == 5)
            {
                Viewware = new ViewWareHouse();
                connect.LoginAccountEmployee(Txt_Username.Text, Txt_Password.Password, int.Parse(cmbx_Department.SelectedValue.ToString()));
                Department          = 6;
                Viewware.Department = Department;


                if (connect.Count == 1)
                {
                    if (connect.table.Rows[0][7].ToString() == "1")
                    {
                        RoleType          = "Administrator";
                        Viewware.RoleType = RoleType;
                        this.Hide();
                        Viewware.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "2")
                    {
                        RoleType          = "Manager";
                        Viewware.RoleType = RoleType;
                        this.Hide();
                        Viewware.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "3")
                    {
                        RoleType          = "SalesMan";
                        Viewware.RoleType = RoleType;
                        this.Hide();
                        Viewware.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "4")
                    {
                        RoleType          = "Mechanic";
                        Viewware.RoleType = RoleType;
                        this.Hide();
                        Viewware.ShowDialog();
                    }

                    else if (connect.table.Rows[0][7].ToString() == "5")
                    {
                        RoleType          = "Surbordinate";
                        Viewware.RoleType = RoleType;
                        this.Hide();
                        Viewware.ShowDialog();
                    }
                }
            }
        }