private void btnXoa_Click(object sender, EventArgs e)
        {
            try
            {
                var rowHandle  = gridViewKhoaHoc.FocusedRowHandle;
                int _KhoaHocId = O2S_Common.TypeConvert.Parse.ToInt32(gridViewKhoaHoc.GetRowCellValue(rowHandle, "KhoaHocId").ToString());

                ValidateXoaKhoaHoc(_KhoaHocId);
                if (MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (KhoaHocLogic.Delete(_KhoaHocId))
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.XOA_THANH_CONG);
                        frmthongbao.Show();
                        LoadGridKhoaHoc();
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            SplashScreenManager.ShowForm(typeof(O2S_Common.Utilities.ThongBao.WaitForm_Wait));
            try
            {
                if (cboLopHoc.SelectedValue != null)
                {
                    int _lophocid = O2S_Common.TypeConvert.Parse.ToInt32(cboLopHoc.SelectedValue.ToString());
                    this.lstBangDiem = BangDiemLogic.SelectTheoDoiBangDiemLop(_lophocid);

                    if (this.lstBangDiem != null && this.lstBangDiem.Count > 0)
                    {
                        for (int i = 0; i < this.lstBangDiem.Count; i++)
                        {
                            this.lstBangDiem[i].Stt = i + 1;
                        }
                        gridControlDSPhieuGhiDanh.DataSource = this.lstBangDiem;
                    }
                    else
                    {
                        gridControlDSPhieuGhiDanh.DataSource = null;
                    }
                }
                else
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.VUI_LONG_NHAP_DAY_DU_THONG_TIN);
                    frmthongbao.Show();
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
            SplashScreenManager.CloseForm();
        }
Ejemplo n.º 3
0
        private void btnTimKiem_Click(object sender, EventArgs e)
        {
            SplashScreenManager.ShowForm(typeof(O2S_Common.Utilities.ThongBao.WaitForm_Wait));
            try
            {
                DataGridView_ResetLaiCot();

                int _KhoaHocId   = O2S_Common.TypeConvert.Parse.ToInt32(cboKhoaHoc.SelectedValue.ToString());
                int _GiangVienId = O2S_Common.TypeConvert.Parse.ToInt32(cboGiangVien.SelectedValue.ToString());

                if (_KhoaHocId != 0 && _GiangVienId != 0)
                {
                    LopHocFilter _filter = new LopHocFilter();
                    _filter.KhoaHocId   = _KhoaHocId;
                    _filter.GiangVienId = _GiangVienId;
                    List <LopHoc_PlusDTO> _lstLopHoc = LopHocLogic.SelectGroupTheoLopHoc(_filter);
                    if (_lstLopHoc != null && _lstLopHoc.Count > 0)
                    {
                        TaoCot_DataGridView(_lstLopHoc);
                        LayDuLieuLenGridView(_lstLopHoc, _GiangVienId, _KhoaHocId);
                    }
                }
                else
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.VUI_LONG_NHAP_DAY_DU_THONG_TIN);
                    frmthongbao.Show();
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
            SplashScreenManager.CloseForm();
        }
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();

                if (HoaDonThuChiLogic.Insert(LoadHoaDonThuChi()))
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
                    frmthongbao.Show();
                    LoadDanhSachHoaDon();
                    LockAndUnlockPanelControl(false);
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
                frmthongbao.Show();
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
Ejemplo n.º 5
0
 private void btnLuuThongTin_Click(object sender, EventArgs e)
 {
     try
     {
         LICHSUTUVAN _lstuvan = new LICHSUTUVAN()
         {
             HocVienId    = this.HocVienId_Select,
             NguoiTuVan   = txtNguoiTuVan.Text,
             NoiDungTuVan = txtNoiDungTuVan.Text,
             KetQuaTuVan  = txtKetQuaTuVan.Text,
             GhiChu       = txtGhiChu.Text,
             NgayTuVan    = dateNgayTuVan.DateTime,
         };
         if (LichSuTuVanLogic.Insert(_lstuvan))
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
             frmthongbao.Show();
         }
         else
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THAT_BAI);
             frmthongbao.Show();
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         //Validate xoa du lieu
         ValidateXoaHocVien(this.hocvienId_Select);
         if (MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             if (HocVienLogic.Delete(this.hocvienId_Select))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.XOA_THANH_CONG);
                 frmthongbao.Show();
                 LoadDanhSachHocVien();
                 ResetPanelControl();
             }
             else
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THAO_TAC_THAT_BAI);
                 frmthongbao.Show();
             }
         }
     }
     catch (ArgumentException ex)
     {
         MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     catch (Exception ex)
     {
         O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
         frmthongbao.Show();
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                DOTHOC _dotHoc = new DOTHOC()
                {
                    CoSoId    = GlobalSettings.CoSoId,
                    LopHocId  = this.LopHocId,
                    TenDotHoc = txtTenLopHoc.Text,
                    HocPhi    = O2S_Common.TypeConvert.Parse.ToDecimal(numHocPhi.Text),
                    SoBuoiHoc = O2S_Common.TypeConvert.Parse.ToDecimal(numSoBuoiHoc.Text),
                };

                if (DotHocLogic.Insert(_dotHoc))
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
                    frmthongbao.Show();
                    this.Close();
                }
                else
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THAT_BAI);
                    frmthongbao.Show();
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
Ejemplo n.º 8
0
 private void btnLuuThongTin_Click(object sender, EventArgs e)
 {
     try
     {
         PHIEUTHU _phieuGD = PhieuThuLogic.SelectSingle(this.PhieuThuId);
         _phieuGD.IsRemove    = 1;
         _phieuGD.LyDoHuy     = txtLyDoHuy.Text;
         _phieuGD.NguoiHuy    = GlobalSettings.UserCode + " - " + GlobalSettings.UserName;
         _phieuGD.ThoiGianHuy = DateTime.Now;
         if (PhieuThuLogic.HuyPhieuThuTien(_phieuGD))
         {
             MessageBox.Show("Hủy phiếu thu thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THAO_TAC_THAT_BAI);
             frmthongbao.Show();
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            //connectionString = string.Format("Data Source = {0}; Initial Catalog = {1}; ", txtTenServer.Text, cboDatabase.Text);

            //if (cboKieuXacThuc.SelectedIndex == 0)
            //    connectionString += "Integrated Security = True; ";
            //else
            //    connectionString += string.Format("User Id = {0}; Password = {1}; ", txtTenDangNhap.Text, txtMatKhau.Text);

            //GlobalSettings.ConnectionString = connectionString;
            //GlobalSettings.ServerName = txtTenServer.Text;
            //GlobalSettings.ServerCatalog = cboDatabase.Text;

            //GlobalSettings.SaveDatabaseConnection();

            LuuLaiCauHinhFileConfig();
            //luu lai duong dan cap nhat CDSL
            VERSION _version = VersionLogic.Select();

            _version.AppLink = txtUpdateVersionLink.Text;
            if (VersionLogic.Update(_version))
            {
                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
                frmthongbao.Show();
            }
        }
Ejemplo n.º 10
0
        private void btnLuuLop_Click(object sender, EventArgs e)
        {
            try
            {
                //insert + Xoa tai BANGDIEM
                int _LopHocId = O2S_Common.TypeConvert.Parse.ToInt32(cboLopHoc.SelectedValue.ToString());
                foreach (var item in this.dsXepLopHocVien)
                {
                    //kiem tra ton tai hay khong
                    List <BANGDIEM> _kiemtratontai = BangDiemLogic.SelectTheoPhieuGhiDanh(item.PhieuGhiDanhId ?? 0);
                    if (_kiemtratontai == null || _kiemtratontai.Count == 0)
                    {
                        BANGDIEM _bangdiem = new BANGDIEM();
                        _bangdiem.HocVienId      = item.HocVienId ?? 0;
                        _bangdiem.LopHocId       = _LopHocId;
                        _bangdiem.PhieuGhiDanhId = item.PhieuGhiDanhId ?? 0;
                        _bangdiem.KhoaHocId      = item.KhoaHocId ?? 0;
                        _bangdiem.TrangThai      = 0;//=0: xep lop; =1: dang hoc; =3: co diem; =99:ket thuc
                        BangDiemLogic.Insert(_bangdiem);
                    }
                }

                List <BANGDIEM> _lstBangDiem_LopHoc = BangDiemLogic.SelectTheoLopHoc(_LopHocId);
                if (_lstBangDiem_LopHoc != null && _lstBangDiem_LopHoc.Count > 0)
                {
                    List <BANGDIEM> _bangdiem_Xoa = (from p in _lstBangDiem_LopHoc
                                                     where !(from q in this.dsXepLopHocVien select q.PhieuGhiDanhId).Contains(p.PhieuGhiDanhId)
                                                     select p).ToList();
                    if (_bangdiem_Xoa != null && _bangdiem_Xoa.Count > 0)
                    {
                        BangDiemLogic.DeleteList(_bangdiem_Xoa);
                    }
                }

                //Update  SiSo cua LOPHOC
                LOPHOC _lophoc = LopHocLogic.SelectSingle(_LopHocId);
                LopHocLogic.Update(new LOPHOC()
                {
                    LopHocId    = _lophoc.LopHocId,
                    TenLopHoc   = _lophoc.TenLopHoc,
                    NgayBatDau  = _lophoc.NgayBatDau,
                    NgayKetThuc = _lophoc.NgayKetThuc,
                    SiSoToiDa   = _lophoc.SiSoToiDa,
                    SiSo        = this.dsXepLopHocVien.Count,
                    KhoaHocId   = _lophoc.KhoaHocId,
                    IsLock      = _lophoc.IsLock
                });

                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                frmthongbao.Show();
            }
            catch (Exception ex)
            {
                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                frmthongbao.Show();
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();

                if (isInsert)
                {
                    int _hocvienId = 0;
                    if (HocVienLogic.Insert(LoadHocVien(), new TAIKHOAN()
                    {
                        TenDangNhap = txtTenDangNhap.Text,
                        MatKhau = txtMatKhau.Text,
                        LoaiTaiKhoanId = KeySetting.LOAITAIKHOAN_HocVien,
                    }, ref _hocvienId))
                    {
                        LoadDanhSachHocVien();
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
                        frmthongbao.Show();
                        LockAndUnlockPanelControl(false);
                    }
                }
                else
                {
                    if (HocVienLogic.Update(LoadHocVien(), new TAIKHOAN()
                    {
                        TenDangNhap = txtTenDangNhap.Text,
                        MatKhau = txtMatKhau.Text,
                    }))
                    {
                        LoadDanhSachHocVien();
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                        frmthongbao.Show();
                        LockAndUnlockPanelControl(false);
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
                frmthongbao.Show();
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        private void btnLuuLai_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();
                //Update PHIEUGHIDANH
                PHIEUGHIDANH _phieughidanh = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId_Select);
                _phieughidanh.DaDong = _phieughidanh.DaDong + O2S_Common.TypeConvert.Parse.ToDecimal(numNopThem.Text);

                decimal _mienggiam = _phieughidanh.MienGiam_Tien ?? 0;
                _phieughidanh.ConNo = _phieughidanh.TongTien - _phieughidanh.DaDong - _mienggiam;
                //Insert Phieu Thu
                var      rowHandle = gridViewDSHocVien.FocusedRowHandle;
                PHIEUTHU _phieuthu = new PHIEUTHU();
                _phieuthu.CoSoId         = GlobalSettings.CoSoId;
                _phieuthu.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                _phieuthu.HocVienId      = this.HocVienId_Select;
                _phieuthu.ThoiGianThu    = DateTime.Now;
                _phieuthu.SoTien         = O2S_Common.TypeConvert.Parse.ToDecimal(numNopThem.Text);
                _phieuthu.GhiChu         = "";//gridViewDSHocVien.GetRowCellValue(rowHandle, "TenKhoaHoc").ToString();
                if (PhieuGhiDanhLogic.InsertQLHocPhi(_phieughidanh, _phieuthu, ref this.PhieuThu_Insert))
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.LUU_THANH_CONG);
                    frmthongbao.Show();
                    //
                    LoadDanhSachHocVien();
                    gridViewDSHocVien_Click(null, null);

                    PhieuThuFilter _filter = new PhieuThuFilter();
                    _filter.HocVienId      = this.HocVienId_Select;
                    _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                    LoadDanhSachPhieuThu(_filter);

                    btnInBienLai.Enabled = true;
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
 private void btnKhoaLichHoc_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Bạn sẵn sàng lên lịch học?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             List <XEPLICHHOC> _lstLichHoc = XepLichHocLogic.SelectTheoLopHoc(this.LopHocId_Select);
             if (XepLichHocLogic.UpdateKhoaLichHoc(_lstLichHoc))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                 frmthongbao.Show();
                 btnTimKiem_Click(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
Ejemplo n.º 14
0
 private void btnLuuThongTin_Click(object sender, EventArgs e)
 {
     try
     {
         if (BangDiemLogic.UpdateFull(this.bangDiemFull_Click))
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
             frmthongbao.Show();
         }
         else
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
             frmthongbao.Show();
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
 private void btnLicenseKiemTra_Click(object sender, EventArgs e)
 {
     try
     {
         if (!String.IsNullOrEmpty(txtKeyKichHoat.Text.Trim()))
         {
             lblThoiGianSuDung.Text = Base.KiemTraLicense.KiemTraThoiHanLicense(txtKeyKichHoat.Text.Trim());
         }
         else
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao("Chưa nhập mã kích hoạt!");
             frmthongbao.Show();
             lblThoiGianSuDung.Text = "none";
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
        private void btnGuiMail_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateEmailKhiGui();
                int          _CauHinhId = O2S_Common.TypeConvert.Parse.ToInt32(cboEmailGui.SelectedValue.ToString());
                CAUHINHEMAIL _cauhinh   = CauHinhEmailLogic.SelectSingle(_CauHinhId);
                if (_cauhinh == null)
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao _frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.VUI_LONG_NHAP_DAY_DU_THONG_TIN);
                    _frmthongbao.Show();
                    return;
                }

                SmtpClient mailclient = new SmtpClient(_cauhinh.SMTPServer, _cauhinh.Port ?? 0);
                mailclient.EnableSsl   = true;
                mailclient.Credentials = new NetworkCredential(_cauhinh.TaiKhoan, O2S_Common.EncryptAndDecrypt.MD5EncryptAndDecrypt.Decrypt(_cauhinh.MatKhau, true));

                MailMessage message = new MailMessage(_cauhinh.TaiKhoan, txtEmailNhan.Text);
                message.Subject    = txtTieuDeMail.Text;
                message.Body       = txtNoiDungMail.HtmlText;
                message.IsBodyHtml = true;

                mailclient.Send(message);
                MessageBox.Show(Base.ThongBaoLable.GUI_MAIL_THANH_CONG, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);

                //O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.GUI_MAIL_THANH_CONG);
                //frmthongbao.Show();
            }
            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.Warning);
                O2S_Common.Logging.LogSystem.Error(ex);
                //O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.GUI_MAIL_THAT_BAI);
                //frmthongbao.Show();
            }
        }
Ejemplo n.º 17
0
 private void btnLuuQuyDinh_Click(object sender, EventArgs e)
 {
     try
     {
         if (QuyDinhLogic.UpdateAll(this.lstQuyDinh))
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
             frmthongbao.Show();
             frmQuyDinh_Load(null, null);
         }
         else
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
             frmthongbao.Show();
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
 private void repositoryItemButton_Xoa_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             var rowHandle = gridViewDSDotHoc.FocusedRowHandle;
             int _DotHocId = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSDotHoc.GetRowCellValue(rowHandle, "DotHocId").ToString());
             if (DotHocLogic.Delete(_DotHocId))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.XOA_THANH_CONG);
                 frmthongbao.Show();
                 gridViewLopHoc_Click(null, null);
             }
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
Ejemplo n.º 19
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             var rowHandle = gridViewEmail.FocusedRowHandle;
             int _caHocId  = O2S_Common.TypeConvert.Parse.ToInt32(gridViewEmail.GetRowCellValue(rowHandle, "CauHinhEmailId").ToString());
             if (CauHinhEmailLogic.Delete(_caHocId))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.XOA_THANH_CONG);
                 frmthongbao.Show();
                 LoadGridCauHinhEmail();
             }
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Bạn có muốn xóa?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             if (NhanVienLogic.Delete(this.nhanvienId_Select))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.XOA_THANH_CONG);
                 frmthongbao.Show();
                 LoadDanhSachNhanVien();
                 ResetPanelControl();
             }
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
         frmthongbao.Show();
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();

                if (isInsert)
                {
                    ValidateTrungTaiKhoan(txtTenDangNhap.Text);
                    if (NhanVienLogic.InsertAndTaiKhoan(LoadNhanVien(), LoadTaiKhoan()))
                    {
                        LoadDanhSachNhanVien();
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
                        frmthongbao.Show();
                        LockAndUnlockPanelControl(false);
                    }
                }
                else
                {
                    if (NhanVienLogic.Update(LoadNhanVien(), LoadTaiKhoan()))
                    {
                        LoadDanhSachNhanVien();
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                        frmthongbao.Show();
                        LockAndUnlockPanelControl(false);
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
                frmthongbao.Show();
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
 private void btnLuuThongTin_Click(object sender, EventArgs e)
 {
     try
     {
         if (isInsert)
         {
             int _khoaHocId = 0;
             if (LopHocLogic.Insert(LoadLopHoc(), ref _khoaHocId))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
                 frmthongbao.Show();
             }
             else
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THAT_BAI);
                 frmthongbao.Show();
             }
         }
         else
         {
             if (LopHocLogic.Update(LoadLopHoc()))
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                 frmthongbao.Show();
             }
             else
             {
                 O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                 frmthongbao.Show();
             }
         }
         LoadGridLopHoc();
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
 private void btnLicenseLuu_Click(object sender, EventArgs e)
 {
     try
     {
         LICENSE _license = new LICENSE();
         _license.DataKey    = txtMaMay.Text;
         _license.LicenseKey = txtKeyKichHoat.Text.Trim();
         try
         {
             LicenseLogic.Update(_license);
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao("Lưu mã kích hoạt thành công!");
             frmthongbao.Show();
         }
         catch (Exception)
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CO_LOI_XAY_RA);
             frmthongbao.Show();
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Warn(ex);
     }
 }
 private void btnLuuThongTin_Click(object sender, EventArgs e)
 {
     try
     {
         PHIEUGHIDANH _phieuGD = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId);
         _phieuGD.IsRemove = 1;
         _phieuGD.LyDoXoa  = txtLyDoXoa.Text;
         _phieuGD.NguoiXoa = GlobalSettings.UserCode;
         if (PhieuGhiDanhLogic.XoaPhieuGhiDanh(_phieuGD))
         {
             MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
         else
         {
             O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THAO_TAC_THAT_BAI);
             frmthongbao.Show();
         }
     }
     catch (Exception ex)
     {
         O2S_Common.Logging.LogSystem.Error(ex);
     }
 }
Ejemplo n.º 25
0
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.TaiKhoan_Select != null)
                {
                    //Update TAIKHOAN: passs
                    this.TaiKhoan_Select.MatKhau = txtMatKhau.Text;

                    //Update PHANQUYENTAIKHOAN
                    List <PHANQUYENTAIKHOAN> _lstPQ_TK_All = new List <PHANQUYENTAIKHOAN>();
                    foreach (var _item in this.lstPQ_TK_ChucNang)
                    {
                        if (_item.IsCheck)
                        {
                            PHANQUYENTAIKHOAN _phanquyen = new PHANQUYENTAIKHOAN
                            {
                                TaiKhoanId = this.TaiKhoan_Select.TaiKhoanId,
                                ChucNangId = _item.ChucNangId,
                                Them       = _item.Them == true ? 1 : 0,
                                Sua        = _item.Sua == true ? 1 : 0,
                                Xoa        = _item.Xoa == true ? 1 : 0,
                                InAn       = _item.InAn == true ? 1 : 0,
                                XuatFile   = _item.XuatFile == true ? 1 : 0,
                            };
                            _lstPQ_TK_All.Add(_phanquyen);
                        }
                    }
                    foreach (var _item in this.lstPQ_TK_BaoCao)
                    {
                        if (_item.IsCheck)
                        {
                            PHANQUYENTAIKHOAN _phanquyen = new PHANQUYENTAIKHOAN
                            {
                                TaiKhoanId = this.TaiKhoan_Select.TaiKhoanId,
                                ChucNangId = _item.ChucNangId,
                                Them       = _item.Them == true ? 1 : 0,
                                Sua        = _item.Sua == true ? 1 : 0,
                                Xoa        = _item.Xoa == true ? 1 : 0,
                                InAn       = _item.InAn == true ? 1 : 0,
                                XuatFile   = _item.XuatFile == true ? 1 : 0,
                            };
                            _lstPQ_TK_All.Add(_phanquyen);
                        }
                    }

                    if (TaiKhoanLogic.Update(this.TaiKhoan_Select) && PhanQuyenTaiKhoanLogic.DeleteAndInsert(_lstPQ_TK_All, this.TaiKhoan_Select.TaiKhoanId))
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                        frmthongbao.Show();
                    }
                    else
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                        frmthongbao.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Warn(ex);
            }
        }
        private void btnLuuPhieu_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuuPhieu();
                DOTHOC _dotHoc = null;
                if (cboDotHoc.SelectedValue != null)
                {
                    _dotHoc = DotHocLogic.SelectSingle(O2S_Common.TypeConvert.Parse.ToInt32(cboDotHoc.SelectedValue.ToString()));
                }
                //Insert bang PHIEUGHIDANH
                //insert bang PHIEUTHU; HOCPHIHOCVIEN
                //cap nhat bang HOCVIEN trang thai hoc vien = hoc vien chinh thuc + TAIKHOAN=chinh thuc
                PHIEUGHIDANH _phieughidanh = new PHIEUGHIDANH();
                _phieughidanh.HocVienId   = this.HocVienId_Select;
                _phieughidanh.KhoaHocId   = O2S_Common.TypeConvert.Parse.ToInt32(cboKhoaHoc.SelectedValue.ToString());
                _phieughidanh.LopHocId    = O2S_Common.TypeConvert.Parse.ToInt32(cboLopHoc.SelectedValue.ToString());
                _phieughidanh.NgayGhiDanh = DateTime.ParseExact(dateNgayGhiDanh.Text, "HH:mm:ss dd/MM/yyyy", CultureInfo.InvariantCulture);
                //tong tien cua lop hoc den thoi diem hien tai
                List <DOTHOC> _lstDotHoc = DotHocLogic.SelectTheoLopHoc(_phieughidanh.LopHocId ?? 0);
                _phieughidanh.HocPhiKH = _lstDotHoc != null?_lstDotHoc.Sum(o => o.HocPhi) : 0;

                _phieughidanh.SoTietKH = _lstDotHoc != null?_lstDotHoc.Sum(o => o.SoBuoiHoc) : 0;

                _phieughidanh.HocPhiHocVienKH   = O2S_Common.TypeConvert.Parse.ToDecimal(lblThanhTienKhoaHoc.Text.Replace(",", ""));
                _phieughidanh.SoTietHocVienKH   = O2S_Common.TypeConvert.Parse.ToDecimal(numSoBuoiHVDangKy.Text);
                _phieughidanh.ThuKhoanKhac      = TinhTongTien_ThuThem();
                _phieughidanh.TongTien          = O2S_Common.TypeConvert.Parse.ToDecimal(numTongTien.Text);
                _phieughidanh.DaDong            = O2S_Common.TypeConvert.Parse.ToDecimal(numDaDong.Text.Replace(",", ""));
                _phieughidanh.ConNo             = O2S_Common.TypeConvert.Parse.ToDecimal(numConNo.Text);
                _phieughidanh.MienGiam_PhanTram = O2S_Common.TypeConvert.Parse.ToInt16(numMienGiam_PTram.Value.ToString());
                _phieughidanh.MienGiam_Tien     = O2S_Common.TypeConvert.Parse.ToDecimal(numMienGiam_Tien.Text.Replace(",", ""));
                _phieughidanh.LyDoMienGiam      = txtLyDoMienGiam.Text;
                if (GlobalSettings.UserID != -1)
                {
                    _phieughidanh.NhanVienId = GlobalSettings.UserID;
                }

                //insert bang PHIEUTHU
                PHIEUTHU             _phieuthu = new PHIEUTHU();
                List <HOCPHIHOCVIEN> _lsthphv  = new List <HOCPHIHOCVIEN>();
                if (O2S_Common.TypeConvert.Parse.ToDecimal(numDaDong.Text.Replace(",", "")) > 0)
                {
                    //_phieuthuInsert.PhieuGhiDanhId = this.PhieuGhiDanhId;
                    _phieuthu.CoSoId      = GlobalSettings.CoSoId;
                    _phieuthu.HocVienId   = this.HocVienId_Select;
                    _phieuthu.ThoiGianThu = DateTime.Now;
                    _phieuthu.SoTien      = O2S_Common.TypeConvert.Parse.ToDecimal(numDaDong.Text.Replace(",", ""));
                    _phieuthu.NoiDung     = cboDotHoc.Text;
                    _phieuthu.GhiChu      = "Thu tiền đợt học: " + cboDotHoc.Text;
                    //Tien Dot Hoc
                    if (cboDotHoc.SelectedValue != null)
                    {
                        HOCPHIHOCVIEN _hphv_kh = new HOCPHIHOCVIEN()
                        {
                            Stt        = 1,
                            HocVienId  = this.HocVienId_Select,
                            DmDichVuId = O2S_Common.TypeConvert.Parse.ToInt32(cboDotHoc.SelectedValue.ToString()),
                            TenDichVu  = cboDotHoc.Text,
                            SoTien     = O2S_Common.TypeConvert.Parse.ToDecimal(lblThanhTienKhoaHoc.Text.Replace(",", "")),
                            SoLuong    = O2S_Common.TypeConvert.Parse.ToDecimal(numSoBuoiHVDangKy.Text.Replace(",", "")),
                            DonGia     = O2S_Common.TypeConvert.Parse.ToDecimal(numHocPhi.Text) / O2S_Common.TypeConvert.Parse.ToDecimal(numSoTietHoc.Text),
                            //PhieuThuId = _phieuthuId,
                            GhiChu = "",
                        };
                        _lsthphv.Add(_hphv_kh);
                    }
                    //tien khoan Khac
                    if (gridViewKhoanKhac.RowCount > 0)
                    {
                        _phieuthu.NoiDung += " và khoản khác";
                        _phieuthu.GhiChu  += " và khoản khác";
                        int _stt_thuthem = 2;
                        for (int i = 0; i < gridViewKhoanKhac.RowCount; i++)
                        {
                            object _noidungkt = gridViewKhoanKhac.GetRowCellValue(i, "noidung");
                            if (_noidungkt != null)
                            {
                                HOCPHIHOCVIEN _hphv_khac = new HOCPHIHOCVIEN()
                                {
                                    Stt        = _stt_thuthem,
                                    HocVienId  = this.HocVienId_Select,
                                    DmDichVuId = 0,
                                    TenDichVu  = gridViewKhoanKhac.GetRowCellValue(i, "noidung") == null ? "" : gridViewKhoanKhac.GetRowCellValue(i, "noidung").ToString(),
                                    SoTien     = O2S_Common.TypeConvert.Parse.ToDecimal(gridViewKhoanKhac.GetRowCellValue(i, "sotien").ToString()),
                                    SoLuong    = 1,
                                    DonGia     = O2S_Common.TypeConvert.Parse.ToDecimal(gridViewKhoanKhac.GetRowCellValue(i, "sotien").ToString()),
                                    //PhieuThuId = _phieuthuId,
                                    GhiChu = gridViewKhoanKhac.GetRowCellValue(i, "ghichu") == null ? "" : gridViewKhoanKhac.GetRowCellValue(i, "ghichu").ToString(),
                                };
                                _lsthphv.Add(_hphv_khac);
                                _stt_thuthem += 1;
                            }
                        }
                    }
                }
                //bang diem
                BANGDIEM _bangdiem = new BANGDIEM();
                _bangdiem.HocVienId = this.HocVienId_Select;
                _bangdiem.LopHocId  = O2S_Common.TypeConvert.Parse.ToInt32(cboLopHoc.SelectedValue.ToString());
                // _bangdiem.PhieuGhiDanhId = item.PhieuGhiDanhId ?? 0;
                _bangdiem.KhoaHocId = O2S_Common.TypeConvert.Parse.ToInt32(cboKhoaHoc.SelectedValue.ToString());
                _bangdiem.TrangThai = 0;//=0: xep lop; =1: dang hoc; =3: co diem; =99:ket thu

                if (PhieuGhiDanhLogic.InsertPGDFull_XepLop(_phieughidanh, _phieuthu, _lsthphv, _bangdiem, ref this.PhieuGhiDanhId, ref this.PhieuThuId))
                {
                    HOCVIEN _hv = HocVienLogic.SelectSingle(this.HocVienId_Select);
                    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}",
                                                  _hv.TenHocVien, Environment.NewLine, _hv.MaHocVien, Environment.NewLine, _hv.MaHocVien),
                                    "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    isSave = true;

                    btnLuuPhieu.Enabled = false;
                    LoadPhieuGhiDanh();

                    if (this.PhieuThuId != 0)
                    {
                        btnInBienLai.Enabled = true;
                        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)
                        {
                            InBienLaiThuTien_Process(this.PhieuThuId);
                        }
                    }
                }
                else
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THAT_BAI);
                    frmthongbao.Show();
                }
            }
            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 btnLuuLai_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.LopHocId_Select != 0)
                {
                    //Xoa di het roi insert lai
                    if (XepLichHocLogic.DeleteTheoLopHoc(this.LopHocId_Select))
                    {
                        List <XEPLICHHOC> _lstInsert = new List <XEPLICHHOC>();
                        foreach (var item in this.lstLichHoc)
                        {
                            var culture       = new System.Globalization.CultureInfo("vi-VN");
                            var day_tiengViet = culture.DateTimeFormat.GetDayName(item.ThoiGianHoc.DayOfWeek);

                            ValidateLuu(item);
                            CAHOC      _cahoc       = CaHocLogic.SelectSingle(item.CaHocId ?? 0);
                            PHONGHOC   _phonghoc    = PhongHocLogic.SelectSingle(item.PhongHocId ?? 0);
                            GIANGVIEN  _gv_chinh    = GiangVienLogic.SelectSigleTheoKhoaKhoa(item.GiaoVien_ChinhId ?? 0);
                            GIANGVIEN  _gv_trogiang = GiangVienLogic.SelectSigleTheoKhoaKhoa(item.GiaoVien_TroGiangId ?? 0);
                            XEPLICHHOC _xeplich     = new XEPLICHHOC()
                            {
                                CoSoId                = GlobalSettings.CoSoId,
                                KhoaHocId             = this.KhoaHocId_Select,
                                LopHocId              = this.LopHocId_Select,
                                TenLopHoc             = cboLopHoc.Text,
                                ThoiGianHoc           = item.ThoiGianHoc,
                                ThoiGianHoc_Full      = day_tiengViet + " - " + item.ThoiGianHoc.ToString("dd/MM/yyyy"),
                                CaHocId               = item.CaHocId,
                                TenCaHocFull          = _cahoc != null ? _cahoc.TenCaHocFull : "",
                                PhongHocId            = item.PhongHocId,
                                TenPhongHoc           = _phonghoc != null ? _phonghoc.TenPhongHoc : "",
                                GiaoVien_ChinhId      = item.GiaoVien_ChinhId,
                                TenGiaoVien_Chinh     = _gv_chinh != null ? _gv_chinh.TenGiangVien : "",
                                TienGiaoVien_Chinh    = item.TienGiaoVien_Chinh,
                                GiaoVien_TroGiangId   = item.GiaoVien_TroGiangId,
                                TenGiaoVien_TroGiang  = _gv_trogiang != null ? _gv_trogiang.TenGiangVien : "",
                                TienGiaoVien_TroGiang = item.TienGiaoVien_TroGiang,
                                GhiChu                = item.GhiChu,
                                IsLock                = item.IsLock,
                            };
                            _lstInsert.Add(_xeplich);
                        }
                        if (XepLichHocLogic.InsertMultiRow(_lstInsert))
                        {
                            //Thread.Sleep(2500);
                            O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                            frmthongbao.Show();
                            LoadLichHocCuaLopHoc(this.LopHocId_Select);
                        }
                        else
                        {
                            O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                            frmthongbao.Show();
                        }
                    }
                    else
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THAT_BAI);
                        frmthongbao.Show();
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Warn(ex);
            }
        }
        private void btnLuuThongTin_Click(object sender, EventArgs e)
        {
            try
            {
                if (isInsert)
                {
                    int _khoaHocId = 0;
                    if (KhoaHocLogic.Insert(LoadKhoaHoc(), ref _khoaHocId))
                    {//Insert Khoa hoc-mon hoc
                        for (int i = 0; i < gridViewDSMonHoc.RowCount; i++)
                        {
                            bool _IsCheck = O2S_Common.TypeConvert.Parse.ToBoolean(gridViewDSMonHoc.GetRowCellValue(i, "IsCheck").ToString());
                            if (_IsCheck)
                            {
                                KHOAHOC_MONHOC _khmh = new KHOAHOC_MONHOC();
                                _khmh.KhoaHocId  = _khoaHocId;
                                _khmh.TenKhoaHoc = txtTenKhoaHoc.Text;
                                _khmh.MonHocId   = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSMonHoc.GetRowCellValue(i, "MonHocId").ToString());
                                _khmh.TenMonHoc  = gridViewDSMonHoc.GetRowCellValue(i, "TenMonHoc").ToString();
                                _khmh.DiemDat    = O2S_Common.TypeConvert.Parse.ToDecimal(gridViewDSMonHoc.GetRowCellValue(i, "DiemDat").ToString());
                                KhoaHocMonHocLogic.Insert(_khmh);
                            }
                        }
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THANH_CONG);
                        frmthongbao.Show();
                    }
                    else
                    {
                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.THEM_MOI_THAT_BAI);
                        frmthongbao.Show();
                    }
                }
                else //update
                {
                    if (KhoaHocLogic.Update(LoadKhoaHoc()))
                    {
                        //INsert Khoa hoc-mon hoc
                        KhoaHocMonHocLogic.DeleteTheoKhoaHoc(this.khoaHocSelect.KhoaHocId);
                        for (int i = 0; i < gridViewDSMonHoc.RowCount; i++)
                        {
                            bool _IsCheck = O2S_Common.TypeConvert.Parse.ToBoolean(gridViewDSMonHoc.GetRowCellValue(i, "IsCheck").ToString());
                            if (_IsCheck)
                            {
                                KHOAHOC_MONHOC _khmh = new KHOAHOC_MONHOC();
                                _khmh.KhoaHocId  = this.khoaHocSelect.KhoaHocId;
                                _khmh.TenKhoaHoc = txtTenKhoaHoc.Text;
                                _khmh.MonHocId   = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSMonHoc.GetRowCellValue(i, "MonHocId").ToString());
                                _khmh.TenMonHoc  = gridViewDSMonHoc.GetRowCellValue(i, "TenMonHoc").ToString();
                                _khmh.DiemDat    = O2S_Common.TypeConvert.Parse.ToDecimal(gridViewDSMonHoc.GetRowCellValue(i, "DiemDat").ToString());
                                KhoaHocMonHocLogic.Insert(_khmh);
                            }
                        }

                        O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.CAP_NHAT_THANH_CONG);
                        frmthongbao.Show();
                    }
                }
                LoadGridKhoaHoc();
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }
        private void btnLuuLai_Click(object sender, EventArgs e)
        {
            try
            {
                ValidateLuu();
                //Update PHIEUGHIDANH: dadong
                PHIEUGHIDANH _phieughidanh = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId_Select);
                _phieughidanh.DaDong = _phieughidanh.DaDong + O2S_Common.TypeConvert.Parse.ToDecimal(numDaDong.Text);
                //
                _phieughidanh.SoTietKH        = _phieughidanh.SoTietKH + O2S_Common.TypeConvert.Parse.ToDecimal(numSoTietHoc.Text);//so tiet tren dot hoc da chon
                _phieughidanh.HocPhiKH        = _phieughidanh.HocPhiKH + O2S_Common.TypeConvert.Parse.ToDecimal(numHocPhi.Text);
                _phieughidanh.HocPhiHocVienKH = _phieughidanh.HocPhiHocVienKH + O2S_Common.TypeConvert.Parse.ToDecimal(numTongTien.Text);
                _phieughidanh.SoTietHocVienKH = _phieughidanh.SoTietHocVienKH + O2S_Common.TypeConvert.Parse.ToDecimal(numSoBuoiHVDangKy.Text);

                decimal _mienggiam = _phieughidanh.MienGiam_Tien ?? 0;
                _phieughidanh.ConNo = _phieughidanh.TongTien - _phieughidanh.DaDong - _mienggiam;


                //Insert Phieu Thu
                var      rowHandle = gridViewDSHocVien.FocusedRowHandle;
                PHIEUTHU _phieuthu = new PHIEUTHU();
                _phieuthu.CoSoId         = GlobalSettings.CoSoId;
                _phieuthu.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                _phieuthu.HocVienId      = this.HocVienId_Select;
                _phieuthu.ThoiGianThu    = DateTime.Now;
                _phieuthu.SoTien         = O2S_Common.TypeConvert.Parse.ToDecimal(numDaDong.Text);
                _phieuthu.NoiDung        = cboDotHoc.Text;
                _phieuthu.GhiChu         = "Thu tiền đợt học: " + cboDotHoc.Text;
                //Hoc phi hoc vien
                DOTHOC _dothoc = DotHocLogic.SelectSingle(O2S_Common.TypeConvert.Parse.ToInt32(cboDotHoc.SelectedValue.ToString()));

                decimal _donGia = _dothoc.HocPhi ?? 0;
                if (_dothoc.SoBuoiHoc != null && _dothoc.SoBuoiHoc != 0)
                {
                    _donGia = _dothoc.HocPhi / _dothoc.SoBuoiHoc ?? 1;
                }

                HOCPHIHOCVIEN _hocphiHV = new HOCPHIHOCVIEN()
                {
                    PhieuGhiDanhId = this.PhieuGhiDanhId_Select,
                    HocVienId      = this.HocVienId_Select,
                    Stt            = 1,
                    DmDichVuId     = _dothoc.DotHocId,
                    TenDichVu      = cboDotHoc.Text,
                    SoTien         = O2S_Common.TypeConvert.Parse.ToDecimal(numTongTien.Text),
                    SoLuong        = O2S_Common.TypeConvert.Parse.ToDecimal(numSoBuoiHVDangKy.Text),
                    DonGia         = _donGia,
                    PhieuThuId     = 0,
                    GhiChu         = "",
                };
                if (PhieuGhiDanhLogic.InsertQLHocPhi_Option1(_phieughidanh, _phieuthu, _hocphiHV, ref this.PhieuThu_Insert))
                {
                    O2S_Common.Utilities.ThongBao.frmThongBao frmthongbao = new O2S_Common.Utilities.ThongBao.frmThongBao(Base.ThongBaoLable.LUU_THANH_CONG);
                    frmthongbao.Show();
                    //
                    LoadDanhSachHocVien();
                    gridViewDSHocVien_Click(null, null);

                    PhieuThuFilter _filter = new PhieuThuFilter();
                    _filter.HocVienId      = this.HocVienId_Select;
                    _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select;
                    LoadDanhSachPhieuThu(_filter);

                    btnInBienLai.Enabled = true;
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            catch (Exception ex)
            {
                O2S_Common.Logging.LogSystem.Error(ex);
            }
        }