private Dictionary <int, QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow> evaluatePrevMonthViewBangThuTienTable(DateTime ngayTinh, int hocSinhId) { ViewBangThuTienTableAdapter viewBangThuTienTableAdapter = (ViewBangThuTienTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterViewBangThuTien); BangThuTienKhoanThuTableAdapter bangThuTienKhoanThuTableAdapter = (BangThuTienKhoanThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterBangThuTienKhoanThu); PhieuThuTableAdapter phieuThuTableAdapter = (PhieuThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterPhieuThu); Dictionary <int, QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow> prevMonthRowDictionary = null; QLMamNon.Dao.QLMamNonDs.ViewBangThuTienDataTable prevMonthBangThuTienTable = viewBangThuTienTableAdapter.GetDataByNgayTinhAndHocSinhId(ngayTinh, hocSinhId); List <int> prevMonthBangThuTienIds = new List <int>(prevMonthBangThuTienTable.Rows.Count); foreach (QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow row in prevMonthBangThuTienTable) { prevMonthBangThuTienIds.Add(row.BangThuTienId); } if (!ListUtil.IsEmpty(prevMonthBangThuTienIds)) { QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuDataTable prevMonthBTTKTDataTable = bangThuTienKhoanThuTableAdapter.GetBangThuTienKhoanThuByBangThuTienIds(String.Join(",", prevMonthBangThuTienIds)); QLMamNon.Dao.QLMamNonDs.PhieuThuDataTable prevMonthPhieuThuDataTable = phieuThuTableAdapter.GetDataByHocSinhIdAndNgayTinh(-1, ngayTinh); prevMonthRowDictionary = new Dictionary <int, Dao.QLMamNonDs.ViewBangThuTienRow>(); foreach (QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow row in prevMonthBangThuTienTable) { BangThuTienUtil.EvaluateValuesForViewBangThuTienRow(row, null, prevMonthBTTKTDataTable, prevMonthPhieuThuDataTable, true, false, true); prevMonthRowDictionary.Add(row.HocSinhId, row); } } return(prevMonthRowDictionary); }
public static void EvaluateValuesForViewBangThuTienRow(QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow row, QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow bangThuTienThangTruocRow, QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuDataTable bTTKTDataTable, QLMamNon.Dao.QLMamNonDs.PhieuThuDataTable phieuThuDataTable, bool ignoreTruyThu, bool isCalculateAnSangAnToi, bool isCalculateHocPhi) { evaluateValuesForAdditionalFields(row, bTTKTDataTable, isCalculateAnSangAnToi, isCalculateHocPhi); evaluateValuesForTienNop(row, phieuThuDataTable); if (!ignoreTruyThu) { row.SoTienTruyThu = BangThuTienUtil.CalculateTruyThu(row, bangThuTienThangTruocRow); } CalculateSummaryFields(row); }
private void addPhieuThuToReport(SortedList soQuyTienMatMap, DateTime fromDate, DateTime toDate, List <int> phanLoaiThuIds) { PhieuThuTableAdapter phieuThuTableAdapter = (PhieuThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterPhieuThu); QLMamNon.Dao.QLMamNonDs.PhieuThuDataTable phieuThuDataTable = phieuThuTableAdapter.GetDataForSoQuyTienMat(fromDate, toDate, StringUtil.JoinWithCommas(phanLoaiThuIds)); Dictionary <string, SoQuyTienMatItem> groupDateToSoQuyTienMatItemsMap = new Dictionary <string, SoQuyTienMatItem>(); foreach (QLMamNon.Dao.QLMamNonDs.PhieuThuRow phieuThuRow in phieuThuDataTable) { phieuThuRow.PhanLoaiThu = phieuThuRow.IsPhanLoaiThuIdNull() ? "Thu tiền học phí" : StaticDataUtil.GetPhanLoaiThuById(phieuThuRow.PhanLoaiThuId); int groupDate = getGroupDate(fromDate, phieuThuRow); DateTime dateOfGroup = fromDate.AddDays((groupDate + 1) * NumberOfDateToGroupPhieuThu - 1); if (dateOfGroup > toDate) { dateOfGroup = toDate; } string key = StringUtil.Join(new int[] { groupDate, phieuThuRow.PhanLoaiThuId }, "~"); if (!groupDateToSoQuyTienMatItemsMap.ContainsKey(key)) { groupDateToSoQuyTienMatItemsMap.Add(key, new SoQuyTienMatItem() { DienGiai = phieuThuRow.PhanLoaiThu, NgayChungTu = dateOfGroup, SoTienThu = 0 }); } } foreach (QLMamNon.Dao.QLMamNonDs.PhieuThuRow phieuThuRow in phieuThuDataTable) { int groupDate = getGroupDate(fromDate, phieuThuRow); string key = StringUtil.Join(new int[] { groupDate, phieuThuRow.PhanLoaiThuId }, "~"); SoQuyTienMatItem soQuyTienMatItemThu = groupDateToSoQuyTienMatItemsMap[key]; soQuyTienMatItemThu.SoTienThu += phieuThuRow.SoTien; } int addedCount = 0; foreach (SoQuyTienMatItem soQuyTienMatItemThu in groupDateToSoQuyTienMatItemsMap.Values) { soQuyTienMatMap.Add(soQuyTienMatItemThu.NgayChungTu.AddMilliseconds(addedCount++), soQuyTienMatItemThu); } }
public QLMamNon.Dao.QLMamNonDs.PhieuThuDataTable LoadPhieuThu(HocSinhDataTable hocSinhTable) { PhieuThuTableAdapter phieuThuTableAdapter = (PhieuThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterPhieuThu); PhieuThuDataTable table = phieuThuTableAdapter.GetData(); foreach (PhieuThuRow row in table) { if (!row.IsHocSinhIdNull()) { row.HocSinh = StaticDataUtil.GetHocSinhFullNameByHocSinhId(hocSinhTable, row.HocSinhId); } if (!row.IsPhanLoaiThuIdNull()) { row.PhanLoaiThu = StaticDataUtil.GetPhanLoaiThuById(row.PhanLoaiThuId); } } return(table); }
private void updateSoTienTruyThuForBangThuTienNextMonths(DateTime ngay, int hocSinhId) { ViewBangThuTienTableAdapter viewBangThuTienTableAdapter = (ViewBangThuTienTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterViewBangThuTien); BangThuTienKhoanThuTableAdapter bangThuTienKhoanThuTableAdapter = (BangThuTienKhoanThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterBangThuTienKhoanThu); PhieuThuTableAdapter phieuThuTableAdapter = (PhieuThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterPhieuThu); QLMNDaoJobInvoker qlmnDaoJobInvoker = new QLMNDaoJobInvoker(); qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTienCommand = new UpdateSoTienTruyThuOfBangThuTienCommand(); qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTienCommand.CommandParameter.Add(UpdateSoTienTruyThuOfBangThuTienCommand.ParameterViewBangThuTienTableAdapter, viewBangThuTienTableAdapter); QLMamNon.Dao.QLMamNonDs.ViewBangThuTienDataTable table = viewBangThuTienTableAdapter.GetDataByNgayTinhAndHocSinhId(ngay.AddMonths(1), hocSinhId); if (ListUtil.IsEmpty(table.Rows)) { return; } QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow viewBangThuTienRow = table[0]; QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuDataTable bTTKTDataTable = bangThuTienKhoanThuTableAdapter.GetBangThuTienKhoanThuByBangThuTienIds(viewBangThuTienRow.BangThuTienId.ToString()); QLMamNon.Dao.QLMamNonDs.PhieuThuDataTable phieuThuDataTable = phieuThuTableAdapter.GetDataByHocSinhIdAndNgayTinh(-1, ngay); Dictionary <int, QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow> prevMonthRowDictionary = evaluatePrevMonthViewBangThuTienTable(ngay.AddMonths(-1), hocSinhId); BangThuTienUtil.EvaluateValuesForViewBangThuTienRow(viewBangThuTienRow, prevMonthRowDictionary != null && prevMonthRowDictionary.ContainsKey(viewBangThuTienRow.HocSinhId) ? prevMonthRowDictionary[viewBangThuTienRow.HocSinhId] : null, bTTKTDataTable, phieuThuDataTable, false, false, true); if (viewBangThuTienRow[ViewBangThuTienFieldName.ThanhTien, DataRowVersion.Original] != DBNull.Value && viewBangThuTienRow[ViewBangThuTienFieldName.ThanhTien, DataRowVersion.Current] != DBNull.Value) { long originalVersionToCompare = (long)viewBangThuTienRow[ViewBangThuTienFieldName.ThanhTien, DataRowVersion.Original]; long currentVersionToCompare = (long)viewBangThuTienRow[ViewBangThuTienFieldName.ThanhTien, DataRowVersion.Current]; if (originalVersionToCompare != currentVersionToCompare) { qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTienCommand.CommandParameter.Remove(UpdateSoTienTruyThuOfBangThuTienCommand.ParameterCurrentViewBangThuTien); qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTienCommand.CommandParameter.Remove(UpdateSoTienTruyThuOfBangThuTienCommand.ParameterSoTienAdded); qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTienCommand.CommandParameter.Add(UpdateSoTienTruyThuOfBangThuTienCommand.ParameterCurrentViewBangThuTien, viewBangThuTienRow); qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTienCommand.CommandParameter.Add(UpdateSoTienTruyThuOfBangThuTienCommand.ParameterSoTienAdded, currentVersionToCompare - originalVersionToCompare); qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTien(); } } }
private List <ViewBangThuTienRow> loadViewBangThuTiensToanTruong(DateTime toDate, int?lopId) { ViewBangThuTienTableAdapter viewBangThuTienTableAdapter = (ViewBangThuTienTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterViewBangThuTien); BangThuTienKhoanThuTableAdapter bangThuTienKhoanThuTableAdapter = (BangThuTienKhoanThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterBangThuTienKhoanThu); PhieuThuTableAdapter phieuThuTableAdapter = (PhieuThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterPhieuThu); ViewBangThuTienDataTable table = viewBangThuTienTableAdapter.GetViewBangThuTienByNgayTinhAndLop(toDate, lopId); List <int> bangThuTienIds = new List <int>(table.Rows.Count); foreach (ViewBangThuTienRow row in table) { bangThuTienIds.Add(row.BangThuTienId); } if (!ListUtil.IsEmpty(bangThuTienIds)) { QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuDataTable bTTKTDataTable = bangThuTienKhoanThuTableAdapter.GetBangThuTienKhoanThuByBangThuTienIds(String.Join(",", bangThuTienIds)); QLMamNon.Dao.QLMamNonDs.PhieuThuDataTable phieuThuDataTable = phieuThuTableAdapter.GetDataByHocSinhIdAndNgayTinh(-1, toDate); Dictionary <int, ViewBangThuTienRow> prevMonthRowDictionary = this.EvaluatePrevMonthViewBangThuTienTable(toDate.AddMonths(-1), lopId); HocSinhDataTable hocSinhDataTable = this.getHocSinhData(); foreach (ViewBangThuTienRow row in table) { row.HoTen = StaticDataUtil.GetHocSinhFullNameByHocSinhId(hocSinhDataTable, row.HocSinhId); BangThuTienUtil.EvaluateValuesForViewBangThuTienRow(row, prevMonthRowDictionary != null && prevMonthRowDictionary.ContainsKey(row.HocSinhId) ? prevMonthRowDictionary[row.HocSinhId] : null, bTTKTDataTable, phieuThuDataTable, false, false, true); } } List <ViewBangThuTienRow> viewBangThuTienRows = new List <Dao.QLMamNonDs.ViewBangThuTienRow>(); foreach (ViewBangThuTienRow row in table) { viewBangThuTienRows.Add(row); } return(viewBangThuTienRows); }
private void loadViewBangThuTiens(DateTime ngayTinh, int lop) { if (this.isNeedToGenerateSoThuTiens(ngayTinh, lop, false)) { this.showFormGenerateSoThuTiens(true); return; } ViewBangThuTienDataTable table = viewBangThuTienTableAdapter.GetViewBangThuTienByNgayTinhAndLop(ngayTinh, lop); List <int> bangThuTienIds = new List <int>(table.Rows.Count); foreach (ViewBangThuTienRow row in table) { bangThuTienIds.Add(row.BangThuTienId); } if (!ListUtil.IsEmpty(bangThuTienIds)) { bTTKTDataTable = bangThuTienKhoanThuTableAdapter.GetBangThuTienKhoanThuByBangThuTienIds(String.Join(",", bangThuTienIds)); phieuThuDataTable = phieuThuTableAdapter.GetDataByHocSinhIdAndNgayTinh(-1, ngayTinh); SoThuTienService soThuTienService = new SoThuTienService(); prevMonthRowDictionary = soThuTienService.EvaluatePrevMonthViewBangThuTienTable(ngayTinh.AddMonths(-1), lop); foreach (ViewBangThuTienRow row in table) { row.HoTen = StaticDataUtil.GetHocSinhFullNameByHocSinhId(hocSinhDataTable, row.HocSinhId); BangThuTienUtil.EvaluateValuesForViewBangThuTienRow(row, prevMonthRowDictionary != null && prevMonthRowDictionary.ContainsKey(row.HocSinhId) ? prevMonthRowDictionary[row.HocSinhId] : null, bTTKTDataTable, phieuThuDataTable, false, false, true); row.AcceptChanges(); } } this.viewBangThuTienRowBindingSource.DataSource = table; this.DataTable = table; }
public List <BangKeThuTienItem> GetBangKeTongHopThuTien(DateTime toDate, int?lopId) { List <ViewBangThuTienRow> viewBangThuTienRows = this.loadViewBangThuTiensToanTruong(toDate, lopId); List <ViewBangThuTienRow> rows = EvaluateViewBangThuTienRowsForReport(viewBangThuTienRows, toDate); List <BangKeThuTienItem> rowsToDisplay = new List <BangKeThuTienItem>(); Dictionary <int, ViewBangThuTienRow> hocSinhIdsToViewBangThuTienRows = new Dictionary <int, ViewBangThuTienRow>(); foreach (ViewBangThuTienRow viewBangThuTienRow in rows) { if (!hocSinhIdsToViewBangThuTienRows.ContainsKey(viewBangThuTienRow.HocSinhId)) { hocSinhIdsToViewBangThuTienRows.Add(viewBangThuTienRow.HocSinhId, viewBangThuTienRow); } } if (ListUtil.IsEmpty(hocSinhIdsToViewBangThuTienRows)) { return(rowsToDisplay); } PhieuThuTableAdapter phieuThuTableAdapter = (PhieuThuTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterPhieuThu); QLMamNon.Dao.QLMamNonDs.PhieuThuDataTable phieuThuDataTable = phieuThuTableAdapter.GetDataOfMonthByHocSinhIdsAndNgay(StringUtil.Join(new List <int>(hocSinhIdsToViewBangThuTienRows.Keys), ","), toDate); int stt = 1; foreach (PhieuThuRow phieuThuRow in phieuThuDataTable) { ViewBangThuTienRow viewBangThuTienRow = hocSinhIdsToViewBangThuTienRows[phieuThuRow.HocSinhId]; BangKeThuTienItem bangKeThuTienItem = new BangKeThuTienItem() { STT = stt++, HocSinhId = viewBangThuTienRow.HocSinhId, HoTen = viewBangThuTienRow.HoTen, Lop = viewBangThuTienRow.Lop, NgayNop = phieuThuRow.Ngay, SoBienLai = phieuThuRow.MaPhieu, PhuPhi = viewBangThuTienRow.PhuPhi, BanTru = viewBangThuTienRow.BanTru, HocPhi = viewBangThuTienRow.HocPhi, AnChinh = viewBangThuTienRow.TienAnSua, AnSang = viewBangThuTienRow.SoTienAnSangConLai, AnToi = viewBangThuTienRow.SoTienAnToiConLai, NangKhieu = viewBangThuTienRow.SoTienNangKhieu, DoDung = viewBangThuTienRow.SoTienDoDung, DieuHoa = viewBangThuTienRow.SoTienDieuHoa, TruyThu = viewBangThuTienRow.SoTienTruyThu, PhaiThu = viewBangThuTienRow.ThanhTien, DaThu = phieuThuRow.SoTien, ConNo = viewBangThuTienRow.ThanhTien - phieuThuRow.SoTien }; if (!ListUtil.IsEmpty(rowsToDisplay)) { BangKeThuTienItem prevBangKeThuTienItem = rowsToDisplay[rowsToDisplay.Count - 1]; if (prevBangKeThuTienItem.HocSinhId == bangKeThuTienItem.HocSinhId) { bangKeThuTienItem.TruyThu = prevBangKeThuTienItem.ConNo; bangKeThuTienItem.PhaiThu = prevBangKeThuTienItem.ConNo; bangKeThuTienItem.ConNo = bangKeThuTienItem.PhaiThu - bangKeThuTienItem.DaThu; } } rowsToDisplay.Add(bangKeThuTienItem); } return(rowsToDisplay); }
private static void evaluateValuesForTienNop(QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow row, QLMamNon.Dao.QLMamNonDs.PhieuThuDataTable phieuThuDataTable) { row.SoTienNopLan1 = 0; row.SoTienNopLan2 = 0; QLMamNon.Dao.QLMamNonDs.PhieuThuRow[] phieuThuRows = phieuThuDataTable.Select(String.Format("HocSinhId={0}", row.HocSinhId)) as QLMamNon.Dao.QLMamNonDs.PhieuThuRow[]; if (ListUtil.IsEmpty(phieuThuRows)) { return; } QLMamNon.Dao.QLMamNonDs.PhieuThuRow firstRow = phieuThuRows[0] as QLMamNon.Dao.QLMamNonDs.PhieuThuRow; row.NgayNopLan1 = firstRow.Ngay; row.SoTienNopLan1 = firstRow.SoTien; if (phieuThuRows.Length > 1) { QLMamNon.Dao.QLMamNonDs.PhieuThuRow secondRow = phieuThuRows[1] as QLMamNon.Dao.QLMamNonDs.PhieuThuRow; row.NgayNopLan2 = secondRow.Ngay; row.SoTienNopLan2 = 0; for (int i = 1; i < phieuThuRows.Length; i++) { QLMamNon.Dao.QLMamNonDs.PhieuThuRow phieuThuRow = phieuThuRows[i] as QLMamNon.Dao.QLMamNonDs.PhieuThuRow; row.SoTienNopLan2 += phieuThuRow.SoTien; } } }