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); }
private static Dictionary <int, Dictionary <int, ViewBangThuTienRow> > getAndSortPrevMonthViewBangThuTienRows(DateTime ngayTinh, ViewBangThuTienTableAdapter viewBangThuTienTableAdapter, List <int> hocSinhIds, Dictionary <int, HocSinhLopRow> hocSinhIdsToHocSinhLops, Dictionary <int, Dictionary <int, ViewBangThuTienRow> > lopToHocSinhToViewBangThuTienRowsMap) { ViewBangThuTienDataTable prevMonthViewBangThuTienTable = viewBangThuTienTableAdapter.GetViewBangThuTienByNgayTinhAndLop(ngayTinh.AddMonths(-1), null); Dictionary <int, Dictionary <int, ViewBangThuTienRow> > lopToHocSinhViewBangThuTienRows = new Dictionary <int, Dictionary <int, ViewBangThuTienRow> >(); foreach (ViewBangThuTienRow viewBangThuTienRow in prevMonthViewBangThuTienTable) { if (!hocSinhIds.Contains(viewBangThuTienRow.HocSinhId)) { continue; } int lopId = hocSinhIdsToHocSinhLops[viewBangThuTienRow.HocSinhId].LopId; if (!lopToHocSinhViewBangThuTienRows.ContainsKey(lopId)) { lopToHocSinhViewBangThuTienRows.Add(lopId, new Dictionary <int, ViewBangThuTienRow>()); } Dictionary <int, ViewBangThuTienRow> hocSinhToViewBangThuTienRows = lopToHocSinhViewBangThuTienRows[lopId]; hocSinhToViewBangThuTienRows.Add(viewBangThuTienRow.HocSinhId, viewBangThuTienRow); } // Sort HocSinh in each Lop by STT ASC foreach (KeyValuePair <int, Dictionary <int, ViewBangThuTienRow> > lopToHocSinhViewBangThuTienRow in lopToHocSinhViewBangThuTienRows) { int lopId = lopToHocSinhViewBangThuTienRow.Key; Dictionary <int, ViewBangThuTienRow> hocSinhViewBangThuTienRows = lopToHocSinhToViewBangThuTienRowsMap.ContainsKey(lopId) ? lopToHocSinhToViewBangThuTienRowsMap[lopId] : null; SortedList <int, ViewBangThuTienRow> sortedViewBangThuTienRows = new SortedList <int, ViewBangThuTienRow>(); int currentMaxSTT = ListUtil.IsEmpty(hocSinhViewBangThuTienRows) ? 0 : hocSinhViewBangThuTienRows.Count; foreach (KeyValuePair <int, ViewBangThuTienRow> hocSinhIdToViewBangThuTienRow in lopToHocSinhViewBangThuTienRow.Value) { if (!sortedViewBangThuTienRows.ContainsKey(hocSinhIdToViewBangThuTienRow.Value.STT)) { sortedViewBangThuTienRows.Add(hocSinhIdToViewBangThuTienRow.Value.STT, hocSinhIdToViewBangThuTienRow.Value); } } for (int i = 0; i < sortedViewBangThuTienRows.Count; i++) { sortedViewBangThuTienRows.Values[i].STT = i + currentMaxSTT + 1; } } return(lopToHocSinhViewBangThuTienRows); }
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 void showFormGenerateSoThuTiens(bool needToCheckGenerated) { if (this.isValidNgayTinhAndLop()) { DateTime ngayTinh = this.GetNgayTinh(); int lop = (int)this.cmbLop.EditValue; if (needToCheckGenerated && !this.isNeedToGenerateSoThuTiens(ngayTinh, lop, true)) { return; } using (FrmSelectHocSinhsToGenerate frmSelectHocSinhsToGenerate = new FrmSelectHocSinhsToGenerate()) { List <int> selectedHocSinhIds = new List <int>(); QLMamNon.Dao.QLMamNonDs.ViewBangThuTienDataTable viewBangThuTienTable = viewBangThuTienTableAdapter.GetViewBangThuTienByNgayTinhAndLop(ngayTinh, lop); foreach (QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow viewBangThuTienRow in viewBangThuTienTable) { selectedHocSinhIds.Add(viewBangThuTienRow.HocSinhId); } frmSelectHocSinhsToGenerate.GeneratedHocSinhIds = selectedHocSinhIds; QLMamNon.Dao.QLMamNonDs.HocSinhDataTable hocSinhTable = hocSinhTableAdapter.GetHocSinhByLopAndNgay(lop, ngayTinh); frmSelectHocSinhsToGenerate.HocSinhTable = hocSinhTable; DialogResult result = frmSelectHocSinhsToGenerate.ShowDialog(this); if (result == System.Windows.Forms.DialogResult.OK) { this.ShowGridLoadingPanel(); BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += new DoWorkEventHandler(generateSoThuTiens); bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(generatedSoThuTiens); bw.RunWorkerAsync(frmSelectHocSinhsToGenerate.HocSinhRows); } } } }
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 int GenerateSoThuTienByHocSinhRows(DateTime ngayTinh, List <HocSinhRow> hocSinhRows) { ViewBangThuTienTableAdapter viewBangThuTienTableAdapter = (ViewBangThuTienTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterViewBangThuTien); ViewBangThuTienDataTable viewBangThuTienTable = viewBangThuTienTableAdapter.GetViewBangThuTienByNgayTinhAndLop(ngayTinh, null); List <int> hocSinhIds = new List <int>(); List <HocSinhRow> needToGenerateHocSinhRows = new List <Dao.QLMamNonDs.HocSinhRow>(); foreach (HocSinhRow hocSinh in hocSinhRows) { DataRow[] rows = viewBangThuTienTable.Select(String.Format("HocSinhId={0}", hocSinh.HocSinhId)); if (ArrayUtil.IsEmpty(rows)) { hocSinhIds.Add(hocSinh.HocSinhId); needToGenerateHocSinhRows.Add(hocSinh); } } Dictionary <int, HocSinhLopRow> hocSinhIdsToHocSinhLops = StaticDataUtil.GetHocSinhLopsByHocSinhIds(hocSinhIds, ngayTinh); Dictionary <int, Dictionary <int, ViewBangThuTienRow> > lopToHocSinhToViewBangThuTienRowsMap = buildLopToHocSinhToViewBangThuTienRowsMap(viewBangThuTienTable, ngayTinh); Dictionary <int, Dictionary <int, ViewBangThuTienRow> > prevMonthLopToHocSinhToViewBangThuTienRowsMap = getAndSortPrevMonthViewBangThuTienRows(ngayTinh, viewBangThuTienTableAdapter, hocSinhIds, hocSinhIdsToHocSinhLops, lopToHocSinhToViewBangThuTienRowsMap); Dictionary <int, int> generatedLopToSTTs = buildGeneratedLopIdToSTTMap(lopToHocSinhToViewBangThuTienRowsMap); // Generate SoThuTien for HocSinhs that exist in previous month foreach (HocSinhRow hocSinh in needToGenerateHocSinhRows) { if (hocSinhIdsToHocSinhLops.ContainsKey(hocSinh.HocSinhId)) { int lopId = hocSinhIdsToHocSinhLops[hocSinh.HocSinhId].LopId; ViewBangThuTienRow preMonthViewBangThuTien = null; if (prevMonthLopToHocSinhToViewBangThuTienRowsMap.ContainsKey(lopId)) { Dictionary <int, ViewBangThuTienRow> prevMonthhocSinhToViewBangThuTienRowsMap = prevMonthLopToHocSinhToViewBangThuTienRowsMap[lopId]; if (prevMonthhocSinhToViewBangThuTienRowsMap.ContainsKey(hocSinh.HocSinhId)) { preMonthViewBangThuTien = prevMonthhocSinhToViewBangThuTienRowsMap[hocSinh.HocSinhId]; } } if (preMonthViewBangThuTien != null) { GenerateSoThuTienByHocSinhAndLopAndNgayTinh(hocSinh.HocSinhId, lopId, ngayTinh, preMonthViewBangThuTien.STT, preMonthViewBangThuTien); if (!generatedLopToSTTs.ContainsKey(lopId)) { generatedLopToSTTs.Add(lopId, 0); } int currentSTT = generatedLopToSTTs[lopId]; if (currentSTT < preMonthViewBangThuTien.STT) { generatedLopToSTTs[lopId] = preMonthViewBangThuTien.STT; } } } } // Generate SoThuTien for HocSinhs that NOT exist in previous month foreach (HocSinhRow hocSinh in needToGenerateHocSinhRows) { if (hocSinhIdsToHocSinhLops.ContainsKey(hocSinh.HocSinhId)) { int lopId = hocSinhIdsToHocSinhLops[hocSinh.HocSinhId].LopId; ViewBangThuTienRow preMonthViewBangThuTien = null; if (prevMonthLopToHocSinhToViewBangThuTienRowsMap.ContainsKey(lopId)) { Dictionary <int, ViewBangThuTienRow> prevMonthhocSinhToViewBangThuTienRowsMap = prevMonthLopToHocSinhToViewBangThuTienRowsMap[lopId]; if (prevMonthhocSinhToViewBangThuTienRowsMap.ContainsKey(hocSinh.HocSinhId)) { preMonthViewBangThuTien = prevMonthhocSinhToViewBangThuTienRowsMap[hocSinh.HocSinhId]; } } if (preMonthViewBangThuTien == null) { if (!generatedLopToSTTs.ContainsKey(lopId)) { generatedLopToSTTs.Add(lopId, 0); } int stt = generatedLopToSTTs[lopId] + 1; GenerateSoThuTienByHocSinhAndLopAndNgayTinh(hocSinh.HocSinhId, lopId, ngayTinh, stt, preMonthViewBangThuTien); generatedLopToSTTs[lopId] = stt; } } } return(hocSinhIds.Count); }
private static Dictionary <int, Dictionary <int, ViewBangThuTienRow> > buildLopToHocSinhToViewBangThuTienRowsMap(ViewBangThuTienDataTable viewBangThuTienTable, DateTime ngayTinh) { List <int> hocSinhIds = new List <int>(); foreach (ViewBangThuTienRow viewBangThuTienRow in viewBangThuTienTable) { hocSinhIds.Add(viewBangThuTienRow.HocSinhId); } Dictionary <int, HocSinhLopRow> hocSinhIdsToHocSinhLops = StaticDataUtil.GetHocSinhLopsByHocSinhIds(hocSinhIds, ngayTinh); Dictionary <int, Dictionary <int, ViewBangThuTienRow> > lopToHocSinhViewBangThuTienRows = new Dictionary <int, Dictionary <int, ViewBangThuTienRow> >(); foreach (ViewBangThuTienRow viewBangThuTienRow in viewBangThuTienTable) { if (!hocSinhIdsToHocSinhLops.ContainsKey(viewBangThuTienRow.HocSinhId)) { continue; } int lopId = hocSinhIdsToHocSinhLops[viewBangThuTienRow.HocSinhId].LopId; if (!lopToHocSinhViewBangThuTienRows.ContainsKey(lopId)) { lopToHocSinhViewBangThuTienRows.Add(lopId, new Dictionary <int, ViewBangThuTienRow>()); } Dictionary <int, ViewBangThuTienRow> hocSinhToViewBangThuTienRows = lopToHocSinhViewBangThuTienRows[lopId]; hocSinhToViewBangThuTienRows.Add(viewBangThuTienRow.HocSinhId, viewBangThuTienRow); } return(lopToHocSinhViewBangThuTienRows); }
protected override void onSaving() { ViewBangThuTienDataTable table = this.DataTable as ViewBangThuTienDataTable; List <int> bangThuTienIds = new List <int>(); foreach (ViewBangThuTienRow viewBangThuTienRow in table) { viewBangThuTienRow.SoTienSXThangTruoc = BangThuTienUtil.SXToSoTienSX(viewBangThuTienRow.SXThangTruoc, Settings.Default.TienAnChinh); viewBangThuTienRow.SoTienAnSangThangTruoc = BangThuTienUtil.SXAnSangToSoTienAnSang(viewBangThuTienRow.AnSangThangTruoc, Settings.Default.TienAnSang); viewBangThuTienRow.SoTienAnToiThangTruoc = BangThuTienUtil.SXAnToiToSoTienAnToi(viewBangThuTienRow.AnToiThangTruoc, Settings.Default.TienAnToi); if (this.isNeedToUpdateBangThuTienKhoanThu(viewBangThuTienRow)) { bangThuTienIds.Add(viewBangThuTienRow.BangThuTienId); } } if (!ListUtil.IsEmpty(bangThuTienIds)) { QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuDataTable bangThuTienKhoanThuDataTable = bangThuTienKhoanThuTableAdapter.GetBangThuTienKhoanThuByBangThuTienIds(StringUtil.Join(bangThuTienIds, ",")); foreach (QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuRow bangThuTienKhoanThuRow in bangThuTienKhoanThuDataTable) { ViewBangThuTienRow[] viewBangThuTienRows = (ViewBangThuTienRow[])table.Select(String.Format("BangThuTienId={0}", bangThuTienKhoanThuRow.BangThuTienId)); ViewBangThuTienRow viewBangThuTienRow = viewBangThuTienRows[0]; switch (bangThuTienKhoanThuRow.KhoanThuId) { case BangThuTienConstant.KhoanThuIdTienAnSua: bangThuTienKhoanThuRow.SoTien = viewBangThuTienRow.TienAnSua; break; case BangThuTienConstant.KhoanThuIdPhuPhi: bangThuTienKhoanThuRow.SoTien = viewBangThuTienRow.PhuPhi; break; case BangThuTienConstant.KhoanThuIdBanTru: bangThuTienKhoanThuRow.SoTien = viewBangThuTienRow.BanTru; break; case BangThuTienConstant.KhoanThuIdHocPhi: bangThuTienKhoanThuRow.SoTien = viewBangThuTienRow.HocPhi; break; case BangThuTienConstant.KhoanThuIdAnSang: bangThuTienKhoanThuRow.SoTien = viewBangThuTienRow.SoTienAnSangThangNay; break; case BangThuTienConstant.KhoanThuIdAnToi: bangThuTienKhoanThuRow.SoTien = viewBangThuTienRow.SoTienAnToiThangNay; break; default: break; } } bangThuTienKhoanThuTableAdapter.Update(bangThuTienKhoanThuDataTable); } // Start Updating SoTienTruyThu for each BangThuTienRow QLMNDaoJobInvoker qlmnDaoJobInvoker = new QLMNDaoJobInvoker(); qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTienCommand = new UpdateSoTienTruyThuOfBangThuTienCommand(); qlmnDaoJobInvoker.UpdateSoTienTruyThuOfBangThuTienCommand.CommandParameter.Add(UpdateSoTienTruyThuOfBangThuTienCommand.ParameterViewBangThuTienTableAdapter, this.viewBangThuTienTableAdapter); foreach (ViewBangThuTienRow viewBangThuTienRow in table) { 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(); } } } // Finished Updating SoTienTruyThu for each BangThuTien base.onSaving(); }