Esempio n. 1
0
        private void btn_Luu_Click(object sender, EventArgs e)
        {
            string a;

            if (radioButtonNhanVien.Checked == true)
            {
                a = "Nhân Viên";
            }
            else
            {
                a = "Quản Lí";
            }

            if (Them)
            {
                try
                {
                    qltk.ThemTK(txtMaNhanVien.Text, txtTenDN.Text, txtMK.Text, a, cbbTrangThai.Text);
                    loaddata();
                    qltk.LayThongTin(dataGridViewTaiKhoan);
                    MessageBox.Show("Đã thêm xong");
                }
                catch
                {
                    MessageBox.Show("lỗi");
                }
            }
            else
            {
                if (txtMK.Text == qltk.LayMK(txtTenDN.Text))
                {
                    try
                    {
                        qltk.SuaTK2(txtMaNhanVien.Text, txtTenDN.Text, a, cbbTrangThai.Text);
                        loaddata();
                        qltk.LayThongTin(dataGridViewTaiKhoan);
                        MessageBox.Show("Đã thêm xong");
                    }
                    catch
                    {
                        MessageBox.Show("lỗi");
                    }
                }
                else
                {
                    try
                    {
                        qltk.SuaTK(txtMaNhanVien.Text, txtTenDN.Text, txtMK.Text, a, cbbTrangThai.Text);
                        loaddata();
                        qltk.LayThongTin(dataGridViewTaiKhoan);
                        MessageBox.Show("Đã thêm xong");
                    }
                    catch
                    {
                        MessageBox.Show("lỗi");
                    }
                }
            }
        }