public ActionResult First() { @ViewBag.Message = "Blance"; IMAccDetailLogRepository<MAccDetailLog> repo = new MAccDetailLogRepository(); IList<String> listCustomer = repo.getListAllCutomer(); // IRepository<VFS_MAccDetailLogBlance> VFS_MAccDetailLogBlance = new VFS_MAccDetailLogBlanceRepository(); // repo.truncateTable(); // xoa tat cac cac hop dong try { foreach (var itemCustomer in listCustomer) { decimal blance = 0; IList<MAccDetailLog> listMAccDetailLog = repo.getListFromCustomer(itemCustomer); foreach (var item in listMAccDetailLog) { if (item.Status == "B") { blance = blance + item.AmountCalInterest; } else { blance = blance - item.AmountCalInterest; } VFS_MAccDetailLogBlance itemInsert = new VFS_MAccDetailLogBlance(); itemInsert.LogId = item.LogId; itemInsert.Balance = blance; VFS_MAccDetailLogBlance.Save(itemInsert); } } @ViewBag.Status = "Sucessfull"; } catch (Exception) { throw; } return View(); }
public static void syncBalanceNoKyQuy() { #region Lay danh sach khach hang IMAccDetailLogRepository<MAccDetailLog> repo = new MAccDetailLogRepository(); IList<String> listCustomer = repo.getListAllCutomer(); #endregion IRepository<VFS_MAccDetailLogBlance> VFS_MAccDetailLogBlance = new VFS_MAccDetailLogBlanceRepository(); // repo.truncateTable(); // xoa tat cac cac hop dong try { foreach (var itemCustomer in listCustomer) { decimal blance = 0; IList<MAccDetailLog> listMAccDetailLog = repo.getListFromCustomer(itemCustomer); foreach (var item in listMAccDetailLog) { if (item.Status == "B") { blance = blance + item.AmountCalInterest; } else { blance = blance - item.AmountCalInterest; } VFS_MAccDetailLogBlance itemInsert = new VFS_MAccDetailLogBlance(); itemInsert.LogId = item.LogId; itemInsert.Balance = blance; VFS_MAccDetailLogBlance.Save(itemInsert); } } } catch (Exception) { throw; } }