private void btnHuy_Click(object sender, EventArgs e)
        {
            this.Hide();
            FTaiKhoan fuser = new FTaiKhoan();

            fuser.MdiParent = main;
            fuser.main      = main;
            fuser.Show();
        }
Exemplo n.º 2
0
        private void tàiKhoảnToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form form = CheckTonTai(typeof(FTaiKhoan));

            if (form != null)
            {
                form.Activate();
            }
            else
            {
                FTaiKhoan newform = new FTaiKhoan();
                newform.MdiParent = this;
                newform.main      = this;
                newform.Show();
            }
        }
        private void btnThucHien_Click(object sender, EventArgs e)
        {
            if (labTacVu.Text == "Thêm")
            {
                if (txtUserName.Text != "")
                {
                    if (txtPass.Text != "")
                    {
                        if (cbxQuyen.Text != "")
                        {
                            try
                            {
                                User.UserName  = txtUserName.Text;
                                User.Password  = txtPass.Text;
                                User.PhanQuyen = cbxQuyen.Text;
                                if (labMaNV.Text == "---")
                                {
                                    User.MaNV = labMaNV.Text;
                                }
                                Act.AddUser(User);
                                MessageBox.Show("Đã thêm Thành Công", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.ToString(), "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Quyền không được để trống", "Chú Ý", MessageBoxButtons.OK);
                            cbxQuyen.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Password không được để trống", "Chú Ý", MessageBoxButtons.OK);
                        txtPass.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Username không được để trống", "Chú Ý", MessageBoxButtons.OK);
                    txtUserName.Focus();
                }
            }
            else if (labTacVu.Text == "Sửa")
            {
                if (txtPass.Text != "")
                {
                    if (cbxQuyen.Text != "")
                    {
                        try
                        {
                            User.UserName  = txtUserName.Text;
                            User.Password  = txtPass.Text;
                            User.PhanQuyen = cbxQuyen.Text;
                            if (labMaNV.Text != "---")
                            {
                                User.MaNV = labMaNV.Text;
                            }

                            Act.UpdateUser(User);
                            MessageBox.Show("Đã sửa Thành Công", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString(), "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Quyền không được để trống", "Chú Ý", MessageBoxButtons.OK);
                        cbxQuyen.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Password không được để trống", "Chú Ý", MessageBoxButtons.OK);
                    txtPass.Focus();
                }
            }
            else
            {
                try
                {
                    User.UserName  = txtUserName.Text;
                    User.Password  = txtPass.Text;
                    User.PhanQuyen = cbxQuyen.Text;
                    if (labMaNV.Text == "---")
                    {
                        User.MaNV = labMaNV.Text;
                    }
                    Act.DeleteUser(User);
                    MessageBox.Show("Đã xóa Thành Công", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString(), "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            this.Hide();
            FTaiKhoan fuser = new FTaiKhoan();

            fuser.MdiParent = main;
            fuser.main      = main;
            fuser.Show();

            //foreach (Form f in MainForm.MdiChildren)
            //{
            //    if (f.GetType() == typeof(FTaiKhoan))
            //    {
            //        f.Activate();
            //        break;
            //    }
            //}
        }