public void UpdateSelectDateDepositAmount(DepositDTO dto) { DataBaseUtility db = new DataBaseUtility(); foreach (DepositAmount amount in dto.DepositAmount) { string query = "update dbo.BankDeposit set DepositAmount=" + SQLUtility.getDouble(amount.DepositBankAmount) + ", LastUpdateDateTime='"+SQLUtility.FormateDateYYYYMMDDWtithTime(DateTime.Now)+"' " + " where Id=" + SQLUtility.getInteger(amount.Id) + " and StoreId=" + SQLUtility.getInteger(dto.StoreId) + ""; db.ExecuteUpdate(query); } }
public void InsertDepositAmount(DepositDTO dto) { DataBaseUtility db = new DataBaseUtility(); foreach (DepositAmount amount in dto.DepositAmount) { string query = "INSERT INTO [dbo].[BankDeposit]([StoreId],[DepositAmount],[BusinessDate],[WeekOfDay],[Status],[CreatedDateTime],[LastUpdateDateTime]) VALUES ( " + " " + SQLUtility.getInteger(dto.StoreId) + " , " + SQLUtility.getDouble(amount.DepositBankAmount) + " , '" + SQLUtility.FormateDateYYYYMMDD(amount.BusinessDate) + "' " + ", " + SQLUtility.getString(amount.BusinessDate.DayOfWeek.ToString()) + " , " + SQLUtility.getString("Payment Pending") + " , '" + SQLUtility.FormateDateYYYYMMDDWtithTime(DateTime.Now) + "', '" + SQLUtility.FormateDateYYYYMMDDWtithTime(DateTime.Now) + " ' )"; db.ExecuteUpdate(query); } }
//Get weekly deposit amount from cash control public ArrayList GetWeeklyDepositAmount(DateTime selectDate, ArrayList storeList) { ArrayList depositAmountList = new ArrayList(); try { // ArrayList storeList = GetStoreList(); foreach (StoreDTO storeDTO in storeList) { DepositDTO depositDTO1 = GetBankDepositListFromLocalDB(selectDate, storeDTO, true); if (depositDTO1 != null) { //foreach (DepositAmount depositAmountDTO in depositDTO1.DepositAmount) //{ DataTable dt = GetEachStoreDepositAmount(storeDTO.ConnectionString, selectDate); ArrayList ammountList = new ArrayList(); if (!ValidationUtility.IsNull(dt)) { List<DepositAmount> depositAmmountList = new List<DepositAmount>(); DateTime businessDate = new DateTime(); for (int i = 0; i < dt.Rows.Count; i++) { double depositAmount = 0; businessDate = ValidationUtility.ToDate(dt.Rows[i]["BusinessDate"].ToString()); if (businessDate.Date <= ValidationUtility.GetActualWeekStartDate(selectDate).AddDays(7).Date) { DepositAmount depositAmountDTO = (DepositAmount)depositDTO1.DepositAmount[i]; depositAmount = ValidationUtility.ToDouble(dt.Rows[i]["DepositInBank"].ToString()); DepositAmount dammount = new DepositAmount { Id = depositAmountDTO.Id, DepositBankAmount = depositAmount, BusinessDate = businessDate }; depositAmmountList.Add(dammount); } } DepositDTO depositDTO = new DepositDTO { StoreId = storeDTO.Id, StoreNumber = storeDTO.StoreNumber, DepositAmount = depositAmmountList }; //InsertDepositAmount(depositDTO); UpdateSelectDateDepositAmount(depositDTO); depositAmountList.Add(GetBankDepositListFromLocalDB(selectDate, storeDTO, false)); } //} // depositAmountList.Add(depositDTO1); } if (depositDTO1 == null) { DataTable dt = GetEachStoreDepositAmount(storeDTO.ConnectionString, selectDate); ArrayList ammountList = new ArrayList(); if (!ValidationUtility.IsNull(dt)) { List<DepositAmount> depositAmmountList = new List<DepositAmount>(); DateTime businessDate = new DateTime(); for (int i = 0; i < dt.Rows.Count; i++) { double depositAmount = 0; businessDate = ValidationUtility.ToDate(dt.Rows[i]["BusinessDate"].ToString()); if (businessDate.Date <= ValidationUtility.GetActualWeekStartDate(selectDate).AddDays(7).Date) { depositAmount = ValidationUtility.ToDouble(dt.Rows[i]["DepositInBank"].ToString()); DepositAmount dammount = new DepositAmount { DepositBankAmount = depositAmount, BusinessDate = businessDate }; depositAmmountList.Add(dammount); } } DepositDTO depositDTO = new DepositDTO { StoreId = storeDTO.Id, StoreNumber = storeDTO.StoreNumber, DepositAmount = depositAmmountList }; InsertDepositAmount(depositDTO); depositAmountList.Add(GetBankDepositListFromLocalDB(selectDate, storeDTO, false)); } } } } catch (Exception ex) { log.Error("Exception in GetWeeklyDepositAmount method", ex); } return depositAmountList; }
// Get Bank Deposit Amount from local data base of week wise public DepositDTO GetBankDepositListFromLocalDB(DateTime selectDate, StoreDTO storeDTO, bool checkAgainToServer) { DepositDTO dto = null; try { ArrayList weekday = new ArrayList(); DateTime weekStartDate = ValidationUtility.GetActualWeekStartDate(selectDate); DateTime weekEndDate = weekStartDate.AddDays(6); DataBaseUtility db = new DataBaseUtility(); // ArrayList StoreList = GetStoreList(); // Check of only Current Date Week DateTime weekStartDateForCurrentDate = ValidationUtility.GetActualWeekStartDate(DateTime.Now); DateTime weekEndDateForCurrentDate = weekStartDate.AddDays(6); if (selectDate.Date >= weekStartDateForCurrentDate.Date && selectDate.Date <= weekEndDateForCurrentDate.Date) { if (checkAgainToServer) { List<DepositAmount> depositAmmountList = GetDepositAmountLocalDB(weekStartDate, weekEndDate, storeDTO.Id); if (depositAmmountList != null && depositAmmountList.Count > 0) { // Update Current Date Deposit Ammount DataTable dt = GetEachStoreDepositAmount(storeDTO.ConnectionString, selectDate); if (!ValidationUtility.IsNull(dt)) { DateTime currentDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); DateTime businessDate = new DateTime(); for (int i = 0; i < dt.Rows.Count; i++) { double depositAmount = 0; businessDate = ValidationUtility.ToDate(dt.Rows[i]["BusinessDate"].ToString()); if (businessDate.Date.Equals(currentDate.Date)) { depositAmount = ValidationUtility.ToDouble(dt.Rows[i]["DepositInBank"].ToString()); DepositAmount dammount = new DepositAmount { DepositBankAmount = depositAmount, BusinessDate = businessDate, WeekOfDay = businessDate.DayOfWeek.ToString() }; Update(dammount, storeDTO.Id); } } } } } } List<DepositAmount> depositUpdatedListAmmountList = GetDepositAmountLocalDB(weekStartDate, weekEndDate, storeDTO.Id); if (depositUpdatedListAmmountList != null && depositUpdatedListAmmountList.Count > 0) { dto = new DepositDTO { DepositAmount = depositUpdatedListAmmountList, StoreId = storeDTO.Id, StoreNumber = storeDTO.StoreNumber }; } } catch (Exception ex) { log.Error("Exception in GetBankDepositListFromLocalDB method ", ex); } return dto; }
//This method is use for update depoisit amount of last business date public void UpdateDeposit() { log.Info(" UpdateDeposit Method is Called now for Deposit "+DateTime.Now); DepositModel dmodel = new DepositModel(); // ArrayList storeList = dmodel.GetStoreList(); ArrayList storeList = ValidationUtility.GetActiveStoreList(true); foreach (StoreDTO storeDTO in storeList) { DateTime lastDayDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(-1); DepositDTO depositDTO1 = GetBankDepositListFromLocalDB(lastDayDate, storeDTO); if (!ValidationUtility.IsNull(depositDTO1)) { DataTable dt = GetEachStoreDepositAmount(storeDTO.ConnectionString, lastDayDate); if (!ValidationUtility.IsNull(dt)) { DateTime businessDate = new DateTime(); for (int i = 0; i < dt.Rows.Count; i++) { double depositAmount = 0; businessDate = ValidationUtility.ToDate(dt.Rows[i]["BusinessDate"].ToString()); if (businessDate.Date.Equals(lastDayDate.Date)) { depositAmount = ValidationUtility.ToDouble(dt.Rows[i]["DepositInBank"].ToString()); DepositAmount dammount = new DepositAmount { DepositBankAmount = depositAmount, BusinessDate = businessDate, WeekOfDay = businessDate.DayOfWeek.ToString() }; Update(dammount, storeDTO.Id); } } } } // Add Week deposit ammount else { DataTable dt = GetEachStoreDepositAmount(storeDTO.ConnectionString, lastDayDate); ArrayList ammountList = new ArrayList(); if (!ValidationUtility.IsNull(dt)) { List<DepositAmount> depositAmmountList = new List<DepositAmount>(); DateTime businessDate = new DateTime(); for (int i = 0; i < dt.Rows.Count; i++) { double depositAmount = 0; businessDate = ValidationUtility.ToDate(dt.Rows[i]["BusinessDate"].ToString()); if (businessDate.Date <= ValidationUtility.GetActualWeekStartDate(lastDayDate).AddDays(7).Date) { depositAmount = ValidationUtility.ToDouble(dt.Rows[i]["DepositInBank"].ToString()); DepositAmount dammount = new DepositAmount { DepositBankAmount = depositAmount, BusinessDate = businessDate }; depositAmmountList.Add(dammount); } } DepositDTO depositDTO = new DepositDTO { StoreId = storeDTO.Id, DepositAmount = depositAmmountList }; dmodel.InsertDepositAmount(depositDTO); } } } log.Info(" UpdateDeposit Method Call is finish " + DateTime.Now); }
// Get Bank Deposit Amount from local data base of week wise public DepositDTO GetBankDepositListFromLocalDB(DateTime selectDate, StoreDTO storeDTO) { // ArrayList allDepositList = new ArrayList(); ArrayList weekday = new ArrayList(); DateTime weekStartDate = ValidationUtility.GetActualWeekStartDate(selectDate); DateTime weekEndDate = weekStartDate.AddDays(6); DataBaseUtility db = new DataBaseUtility(); DepositModel dmodel = new DepositModel(); // ArrayList StoreList = dmodel.GetStoreList(); ArrayList StoreList = ValidationUtility.GetActiveStoreList(true); List<DepositAmount> depositAmmountList = GetDepositAmountLocalDB(weekStartDate, weekEndDate, storeDTO.Id); DepositDTO dto = null; if (depositAmmountList != null && depositAmmountList.Count > 0) { dto = new DepositDTO { DepositAmount = depositAmmountList, StoreId = storeDTO.StoreNumber }; //allDepositList.Add(dto); } return dto; }