private void btnWork_Click(object sender, EventArgs e)
        {
            //string typeTho = this.lbTypeTho.Text.Trim();
            //if (typeTho == "Bảo Vệ" || typeTho == "Thợ Sửa" || typeTho == "Thợ Rửa")
            //{
            //    fQuanLyXe form = new fQuanLyXe();
            //    this.Hide();
            //    form.ShowDialog();
            //    this.Show();
            //}
            //else
            //{
            //    fMain form = new fMain();
            //    this.Hide();
            //    form.ShowDialog();
            //    this.Show();
            //}
            fMain form = new fMain();

            this.Hide();
            form.ShowDialog();
            this.Show();
            //{
            //    //form.btnDoanhThu.Enabled = false;
            //    form.btnFixService.Enabled = false;
            //    form.btnWashService.Enabled = false;
            //}
            //else if (this.lbTypeTho.Text.Trim() == "Thợ Sửa")
            //{
            //    form.btnParkService.Enabled = false;
            //    //form.btnDoanhThu.Enabled = false;
            //    form.btnWashService.Enabled = false;
            //}
            //else /*if (this.lbTypeTho.Text.Trim() == "Thợ Rửa")*/
            //{
            //    form.btnParkService.Enabled = false;
            //    //form.btnDoanhThu.Enabled = false;
            //    form.btnFixService.Enabled = false;
            //}
        }
Exemplo n.º 2
0
        private void btnLog_Click(object sender, EventArgs e)
        {
            if (this.txtUser.Text == "" || this.txtPass.Text == "")
            {
                MessageBox.Show("Invalid Username or Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (this.rbBaoVe.Checked == false && this.rbThoSuaXe.Checked == false && this.rbThoRuaXe.Checked == false &&
                    this.rbNhanVien.Checked == false && this.rbDev.Checked == false && this.rbGiamDoc.Checked == false)
                {
                    MessageBox.Show("Please choose your roll", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    string username = this.txtUser.Text.Trim();
                    string password = this.txtPass.Text.Trim();
                    if (this.rbDev.Checked == true || this.rbGiamDoc.Checked == true)
                    {
                        AccountDTO acc = new AccountDTO(0, this.txtUser.Text, this.txtPass.Text);

                        if (this.accBUS.loginAccount(acc))
                        {
                            Global.SetGlobalEmployeeType(4);
                            this.txtUser.Text = "";
                            this.txtPass.Text = "";
                            fMain form = new fMain();
                            this.Hide();
                            form.ShowDialog();
                            this.Show();
                        }
                        else
                        {
                            MessageBox.Show("Invalid Username or Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else if (this.rbBaoVe.Checked == true)
                    {
                        DataTable table = this.nhanVienBaoVeBUS.VerifyLogin(username, password);

                        if (table != null)
                        {
                            this.txtUser.Text = "";
                            this.txtPass.Text = "";

                            string id = table.Rows[0][0].ToString().Trim();
                            if (this.checkShift("Bảo Vệ", id))
                            {
                                Global.SetGlobalEmployeeId(id);
                                if (this.ChamCong() == 1)
                                {
                                    if (bool.Parse(table.Rows[0][3].ToString()) == true)
                                    {
                                        Global.SetGlobalEmployeeType(5);
                                    }
                                    else
                                    {
                                        Global.SetGlobalEmployeeType(0);
                                    }
                                    fWelcome form = new fWelcome(this.status);
                                    this.Hide();
                                    form.ShowDialog();
                                    this.Show();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Chưa đến ca của bạn. Vui lòng làm việc đúng giờ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Invalid Username or Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else if (this.rbThoSuaXe.Checked == true)
                    {
                        DataTable table = this.nhanVienSuaXeBUS.VerifyLogin(username, password);

                        if (table != null)
                        {
                            this.txtUser.Text = "";
                            this.txtPass.Text = "";

                            string id = table.Rows[0][0].ToString().Trim();
                            if (this.checkShift("Thợ Sửa", id))
                            {
                                Global.SetGlobalEmployeeId(id);
                                if (this.ChamCong() == 1)
                                {
                                    if (bool.Parse(table.Rows[0][3].ToString()) == true)
                                    {
                                        Global.SetGlobalEmployeeType(6);
                                    }
                                    else
                                    {
                                        Global.SetGlobalEmployeeType(1);
                                    }

                                    fWelcome form = new fWelcome(this.status);
                                    this.Hide();
                                    form.ShowDialog();
                                    this.Show();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Chưa đến ca của bạn. Vui lòng làm việc đúng giờ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Invalid Username or Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else if (this.rbThoRuaXe.Checked == true)
                    {
                        DataTable table = this.nhanVienRuaXeBUS.VerifyLogin(username, password);

                        if (table != null)
                        {
                            this.txtUser.Text = "";
                            this.txtPass.Text = "";

                            string id = table.Rows[0][0].ToString().Trim();

                            if (this.checkShift("Thợ Rửa", id))
                            {
                                Global.SetGlobalEmployeeId(id);
                                if (this.ChamCong() == 1)
                                {
                                    if (bool.Parse(table.Rows[0][3].ToString()) == true)
                                    {
                                        Global.SetGlobalEmployeeType(7);
                                    }
                                    else
                                    {
                                        Global.SetGlobalEmployeeType(2);
                                    }

                                    fWelcome form = new fWelcome(this.status);
                                    this.Hide();
                                    form.ShowDialog();
                                    this.Show();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Chưa đến ca của bạn. Vui lòng làm việc đúng giờ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Invalid Username or Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else if (this.rbNhanVien.Checked == true)
                    {
                        DataTable table = this.nhanVienHopDongBUS.VerifyLogin(username, password);
                        //this.ChamCong();
                        if (table != null)
                        {
                            this.txtUser.Text = "";
                            this.txtPass.Text = "";

                            string id = table.Rows[0][0].ToString().Trim();

                            if (this.checkShift("Nhân Viên", id))
                            {
                                Global.SetGlobalEmployeeId(id);
                                if (this.ChamCong() == 1)
                                {
                                    if (bool.Parse(table.Rows[0][3].ToString()) == true)
                                    {
                                        Global.SetGlobalEmployeeType(8);
                                    }
                                    else
                                    {
                                        Global.SetGlobalEmployeeType(3);
                                    }

                                    fWelcome form = new fWelcome(this.status);
                                    this.Hide();
                                    form.ShowDialog();
                                    this.Show();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Chưa đến ca của bạn. Vui lòng làm việc đúng giờ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Invalid Username or Password", "Login Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }