private void LapBienLaiThuTien(DataTable dtDinhMuc, int IDSV_SinhVien) { // Them bien lai thu tien pTC_BienLaiThuTienInfo = new TC_BienLaiThuTienInfo(); pTC_BienLaiThuTienInfo.GhiChu = ""; pTC_BienLaiThuTienInfo.HocKy = Program.HocKy; pTC_BienLaiThuTienInfo.IDDM_NamHoc = Program.IDNamHoc; pTC_BienLaiThuTienInfo.IDHT_NguoiThu = Program.objUserCurrent.HT_UserID; pTC_BienLaiThuTienInfo.IDSV_SinhVien = IDSV_SinhVien; pTC_BienLaiThuTienInfo.IDDM_Lop = pDM_LopInfo.DM_LopID; pTC_BienLaiThuTienInfo.NgayThu = DateTime.Now; pTC_BienLaiThuTienInfo.NoiDung = "THU TIỀN HỌC KỲ " + Program.HocKy.ToString() + " NĂM HỌC " + Program.NamHoc; pTC_BienLaiThuTienInfo.PhieuThu = true; pTC_BienLaiThuTienInfo.Printed = false; pTC_BienLaiThuTienInfo.SoPhieu = GetSoPhieu(Program.HocKy, Program.IDNamHoc, IDSV_SinhVien, pDM_LopInfo.IDDM_DiaDiem); //dtDinhMuc.Columns[3]. pTC_BienLaiThuTienInfo.SoTien = SumColumnValue(dtDinhMuc, "SoTien"); pTC_BienLaiThuTienInfo.SoTienBangChu = clsStrHelper.ReadMoney(pTC_BienLaiThuTienInfo.SoTien) + " đồng"; pTC_BienLaiThuTienInfo.PhieuHuy = false; pTC_BienLaiThuTienInfo.NgayHuy = DateTime.Parse("1/1/1900"); int intTC_BienLaiThuTienID = oBTC_BienLaiThuTien.Add(pTC_BienLaiThuTienInfo); // them bien lai thu tien chi tiet foreach (DataRow mdr in dtDinhMuc.Rows) { if (float.Parse("0" + mdr["SoTien"].ToString()) > 0 && mdr["TC_LoaiThuChiID"].ToString() != "") { pTC_BienLaiThuTien_ChiTietInfo = new TC_BienLaiThuTien_ChiTietInfo(); pTC_BienLaiThuTien_ChiTietInfo.IDTC_BienLaiThuTien = intTC_BienLaiThuTienID; pTC_BienLaiThuTien_ChiTietInfo.IDTC_DinhMucThuSinhVien = int.Parse("0" + mdr["IDTC_DinhMucThuSinhVien"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.IDTC_LoaiThuChi = int.Parse(mdr["TC_LoaiThuChiID"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.LanThu = int.Parse("0" + mdr["LanThu"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.NoiDung = mdr["NoiDung"].ToString(); pTC_BienLaiThuTien_ChiTietInfo.SoTien = float.Parse("0" + mdr["SoTien"].ToString()); oBTC_BienLaiThuTien_ChiTiet.Add(pTC_BienLaiThuTien_ChiTietInfo); } } }
private void btnLuu_Click(object sender, EventArgs e) { if (!Check_Valid()) { return; } if (dtLoaiThuChi != null && dtLoaiThuChi.Rows.Count > 0) { if (Sua == false) { // Them bien lai thu tien pTC_BienLaiThuTienInfo.GhiChu = ""; pTC_BienLaiThuTienInfo.HocKy = Program.HocKy; pTC_BienLaiThuTienInfo.IDDM_NamHoc = Program.IDNamHoc; pTC_BienLaiThuTienInfo.IDHT_NguoiThu = Program.objUserCurrent.HT_UserID; pTC_BienLaiThuTienInfo.IDSV_SinhVien = SV_SinhVienID; pTC_BienLaiThuTienInfo.IDDM_Lop = IDDM_Lop; pTC_BienLaiThuTienInfo.NgayThu = DateTime.Parse(dtpNgay.EditValue.ToString()); pTC_BienLaiThuTienInfo.NoiDung = txtNoiDung.Text.Trim(); pTC_BienLaiThuTienInfo.PhieuThu = (rdThuChi.SelectedIndex == 0 ? true : false); pTC_BienLaiThuTienInfo.Printed = false; pTC_BienLaiThuTienInfo.SoPhieu = txtSoPhieu.Text.Trim(); pTC_BienLaiThuTienInfo.SoTien = float.Parse("0" + lbTotal.Text.Trim()); pTC_BienLaiThuTienInfo.SoTienBangChu = lbTienBangChu.Text; pTC_BienLaiThuTienInfo.PhieuHuy = false; pTC_BienLaiThuTienInfo.NgayHuy = DateTime.Parse("1/1/1900"); int intTC_BienLaiThuTienID = oBTC_BienLaiThuTien.Add(pTC_BienLaiThuTienInfo); // them bien lai thu tien chi tiet foreach (DataRow mdr in dtLoaiThuChi.Rows) { if (float.Parse("0" + mdr["SoTien"].ToString()) > 0 && mdr["TC_LoaiThuChiID"].ToString() != "") { pTC_BienLaiThuTien_ChiTietInfo.IDTC_BienLaiThuTien = intTC_BienLaiThuTienID; pTC_BienLaiThuTien_ChiTietInfo.IDTC_DinhMucThuSinhVien = int.Parse("0" + mdr["IDTC_DinhMucThuSinhVien"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.IDTC_LoaiThuChi = int.Parse(mdr["TC_LoaiThuChiID"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.LanThu = int.Parse("0" + mdr["LanThu"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.NoiDung = mdr["NoiDung"].ToString(); pTC_BienLaiThuTien_ChiTietInfo.SoTien = float.Parse("0" + mdr["SoTien"].ToString()); oBTC_BienLaiThuTien_ChiTiet.Add(pTC_BienLaiThuTien_ChiTietInfo); } } } else if (Sua == true && dr != null) { // update bien lai thu tien pTC_BienLaiThuTienInfo.GhiChu = ""; pTC_BienLaiThuTienInfo.HocKy = Program.HocKy; pTC_BienLaiThuTienInfo.IDDM_NamHoc = Program.IDNamHoc; pTC_BienLaiThuTienInfo.IDHT_NguoiThu = Program.objUserCurrent.HT_UserID; pTC_BienLaiThuTienInfo.IDSV_SinhVien = SV_SinhVienID; pTC_BienLaiThuTienInfo.NgayThu = DateTime.Parse(dtpNgay.EditValue.ToString()); pTC_BienLaiThuTienInfo.NoiDung = txtNoiDung.Text.Trim(); pTC_BienLaiThuTienInfo.PhieuThu = (rdThuChi.SelectedIndex == 0 ? true : false); pTC_BienLaiThuTienInfo.Printed = false; pTC_BienLaiThuTienInfo.SoPhieu = txtSoPhieu.Text.Trim(); pTC_BienLaiThuTienInfo.SoTien = float.Parse("0" + lbTotal.Text.Trim()); pTC_BienLaiThuTienInfo.SoTienBangChu = lbTienBangChu.Text; pTC_BienLaiThuTienInfo.PhieuHuy = false; pTC_BienLaiThuTienInfo.NgayHuy = DateTime.Parse("1/1/1900"); pTC_BienLaiThuTienInfo.TC_BienLaiThuTienID = int.Parse(dr["TC_BienLaiThuTienID"].ToString()); oBTC_BienLaiThuTien.Update(pTC_BienLaiThuTienInfo); try { oBTC_BienLaiThuTien_ChiTiet.DeleteBy_BienLaiThuTien(pTC_BienLaiThuTienInfo.TC_BienLaiThuTienID); } catch { } // them bien lai thu tien chi tiet foreach (DataRow mdr in dtLoaiThuChi.Rows) { if (float.Parse("0" + mdr["SoTien"].ToString()) > 0 && mdr["TC_LoaiThuChiID"].ToString() != "") { pTC_BienLaiThuTien_ChiTietInfo.IDTC_BienLaiThuTien = pTC_BienLaiThuTienInfo.TC_BienLaiThuTienID; pTC_BienLaiThuTien_ChiTietInfo.IDTC_DinhMucThuSinhVien = int.Parse("0" + mdr["IDTC_DinhMucThuSinhVien"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.IDTC_LoaiThuChi = int.Parse(mdr["TC_LoaiThuChiID"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.LanThu = int.Parse("0" + mdr["LanThu"].ToString()); pTC_BienLaiThuTien_ChiTietInfo.NoiDung = mdr["NoiDung"].ToString(); pTC_BienLaiThuTien_ChiTietInfo.SoTien = float.Parse(mdr["SoTien"].ToString()); oBTC_BienLaiThuTien_ChiTiet.Add(pTC_BienLaiThuTien_ChiTietInfo); } } } this.Tag = "1"; ThongBao("Lưu thông tin thành công!"); if (chkInKhiLuu.Checked) { btnIn_Click(null, null); this.Close(); } if (Sua == false) { GetSoPhieu(Program.HocKy, Program.IDNamHoc, SV_SinhVienID, IDDM_DiaDiem); ClearText(); } } else { ThongBao("Không có dữ liệu để lưu!"); } }