Beispiel #1
0
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();

                HocVien.Update(new HOCVIEN()
                {
                    MaHV       = txtMaHV.Text,
                    TenHV      = txtTenHV.Text,
                    GioiTinhHV = cboGioiTinh.Text,
                    NgaySinh   = dateNgaySinh.Value,
                    DiaChi     = txtDiaChi.Text,
                    SdtHV      = txtSDT.Text,
                    EmailHV    = txtEmail.Text,
                    MaLoaiHV   = hv.MaLoaiHV
                });

                MessageBox.Show("Cập nhật thông tin học viên thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();

                if (isInsert)
                {
                    HocVien.Insert(LoadHocVien(), new TAIKHOAN()
                    {
                        TenDangNhap = txtTenDangNhap.Text,
                        MatKhau     = txtMatKhau.Text,
                    });

                    InitializeHocVien();
                    MessageBox.Show("Thêm học viên thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    HocVien.Update(LoadHocVien(), new TAIKHOAN()
                    {
                        TenDangNhap = txtTenDangNhap.Text,
                        MatKhau     = txtMatKhau.Text,
                    });

                    InitializeHocVien();
                    MessageBox.Show("Sửa học viên thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnLuuPhieu_Click(object sender, EventArgs e)
        {
            try
            {
                ValidatePhieu();

                maPhieu = txtMaPhieu.Text;
                maHV    = gridDSHV.SelectedRows[0].Cells["clmMaHV"].Value.ToString();
                maKH    = ((KHOAHOC)cboKhoaHoc.SelectedValue).MaKH;
                PhieuGhiDanh.Insert(new PHIEUGHIDANH()
                {
                    MaPhieu     = maPhieu,
                    NgayGhiDanh = dateNgayGhiDanh.Value,
                    DaDong      = numDaDong.Value,
                    ConNo       = numConNo.Value,
                    MaNV        = GlobalSettings.UserID,

                    DANGKies = new DANGKY()
                    {
                        MaHV    = maHV,
                        MaKH    = maKH,
                        MaPhieu = maPhieu
                    }
                });

                MessageBox.Show(string.Format("Phiếu ghi danh {0} đã được thêm thành công", maPhieu), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                var h = HocVien.Select(maHV);
                if (h.MaLoaiHV == "LHV00")
                {
                    HocVien.Update(new HOCVIEN()
                    {
                        MaHV         = h.MaHV,
                        TenHV        = h.TenHV,
                        GioiTinhHV   = h.GioiTinhHV,
                        NgaySinh     = h.NgaySinh,
                        DiaChi       = h.DiaChi,
                        SdtHV        = h.SdtHV,
                        EmailHV      = h.EmailHV,
                        NgayTiepNhan = h.NgayTiepNhan,
                        MaLoaiHV     = "LHV01",
                        TenDangNhap  = h.MaHV,
                    },
                                   new TAIKHOAN()
                    {
                        TenDangNhap = h.MaHV,
                        MatKhau     = h.MaHV
                    });
                    MessageBox.Show(string.Format("Học viên {0} đã được chuyển thành học viên chính thức với tài khoản:{1}Tên đăng nhập: {2}{3}Mật khẩu: {4}",
                                                  h.TenHV, Environment.NewLine, h.MaHV, Environment.NewLine, h.MaHV),
                                    "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                isSave = true;
                LoadPhieuGhiDanh();
                if (MessageBox.Show("Bạn có muốn in phiếu ghi danh vừa lưu?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    btnInBienLai_Click(sender, e);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }