public static bool HuyPhieuThuTien(PHIEUTHU _phieuthu) { try { using (TransactionScope ts = new TransactionScope()) { var phieuthuCu = SelectSingle(_phieuthu.PhieuThuId); phieuthuCu.IsRemove = _phieuthu.IsRemove; phieuthuCu.LyDoHuy = _phieuthu.LyDoHuy; phieuthuCu.NguoiHuy = _phieuthu.NguoiHuy; phieuthuCu.ThoiGianHuy = _phieuthu.ThoiGianHuy; phieuthuCu.ModifiedDate = DateTime.Now; phieuthuCu.ModifiedBy = GlobalSettings.UserCode; phieuthuCu.ModifiedLog = GlobalSettings.SessionMyIP; Database.SubmitChanges(); //update PHIEUGHIDANH PHIEUGHIDANH _pgdanh = PhieuGhiDanhLogic.SelectSingle(_phieuthu.PhieuGhiDanhId ?? 0); _pgdanh.DaDong = _pgdanh.DaDong - _phieuthu.SoTien; _pgdanh.ConNo = _pgdanh.ConNo + _phieuthu.SoTien; _pgdanh.ModifiedDate = DateTime.Now; _pgdanh.ModifiedBy = GlobalSettings.UserCode; _pgdanh.ModifiedLog = GlobalSettings.SessionMyIP; ts.Complete(); return(true); } } catch (System.Exception ex) { return(false); O2S_Common.Logging.LogSystem.Error(ex); } }
private void btnLuuLai_Click(object sender, EventArgs e) { PHIEUGHIDANH p = PhieuGhiDanh.Select(gridKetQua.SelectedRows[0].Cells["clmMaPhieu"].Value.ToString()); try { ValidateLuu(); PhieuGhiDanh.Update(new PHIEUGHIDANH() { MaPhieu = p.MaPhieu, NgayGhiDanh = p.NgayGhiDanh, MaNV = p.MaNV, DaDong = p.DaDong + numNop.Value, ConNo = p.DANGKies.KHOAHOC.HocPhi - (p.DaDong + numNop.Value) }); gridKetQua_Click(sender, e); MessageBox.Show("Lưu lại 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); } }
/// <summary> /// Cập nhật phiếu ghi danh /// </summary> /// <param name="ph"></param> public static void Update(PHIEUGHIDANH ph) { PHIEUGHIDANH pCu = Select(ph.MaPhieu); pCu.NgayGhiDanh = ph.NgayGhiDanh; pCu.DaDong = ph.DaDong; pCu.ConNo = ph.ConNo; pCu.MaNV = ph.MaNV; Database.SubmitChanges(); }
private void gridViewDSHocVien_Click(object sender, EventArgs e) { try { var rowHandle = gridViewDSHocVien.FocusedRowHandle; this.HocVienId_Select = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHocVien.GetRowCellValue(rowHandle, "HocVienId").ToString()); this.PhieuGhiDanhId_Select = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHocVien.GetRowCellValue(rowHandle, "PhieuGhiDanhId").ToString()); PHIEUGHIDANH _phieugd = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId_Select); lblMaHocVien.Text = _phieugd.HOCVIEN.MaHocVien; lblTenHocVien.Text = _phieugd.HOCVIEN.TenHocVien; lblHocPhi.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.TongTien.ToString()), 0); lblDaDong.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.DaDong.ToString()), 0); lblConNo.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.ConNo.ToString()), 0); lblMienGiam_Tien.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.MienGiam_Tien.ToString()), 0); numDaDong.Text = _phieugd.ConNo.ToString(); //Load danh sach phieu thu PhieuThuFilter _filter = new PhieuThuFilter(); _filter.HocVienId = this.HocVienId_Select; _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select; LoadDanhSachPhieuThu(_filter); //Load dot hoc theo lop hoc if (_phieugd.LopHocId != null && _phieugd.LopHocId != 0) { cboDotHoc.DataSource = DotHocLogic.SelectDotHocChucDongTien(_phieugd.LopHocId ?? 0, this.PhieuGhiDanhId_Select); cboDotHoc.DisplayMember = "TenDotHoc"; cboDotHoc.ValueMember = "DotHocId"; } else { cboDotHoc.DataSource = null; cboDotHoc.DisplayMember = "TenDotHoc"; cboDotHoc.ValueMember = "DotHocId"; } btnInBienLai.Enabled = false; //if (_phieugd.ConNo == 0) //{ // btnLuuLai.Enabled = false; // numDaDong.ReadOnly = true; //} //else //{ // btnLuuLai.Enabled = true; // numDaDong.ReadOnly = false; //} } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); } }
public static bool InsertQLHocPhi_Option1(PHIEUGHIDANH _phieughidanh, PHIEUTHU _phieuthu, HOCPHIHOCVIEN _hocphiHV, ref int _PhieuThuId) { try { using (TransactionScope ts = new TransactionScope()) { //update Phieu ghi danh PHIEUGHIDANH _PGD_select = PhieuGhiDanhLogic.SelectSingle(_phieughidanh.PhieuGhiDanhId); _PGD_select.DaDong = _phieughidanh.DaDong; _PGD_select.ConNo = _phieughidanh.ConNo; _PGD_select.ModifiedDate = DateTime.Now; _PGD_select.ModifiedBy = GlobalSettings.UserCode; _PGD_select.ModifiedLog = GlobalSettings.SessionMyIP; Database.SubmitChanges(); //insert bang PHIEUTHU if (_phieuthu != null && _phieuthu.HocVienId > 0) { _phieuthu.PhieuGhiDanhId = _phieughidanh.PhieuGhiDanhId; _phieuthu.CreatedDate = DateTime.Now; _phieuthu.CreatedBy = GlobalSettings.UserCode; _phieuthu.CreatedLog = GlobalSettings.SessionMyIP; _phieuthu.IsRemove = 0; Database.PHIEUTHUs.InsertOnSubmit(_phieuthu); Database.SubmitChanges(); _PhieuThuId = _phieuthu.PhieuThuId; _phieuthu.MaPhieuThu = string.Format("{0}{1:D7}", "PT", _phieuthu.PhieuThuId); Database.SubmitChanges(); } //Insert HocPhiHocVien if (_phieuthu.PhieuThuId != 0) { _hocphiHV.PhieuThuId = _phieuthu.PhieuThuId; _hocphiHV.CreatedDate = DateTime.Now; _hocphiHV.CreatedBy = GlobalSettings.UserCode; _hocphiHV.CreatedLog = GlobalSettings.SessionMyIP; _hocphiHV.IsRemove = 0; Database.HOCPHIHOCVIENs.InsertOnSubmit(_hocphiHV); Database.SubmitChanges(); } ts.Complete(); return(true); } } catch (System.Exception ex) { return(false); O2S_Common.Logging.LogSystem.Error(ex); } }
private void btnThemVaoLop_Click(object sender, EventArgs e) { try { if (gridViewHV_ChuaXepLop.RowCount > 0) { int _lophocId = O2S_Common.TypeConvert.Parse.ToInt32(cboLopHoc.SelectedValue.ToString()); LOPHOC _lophoc = LopHocLogic.SelectSingle(_lophocId); if (gridViewHV_XepLop.RowCount < _lophoc.SiSoToiDa || MessageBox.Show("Số học viên tối đa của lớp là " + _lophoc.SiSoToiDa + Environment.NewLine + "Bạn có chắc sẽ thêm?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { var rowHandle = gridViewHV_ChuaXepLop.FocusedRowHandle; int _phieughidanhId = O2S_Common.TypeConvert.Parse.ToInt32(gridViewHV_ChuaXepLop.GetRowCellValue(rowHandle, "PhieuGhiDanhId").ToString()); PHIEUGHIDANH _phieuGD = PhieuGhiDanhLogic.SelectSingle(_phieughidanhId); XepLopDTO _hocvienLop = new XepLopDTO(); _hocvienLop.HocVienId = _phieuGD.HocVienId; _hocvienLop.MaHocVien = _phieuGD.HOCVIEN.MaHocVien; _hocvienLop.TenHocVien = _phieuGD.HOCVIEN.TenHocVien; _hocvienLop.PhieuGhiDanhId = _phieuGD.PhieuGhiDanhId; _hocvienLop.MaPhieuGhiDanh = _phieuGD.MaPhieuGhiDanh; _hocvienLop.NgayGhiDanh = _phieuGD.NgayGhiDanh; _hocvienLop.NgaySinh = _phieuGD.HOCVIEN.NgaySinh; _hocvienLop.GioiTinh = _phieuGD.HOCVIEN.GioiTinh; _hocvienLop.DiaChi = _phieuGD.HOCVIEN.DiaChi; _hocvienLop.Sdt = _phieuGD.HOCVIEN.Sdt; _hocvienLop.Email = _phieuGD.HOCVIEN.Email; _hocvienLop.KhoaHocId = _phieuGD.KhoaHocId; _hocvienLop.MaKhoaHoc = _phieuGD.KHOAHOC.MaKhoaHoc; _hocvienLop.TenKhoaHoc = _phieuGD.KHOAHOC.TenKhoaHoc; this.dsXepLopHocVien.Add(_hocvienLop); XepLopDTO _xoa = this.dsChuaCoLop.Where(o => o.PhieuGhiDanhId == _hocvienLop.PhieuGhiDanhId && o.KhoaHocId == _hocvienLop.KhoaHocId).FirstOrDefault(); this.dsChuaCoLop.Remove(_xoa); gridControlHV_ChuaXepLop.DataSource = null; gridControlHV_ChuaXepLop.DataSource = this.dsChuaCoLop; gridControlHV_XepLop.DataSource = null; gridControlHV_XepLop.DataSource = this.dsXepLopHocVien; } } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Warn(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 gridViewDSHocVien_Click(object sender, EventArgs e) { try { var rowHandle = gridViewDSHocVien.FocusedRowHandle; this.HocVienId_Select = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHocVien.GetRowCellValue(rowHandle, "HocVienId").ToString()); this.PhieuGhiDanhId_Select = O2S_Common.TypeConvert.Parse.ToInt32(gridViewDSHocVien.GetRowCellValue(rowHandle, "PhieuGhiDanhId").ToString()); PHIEUGHIDANH _phieugd = PhieuGhiDanhLogic.SelectSingle(this.PhieuGhiDanhId_Select); lblMaHocVien.Text = _phieugd.HOCVIEN.MaHocVien; lblTenHocVien.Text = _phieugd.HOCVIEN.TenHocVien; lblHocPhi.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.TongTien.ToString()), 0); lblDaDong.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.DaDong.ToString()), 0); lblConNo.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.ConNo.ToString()), 0); lblMienGiam_Tien.Text = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_phieugd.MienGiam_Tien.ToString()), 0); numNopThem.Text = _phieugd.ConNo.ToString(); //Load danh sach phieu thu PhieuThuFilter _filter = new PhieuThuFilter(); _filter.HocVienId = this.HocVienId_Select; _filter.PhieuGhiDanhId = this.PhieuGhiDanhId_Select; LoadDanhSachPhieuThu(_filter); btnInBienLai.Enabled = false; if (_phieugd.ConNo == 0) { btnLuuLai.Enabled = false; numNopThem.ReadOnly = true; } else { btnLuuLai.Enabled = true; numNopThem.ReadOnly = false; } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); } }
public static bool UpdateMaPhieuGhiDanh7So() { try { List <PHIEUGHIDANH> _lstHocvien = (from p in GlobalSettings.Database.PHIEUGHIDANHs select p).ToList(); foreach (var item in _lstHocvien) { PHIEUGHIDANH _hocvien = (from p in Database.PHIEUGHIDANHs where p.PhieuGhiDanhId == item.PhieuGhiDanhId select p).FirstOrDefault(); _hocvien.MaPhieuGhiDanh = string.Format("{0}{1:D7}", "PGD", item.PhieuGhiDanhId); Database.SubmitChanges(); } return(true); } catch (Exception ex) { return(false); } }
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); } }
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); } }
private void InBienLaiThuTien(PHIEUTHU _phieuthu) { try { SplashScreenManager.ShowForm(typeof(O2S_Common.Utilities.ThongBao.WaitForm_Wait)); PHIEUGHIDANH _phieughidanh = PhieuGhiDanhLogic.SelectSingle(_phieuthu.PhieuGhiDanhId ?? 0); var rowHandle = gridViewDSHocVien.FocusedRowHandle; List <reportExcelDTO> thongTinThem = new List <reportExcelDTO>(); reportExcelDTO item_MAPHIEUTHU = new reportExcelDTO(); item_MAPHIEUTHU.name = "MAPHIEUTHU"; item_MAPHIEUTHU.value = _phieuthu.MaPhieuThu; thongTinThem.Add(item_MAPHIEUTHU); reportExcelDTO item_MAHOCVIEN = new reportExcelDTO(); item_MAHOCVIEN.name = "MAHOCVIEN"; item_MAHOCVIEN.value = lblMaHocVien.Text; thongTinThem.Add(item_MAHOCVIEN); reportExcelDTO item_TENHOCVIEN = new reportExcelDTO(); item_TENHOCVIEN.name = "TENHOCVIEN"; item_TENHOCVIEN.value = lblTenHocVien.Text; thongTinThem.Add(item_TENHOCVIEN); reportExcelDTO item_DIACHI = new reportExcelDTO(); item_DIACHI.name = "DIACHI"; item_DIACHI.value = gridViewDSHocVien.GetRowCellValue(rowHandle, "DiaChi").ToString(); thongTinThem.Add(item_DIACHI); reportExcelDTO item_KHOAHOC = new reportExcelDTO(); item_KHOAHOC.name = "KHOAHOC"; item_KHOAHOC.value = gridViewDSHocVien.GetRowCellValue(rowHandle, "TenKhoaHoc").ToString(); thongTinThem.Add(item_KHOAHOC); DateTime _namsinh = O2S_Common.TypeConvert.Parse.ToDateTime(gridViewDSHocVien.GetRowCellValue(rowHandle, "NgaySinh").ToString()); reportExcelDTO item_NAMSINH = new reportExcelDTO(); item_NAMSINH.name = "NAMSINH"; item_NAMSINH.value = _namsinh.ToString("dd/MM/yyyy"); thongTinThem.Add(item_NAMSINH); reportExcelDTO item_LOPHOC = new reportExcelDTO(); item_LOPHOC.name = "LOPHOC"; item_LOPHOC.value = gridViewDSHocVien.GetRowCellValue(rowHandle, "TenLopHoc").ToString(); thongTinThem.Add(item_LOPHOC); // reportExcelDTO item_TONGTIEN = new reportExcelDTO() { name = "TONGTIEN", value = O2S_Common.Number.Convert.NumberToString(_phieughidanh.TongTien ?? 0, 0) + " đ", }; thongTinThem.Add(item_TONGTIEN); reportExcelDTO item_MIENGIAM_TIEN = new reportExcelDTO() { name = "MIENGIAM_TIEN", value = O2S_Common.Number.Convert.NumberToString(_phieughidanh.MienGiam_Tien ?? 0, 0) + " đ", }; thongTinThem.Add(item_MIENGIAM_TIEN); reportExcelDTO item_CONNO = new reportExcelDTO() { name = "CONNO", value = O2S_Common.Number.Convert.NumberToString(_phieughidanh.ConNo ?? 0, 0) + " đ", }; thongTinThem.Add(item_CONNO); reportExcelDTO item_SOTIEN = new reportExcelDTO() { name = "SOTIEN", value = O2S_Common.Number.Convert.NumberToString(_phieuthu.SoTien ?? 0, 0) + " đ", }; thongTinThem.Add(item_SOTIEN); reportExcelDTO item_sotienchu = new reportExcelDTO(); item_sotienchu.name = "SOTIENBANGCHU"; item_sotienchu.value = O2S_Common.Strings.Convert.CurrencyToVneseString(O2S_Common.Number.Convert.NumberToNumberRoundAuto(_phieuthu.SoTien ?? 0, 0).ToString()); thongTinThem.Add(item_sotienchu); // DataTable dataExport = new DataTable(); dataExport.Columns.Add("STT", typeof(string)); dataExport.Columns.Add("KHOANTHU", typeof(string)); dataExport.Columns.Add("SOTIEN", typeof(string)); dataExport.Columns.Add("GHICHU", typeof(string)); HocPhiHocVienFilter _filter = new HocPhiHocVienFilter() { PhieuThuId = _phieuthu.PhieuThuId, HocVienId = this.HocVienId_Select, }; List <HocPhiHocVien_PlusDTO> _lsthocPhiHV = HocPhiHocVienLogic.Select(_filter); if (_lsthocPhiHV != null && _lsthocPhiHV.Count > 0) { _lsthocPhiHV.OrderBy(o => o.Stt).ToList(); for (int i = 0; i < _lsthocPhiHV.Count; i++) { DataRow newRow_khac = dataExport.NewRow(); newRow_khac["STT"] = _lsthocPhiHV[i].Stt; newRow_khac["KHOANTHU"] = _lsthocPhiHV[i].TenDichVu == null ? "" : _lsthocPhiHV[i].TenDichVu; newRow_khac["SOTIEN"] = O2S_Common.Number.Convert.NumberToString(O2S_Common.TypeConvert.Parse.ToDecimal(_lsthocPhiHV[i].SoTien.ToString()), 0); newRow_khac["GHICHU"] = _lsthocPhiHV[i].GhiChu == null ? "" : _lsthocPhiHV[i].GhiChu; dataExport.Rows.Add(newRow_khac); } } string fileTemplatePath = LuaChonTemplateInBienLai(_lsthocPhiHV); Utilities.Prints.PrintPreview.ShowPrintPreview_UsingExcelTemplate(fileTemplatePath, thongTinThem, dataExport); } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); } SplashScreenManager.CloseForm(); }
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); } }
public static bool InsertPGDFull(PHIEUGHIDANH _phieughidanh, PHIEUTHU _phieuthu, List <HOCPHIHOCVIEN> _lsthphv, ref int _PhieuGhiDanhId, ref int _PhieuThuId) { try { // O2S_Common.Logging.LogSystem.Error("Luu log InsertPGDFull"); using (TransactionScope ts = new TransactionScope()) { //Phieu ghi danh _phieughidanh.CoSoId = GlobalSettings.CoSoId; _phieughidanh.CreatedDate = DateTime.Now; _phieughidanh.CreatedBy = GlobalSettings.UserCode; _phieughidanh.CreatedLog = GlobalSettings.SessionMyIP; _phieughidanh.IsRemove = 0; Database.PHIEUGHIDANHs.InsertOnSubmit(_phieughidanh); Database.SubmitChanges(); _PhieuGhiDanhId = _phieughidanh.PhieuGhiDanhId; _phieughidanh.MaPhieuGhiDanh = string.Format("{0}{1:D7}", "PGD", _PhieuGhiDanhId); Database.SubmitChanges(); //insert bang PHIEUTHU if (_phieuthu != null && _phieuthu.HocVienId > 0) { _phieuthu.PhieuGhiDanhId = _PhieuGhiDanhId; _phieuthu.CreatedDate = DateTime.Now; _phieuthu.CreatedBy = GlobalSettings.UserCode; _phieuthu.CreatedLog = GlobalSettings.SessionMyIP; _phieuthu.IsRemove = 0; Database.PHIEUTHUs.InsertOnSubmit(_phieuthu); Database.SubmitChanges(); _PhieuThuId = _phieuthu.PhieuThuId; _phieuthu.MaPhieuThu = string.Format("{0}{1:D7}", "PT", _phieuthu.PhieuThuId); Database.SubmitChanges(); } //Hocphihocvien if (_lsthphv != null && _lsthphv.Count > 0) { foreach (var item in _lsthphv) { item.PhieuGhiDanhId = _PhieuGhiDanhId; item.PhieuThuId = _phieuthu.PhieuThuId; item.CreatedDate = DateTime.Now; item.CreatedBy = GlobalSettings.UserCode; item.CreatedLog = GlobalSettings.SessionMyIP; item.IsRemove = 0; Database.HOCPHIHOCVIENs.InsertOnSubmit(item); Database.SubmitChanges(); } } //Update HOCVIEN = Hoc vien chinh thuc HOCVIEN _hocvien = HocVienLogic.SelectSingle(_phieughidanh.HocVienId ?? 0); _hocvien.LOAIHOCVIEN = LoaiHocVienLogic.Select(KeySetting.LOAIHOCVIEN_CHINHTHUC); //Database.SubmitChanges(); //Update TAIKHOAN = được sử dụng TAIKHOAN _taikhoan = TaiKhoanLogic.SelectTheoTenDangNhap(_hocvien.MaHocVien); _taikhoan.IsRemove = 0; Database.SubmitChanges(); ts.Complete(); return(true); } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); return(false); } }
/// <summary> /// Thêm phiếu ghi danh /// </summary> /// <param name="p"></param> public static void Insert(PHIEUGHIDANH p) { Database.PHIEUGHIDANHs.InsertOnSubmit(p); Database.SubmitChanges(); }
public static bool InsertPGDFull_XepLop(PHIEUGHIDANH _phieughidanh, PHIEUTHU _phieuthu, List <HOCPHIHOCVIEN> _lsthphv, BANGDIEM _bangdiem, ref int _PhieuGhiDanhId, ref int _PhieuThuId) { try { // O2S_Common.Logging.LogSystem.Error("Luu log InsertPGDFull"); using (TransactionScope ts = new TransactionScope()) { //Phieu ghi danh _phieughidanh.CoSoId = GlobalSettings.CoSoId; _phieughidanh.CreatedDate = DateTime.Now; _phieughidanh.CreatedBy = GlobalSettings.UserCode; _phieughidanh.CreatedLog = GlobalSettings.SessionMyIP; _phieughidanh.IsRemove = 0; Database.PHIEUGHIDANHs.InsertOnSubmit(_phieughidanh); Database.SubmitChanges(); _PhieuGhiDanhId = _phieughidanh.PhieuGhiDanhId; _phieughidanh.MaPhieuGhiDanh = string.Format("{0}{1:D7}", "PGD", _PhieuGhiDanhId); Database.SubmitChanges(); //insert bang PHIEUTHU if (_phieuthu != null && _phieuthu.HocVienId > 0) { _phieuthu.PhieuGhiDanhId = _PhieuGhiDanhId; _phieuthu.CreatedDate = DateTime.Now; _phieuthu.CreatedBy = GlobalSettings.UserCode; _phieuthu.CreatedLog = GlobalSettings.SessionMyIP; _phieuthu.IsRemove = 0; Database.PHIEUTHUs.InsertOnSubmit(_phieuthu); Database.SubmitChanges(); _PhieuThuId = _phieuthu.PhieuThuId; _phieuthu.MaPhieuThu = string.Format("{0}{1:D7}", "PT", _phieuthu.PhieuThuId); Database.SubmitChanges(); } //Hocphihocvien if (_lsthphv != null && _lsthphv.Count > 0) { foreach (var item in _lsthphv) { item.PhieuGhiDanhId = _PhieuGhiDanhId; item.PhieuThuId = _phieuthu.PhieuThuId; item.CreatedDate = DateTime.Now; item.CreatedBy = GlobalSettings.UserCode; item.CreatedLog = GlobalSettings.SessionMyIP; item.IsRemove = 0; Database.HOCPHIHOCVIENs.InsertOnSubmit(item); Database.SubmitChanges(); } } //insert BANGDIEM if (_bangdiem.LopHocId != 0) { _bangdiem.PhieuGhiDanhId = _PhieuGhiDanhId; _bangdiem.CreatedDate = DateTime.Now; _bangdiem.CreatedBy = GlobalSettings.UserCode; _bangdiem.CreatedLog = GlobalSettings.SessionMyIP; _bangdiem.IsRemove = 0; Database.BANGDIEMs.InsertOnSubmit(_bangdiem); Database.SubmitChanges(); int _id = _bangdiem.BangDiemId; //Insert Bang diem chi tiet List <KHOAHOC_MONHOC> _khmh = KhoaHocMonHocLogic.SelectTheoKhoaHoc(_bangdiem.KhoaHocId); foreach (var item in _khmh) { BANGDIEMCHITIET _chitiet = new BANGDIEMCHITIET(); _chitiet.BangDiemId = _id; _chitiet.MonHocId = item.MonHocId ?? 0; _chitiet.TenMonHoc = item.TenMonHoc; _chitiet.IsRemove = 0; //_chitiet.CreatedDate = DateTime.Now; //_chitiet.CreatedBy = GlobalSettings.UserCode; //_chitiet.CreatedLog = GlobalSettings.SessionMyIP; Database.BANGDIEMCHITIETs.InsertOnSubmit(_chitiet); Database.SubmitChanges(); } //Update SiSo cua LOPHOC LOPHOC _lophoc = LopHocLogic.SelectSingle(_bangdiem.LopHocId); LopHocLogic.Update(new LOPHOC() { //LopHocId = _lophoc.LopHocId, //TenLopHoc = _lophoc.TenLopHoc, //NgayBatDau = _lophoc.NgayBatDau, //NgayKetThuc = _lophoc.NgayKetThuc, //SiSoToiDa = _lophoc.SiSoToiDa, SiSo = _lophoc.SiSo + 1, //KhoaHocId = _lophoc.KhoaHocId, //IsLock = _lophoc.IsLock }); } //Update HOCVIEN = Hoc vien chinh thuc HOCVIEN _hocvien = HocVienLogic.SelectSingle(_phieughidanh.HocVienId ?? 0); _hocvien.LOAIHOCVIEN = LoaiHocVienLogic.Select(KeySetting.LOAIHOCVIEN_CHINHTHUC); //Database.SubmitChanges(); //Update TAIKHOAN = được sử dụng TAIKHOAN _taikhoan = TaiKhoanLogic.SelectTheoTenDangNhap(_hocvien.MaHocVien); _taikhoan.IsRemove = 0; Database.SubmitChanges(); ts.Complete(); return(true); } } catch (Exception ex) { O2S_Common.Logging.LogSystem.Error(ex); return(false); } }
public static bool XoaPhieuGhiDanh(PHIEUGHIDANH _phieuGD) { try { using (TransactionScope ts = new TransactionScope()) { //xoa HOCPHIHOCVIEN List <HOCPHIHOCVIEN> _lstHPHV = HocPhiHocVienLogic.SelectTheoPhieuGhiDanh(_phieuGD.PhieuGhiDanhId); if (_lstHPHV != null && _lstHPHV.Count > 0) { Database.HOCPHIHOCVIENs.DeleteAllOnSubmit(_lstHPHV); //Database.SubmitChanges(); } //Xoa bang PHIEUTHU; List <PHIEUTHU> _lstPhieuThu = PhieuThuLogic.SelectTheoPhieuGhiDanh(_phieuGD.PhieuGhiDanhId); if (_lstPhieuThu != null && _lstPhieuThu.Count > 0) { Database.PHIEUTHUs.DeleteAllOnSubmit(_lstPhieuThu); // Database.SubmitChanges(); } //update=Xoa bang PHIEUGHIDANH //PHIEUGHIDANH _phieuGDUpdate = SelectSingle(_phieuGD.PhieuGhiDanhId); _phieuGD.IsRemove = _phieuGD.IsRemove; _phieuGD.LyDoXoa = _phieuGD.LyDoXoa; _phieuGD.NguoiXoa = _phieuGD.NguoiXoa; _phieuGD.ModifiedDate = DateTime.Now; _phieuGD.ModifiedBy = GlobalSettings.UserCode; _phieuGD.ModifiedLog = GlobalSettings.SessionMyIP; //Database.SubmitChanges(); //cap nhat bang HOCVIEN va bang tai khoan: kiem tra HV hoc khoa nao ko? neu=1 thi update PhieuGhiDanhFilter _filter = new PhieuGhiDanhFilter(); _filter.HocVienId = _phieuGD.HocVienId; List <PhieuGhiDanh_PlusDTO> _PGD_Kiemtra = PhieuGhiDanhLogic.Select(_filter); if (_PGD_Kiemtra == null || _PGD_Kiemtra.Count <= 1) { HOCVIEN _hocvien = HocVienLogic.SelectSingle(_phieuGD.HocVienId ?? 0); _hocvien.LOAIHOCVIEN = LoaiHocVienLogic.Select(KeySetting.LOAIHOCVIEN_TIEMNANG); Database.SubmitChanges(); TAIKHOAN _taikhoan = TaiKhoanLogic.SelectTheoTenDangNhap(_hocvien.TAIKHOAN.TenDangNhap); _taikhoan.IsRemove = 1; //Database.SubmitChanges(); } //Kiem tra lop hoc va xoa bang diem List <BANGDIEM> _bangdiem = BangDiemLogic.SelectTheoPhieuGhiDanh(_phieuGD.PhieuGhiDanhId); if (_bangdiem != null && _bangdiem.Count > 0) { Database.BANGDIEMs.DeleteAllOnSubmit(_bangdiem); //Update So luong hoc vien trong lop hoc... LOPHOC _lopHoc = LopHocLogic.SelectSingle(_phieuGD.LopHocId ?? 0); if (_lopHoc != null) { _lopHoc.SiSo = (from p in Database.BANGDIEMs where p.LopHocId == (_phieuGD.LopHocId ?? 0) && p.IsRemove != 1 select p).Count(); _lopHoc.ModifiedDate = DateTime.Now; _lopHoc.ModifiedBy = GlobalSettings.UserCode; _lopHoc.ModifiedLog = GlobalSettings.SessionMyIP; Database.SubmitChanges(); } } Database.SubmitChanges(); ts.Complete(); return(true); } } catch (System.Exception ex) { return(false); O2S_Common.Logging.LogSystem.Error(ex); } }