public static string GetMaPhanLoaiChiNameByPhieuChiId(PhieuChiTableAdapter adapter, Int32 phieuChiId) { if (phieuChiId < 0) { return(CommonConstant.EMPTY); } QLMamNon.Dao.QLMamNonDs.PhieuChiDataTable phieChiTable = adapter.GetPhieuChiById(phieuChiId); if (ListUtil.IsEmpty(phieChiTable.Rows)) { return(CommonConstant.EMPTY); } QLMamNon.Dao.QLMamNonDs.PhieuChiRow phieChiRow = phieChiTable.Rows[0] as QLMamNon.Dao.QLMamNonDs.PhieuChiRow; if (phieChiRow != null) { QLMamNon.Dao.QLMamNonDs.PhanLoaiChiDataTable table = StaticDataFacade.Get(StaticDataKeys.PhanLoaiChi) as QLMamNon.Dao.QLMamNonDs.PhanLoaiChiDataTable; QLMamNon.Dao.QLMamNonDs.PhanLoaiChiRow[] rows = (QLMamNon.Dao.QLMamNonDs.PhanLoaiChiRow[])table.Select(String.Format("PhanLoaiChiId={0}", phieChiRow.PhanLoaiChiId)); if (!ArrayUtil.IsEmpty(rows)) { return(rows[0].MaPhanLoai); } } return(CommonConstant.EMPTY); }
public static Dictionary <int, QLMamNon.Dao.QLMamNonDs.LopRow> GetLopsByHocSinhIds(List <int> hocSinhIds, DateTime ngay) { Dictionary <int, QLMamNon.Dao.QLMamNonDs.HocSinhLopRow> hocSinhIdsToLopIds = GetHocSinhLopsByHocSinhIds(hocSinhIds, ngay); QLMamNon.Dao.QLMamNonDs.LopDataTable lopTable = StaticDataFacade.Get(StaticDataKeys.LopHoc) as QLMamNon.Dao.QLMamNonDs.LopDataTable; Dictionary <int, QLMamNon.Dao.QLMamNonDs.LopRow> hocSinhIdsToLopNames = new Dictionary <int, QLMamNon.Dao.QLMamNonDs.LopRow>(); if (ListUtil.IsEmpty(hocSinhIdsToLopIds)) { return(hocSinhIdsToLopNames); } foreach (KeyValuePair <int, QLMamNon.Dao.QLMamNonDs.HocSinhLopRow> pair in hocSinhIdsToLopIds) { if (pair.Value == null) { continue; } QLMamNon.Dao.QLMamNonDs.LopRow[] rows = lopTable.Select(String.Format("LopId={0}", pair.Value.LopId)) as QLMamNon.Dao.QLMamNonDs.LopRow[]; if (!ArrayUtil.IsEmpty(rows) && !hocSinhIdsToLopNames.ContainsKey(pair.Key)) { hocSinhIdsToLopNames.Add(pair.Key, rows[0]); } } return(hocSinhIdsToLopNames); }
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; } } }
public static Dictionary <int, QLMamNon.Dao.QLMamNonDs.HocSinhLopRow> GetHocSinhLopsByHocSinhIds(List <int> hocSinhIds, DateTime ngay) { if (ListUtil.IsEmpty(hocSinhIds)) { return(null); } HocSinhLopTableAdapter hocSinhLopTableAdapter = (HocSinhLopTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterHocSinhLop); Dictionary <int, QLMamNon.Dao.QLMamNonDs.HocSinhLopRow> hocSinhIdsToHocSinhLops = new Dictionary <int, QLMamNon.Dao.QLMamNonDs.HocSinhLopRow>(); QLMamNon.Dao.QLMamNonDs.HocSinhLopDataTable table = hocSinhLopTableAdapter.GetHocSinhLopByHocSinhIdsAndNgay(StringUtil.Join(hocSinhIds, ","), ngay); if (!ListUtil.IsEmpty(table.Rows)) { foreach (QLMamNon.Dao.QLMamNonDs.HocSinhLopRow row in table) { if (!hocSinhIdsToHocSinhLops.ContainsKey(row.HocSinhId)) { hocSinhIdsToHocSinhLops.Add(row.HocSinhId, row); } } } return(hocSinhIdsToHocSinhLops); }
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); }
public void UpdateUserPrivileges(UserPrivilegeTableAdapter userPrivilegeTableAdapter, int userId, List <int> privilegeIds) { if (ListUtil.IsEmpty(privilegeIds)) { userPrivilegeTableAdapter.DeleteUserPrivileges("0", userId); } else { userPrivilegeTableAdapter.DeleteUserPrivileges(StringUtil.JoinWithCommas(privilegeIds), userId); foreach (int privilegeId in privilegeIds) { userPrivilegeTableAdapter.InsertUserPrivilegeIfNotExists(userId, privilegeId, 1); } } }
protected override void onSaving() { if (ControlUtil.IsEditValueNull(this.cmbLopHocDen)) { MessageBox.Show("Xin vui long chọn Lớp học", "Chọn lớp học", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } List <int> hocSinhIds = new List <int>(); int lop = (int)cmbLopHocDen.EditValue; QLMamNon.Dao.QLMamNonDs.HocSinhDataTable hocSinhTable = this.hocSinhTableAdapter.GetHocSinhByParams(DateTime.Now, null, lop, null); foreach (DataRowView rowView in hocSinhRowBindingSourceDen) { HocSinhRow hocSinhRow = rowView.Row as QLMamNon.Dao.QLMamNonDs.HocSinhRow; int hocSinh = hocSinhRow.HocSinhId; hocSinhIds.Add(hocSinh); if (hocSinhRow.RowState == DataRowState.Modified || hocSinhRow.RowState == DataRowState.Added) { this.hocSinhTableAdapter.InsertHocSinhToLop(hocSinh, lop, hocSinhRow.NgayVaoLop); } } ((QLMamNon.Dao.QLMamNonDs.HocSinhDataTable) this.hocSinhRowBindingSourceDen.DataSource).AcceptChanges(); List <int> deletingHocSinhIds = new List <int>(); foreach (QLMamNon.Dao.QLMamNonDs.HocSinhRow hsRow in hocSinhTable) { if (!hocSinhIds.Contains(hsRow.HocSinhId)) { deletingHocSinhIds.Add(hsRow.HocSinhId); } } if (!ListUtil.IsEmpty(deletingHocSinhIds)) { this.hocSinhLopTableAdapter.DeleteHocSinhLopByHocSinhIds(StringUtil.Join(deletingHocSinhIds, ","), DateTime.Now.AddDays(-1)); SoThuTienService soThuTienService = new SoThuTienService(); soThuTienService.DeleteBangThuTienByHocSinhIdsAndDate(deletingHocSinhIds, DateTimeUtil.DateEndOfMonth(DateTime.Now)); } FormMainFacade.SetStatusCaption(this.FormKey, StatusCaptions.SavedCaption); }
public static void CalculateSummaryFields(QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow row) { BangThuTienGenHistoryTableAdapter bangThuTienGenHistoryTableAdapter = (BangThuTienGenHistoryTableAdapter)StaticDataFacade.Get(StaticDataKeys.AdapterBangThuTienGenHistory); BangThuTienGenHistoryDataTable bangThuTienGenHistoryDataTable = bangThuTienGenHistoryTableAdapter.GetDataByLopAndNgay(row.LopId, row.NgayTinh); if (!ListUtil.IsEmpty(bangThuTienGenHistoryDataTable.Rows)) { BangThuTienGenHistoryRow bangThuTienGenHistoryRow = bangThuTienGenHistoryDataTable[0]; row.SoTienSXThangTruoc = BangThuTienUtil.SXToSoTienSX(row.SXThangTruoc, (long)bangThuTienGenHistoryRow.SoTienAnChinh); row.SoTienAnSangThangTruoc = BangThuTienUtil.SXAnSangToSoTienAnSang(row.AnSangThangTruoc, (long)bangThuTienGenHistoryRow.SoTienAnSang); row.SoTienAnToiThangTruoc = BangThuTienUtil.SXAnToiToSoTienAnToi(row.AnToiThangTruoc, (long)bangThuTienGenHistoryRow.SoTienAnToi); } row.SoTienAnSangConLai = row.SoTienAnSangThangNay - row.SoTienAnSangThangTruoc; row.SoTienAnToiConLai = row.SoTienAnToiThangNay - row.SoTienAnToiThangTruoc; row.KhoanThuChinh = row.TienAnSua + row.PhuPhi + row.BanTru + row.HocPhi; row.ThanhTien = BangThuTienUtil.CalculateThanhTien(row); }
private void btnChon_Click(object sender, EventArgs e) { this.HocSinhRows = new List <Dao.QLMamNonDs.HocSinhRow>(); int[] selectedRowHandlers = this.gvMain.GetSelectedRows(); for (int i = 0; i < selectedRowHandlers.Length; i++) { DataRowView rowView = (DataRowView)this.gvMain.GetRow(selectedRowHandlers[i]); this.HocSinhRows.Add((QLMamNon.Dao.QLMamNonDs.HocSinhRow)rowView.Row); } if (ListUtil.IsEmpty(this.HocSinhRows)) { MessageBox.Show("Bạn chưa chọn học sinh", "Chọn học sinh", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } this.DialogResult = DialogResult.OK; this.Close(); }
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; }
private void cmbLopHoc_EditValueChanged(object sender, EventArgs e) { if (this.DataTable != null) { DataTable table = this.DataTable.GetChanges(); if (table != null && !ListUtil.IsEmpty(table.Rows)) { DialogResult result = MessageBox.Show("Bạn có muốn lưu thay đổi không?", "Lưu thay đổi", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == System.Windows.Forms.DialogResult.OK) { this.btnSave_Click(null, null); } else { this.btnCancel_Click(null, null); } } } this.loadTaiSanToGridLop(); this.loadTaiSanToGridTaiSan(); }
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(); }
private static void evaluateValuesForAdditionalFields(QLMamNon.Dao.QLMamNonDs.ViewBangThuTienRow row, QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuDataTable bTTKTDataTable, bool isCalculateAnSangAnToi, bool isCalculateHocPhi) { if (isCalculateHocPhi) { row.TienAnSua = 0; row.PhuPhi = 0; row.BanTru = 0; row.HocPhi = 0; } if (isCalculateAnSangAnToi) { row.SoTienAnSangThangNay = 0; row.SoTienAnToiThangNay = 0; } QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuRow[] bangThuTienKhoanThuRows = bTTKTDataTable.Select(String.Format("BangThuTienId={0}", row.BangThuTienId)) as QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuRow[]; if (!ListUtil.IsEmpty(bangThuTienKhoanThuRows)) { foreach (QLMamNon.Dao.QLMamNonDs.BangThuTienKhoanThuRow bangThuTienKhoanThuRow in bangThuTienKhoanThuRows) { switch (bangThuTienKhoanThuRow.KhoanThuId) { case BangThuTienConstant.KhoanThuIdTienAnSua: if (isCalculateHocPhi) { row.TienAnSua = bangThuTienKhoanThuRow.SoTien; } break; case BangThuTienConstant.KhoanThuIdPhuPhi: if (isCalculateHocPhi) { row.PhuPhi = bangThuTienKhoanThuRow.SoTien; } break; case BangThuTienConstant.KhoanThuIdBanTru: if (isCalculateHocPhi) { row.BanTru = bangThuTienKhoanThuRow.SoTien; } break; case BangThuTienConstant.KhoanThuIdHocPhi: if (isCalculateHocPhi) { row.HocPhi = bangThuTienKhoanThuRow.SoTien; } break; case BangThuTienConstant.KhoanThuIdAnSang: if (isCalculateAnSangAnToi) { row.SoTienAnSangThangNay = bangThuTienKhoanThuRow.SoTien; } break; case BangThuTienConstant.KhoanThuIdAnToi: if (isCalculateAnSangAnToi) { row.SoTienAnToiThangNay = bangThuTienKhoanThuRow.SoTien; } break; default: break; } } } }
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); }