Beispiel #1
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            int flat_hv;
            int flat_dk;
            int flat_dkcn = 0;

            //update dữ liệu trong bản học viên
            if (rdNam.Checked)
            {
                if (cbxTinhTrang.Text == "Còn Học")
                {
                    flat_hv = hv.update(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), txtMaHV.Text, txtHoTen.Text, 1, txtDiaChi.Text, txtSDT.Text, txtEmail.Text, dtNgayDK.Value, 1, dtNgaySinh.Value);
                }

                else
                {
                    flat_hv = hv.update(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), txtMaHV.Text, txtHoTen.Text, 1, txtDiaChi.Text, txtSDT.Text, txtEmail.Text, dtNgayDK.Value, 0, dtNgaySinh.Value);
                }
            }
            else
            {
                if (cbxTinhTrang.Text == "Còn Học")
                {
                    flat_hv = hv.update(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), txtMaHV.Text, txtHoTen.Text, 0, txtDiaChi.Text, txtSDT.Text, txtEmail.Text, dtNgayDK.Value, 1, dtNgaySinh.Value);
                }

                else
                {
                    flat_hv = hv.update(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), txtMaHV.Text, txtHoTen.Text, 0, txtDiaChi.Text, txtSDT.Text, txtEmail.Text, dtNgayDK.Value, 0, dtNgaySinh.Value);
                }
            }

            //update bảng đăng ký
            flat_dk = dk.delete(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), txtMaHV.Text, malop_phu);
            if (flat_dk == 1)
            {
                flat_dkcn = dk.insert(AccountHelper.getAccountId(), AccountHelper.getAccoutPassword(), cbxLopHoc.Text, txtMaHV.Text);
            }
            else
            {
                DialogHelper.ExtendedShowErrorDialog("Cập nhât không thành công", "", 1, 1);
            }



            if (flat_hv == 1 && flat_dkcn == 1)
            {
                Load_HV();
                DialogHelper.ExtendedShowErrorDialog("Cập nhật thành công", "", 1, 2);
            }
            else
            {
                Load_HV();
                DialogHelper.ExtendedShowErrorDialog("Cập nhật không thành công", "", 1, 1);
            }


            XoaText();
            EditButton(true, false, false, false);
            this.Cursor = Cursors.Arrow;
        }