public JsonResult Addstore(string snumber, string sname, string connstring) { try { StoreModel sm = new StoreModel(); if (!ValidationUtility.IsNull(snumber) && !ValidationUtility.IsNull(sname)) { int storeNumber = ValidationUtility.ToInteger(snumber); bool flag = sm.IsStoreExist(storeNumber, sname); if (!flag) { StoreDTO storeDTO = new StoreDTO(); storeDTO.StoreNumber = storeNumber; storeDTO.StoreName = sname; storeDTO.ConnectionString = connstring; sm.AddInactiveStore(storeDTO); string msg = "Recored Added Successfully"; return Json(msg, JsonRequestBehavior.AllowGet); //if (!ValidationUtility.IsNull(connstring)) //{ // sm.AddStore(storeNumber, sname, connstring); // string msg = "Recored Added Successfully"; // return Json(msg, JsonRequestBehavior.AllowGet); //} //else //{ // StoreDTO storeDTO = new StoreDTO(); // storeDTO.StoreNumber = storeNumber; // storeDTO.StoreName = sname; // sm.AddInactiveStore(storeDTO); //} } else { string msg = "Store Already Exist"; return Json(msg, JsonRequestBehavior.AllowGet); } } } catch (Exception ex) { } string msg1 = " Recored Not Added Successfully "; return Json(msg1, JsonRequestBehavior.AllowGet); }
public void UpdateRecordSale() { try { log.Info(" UpdateRecordSale Start Time is " + DateTime.Now); ArrayList weekDayList = new ArrayList(); string weekOfDay = DateTime.Now.AddDays(-1).DayOfWeek.ToString(); weekDayList.Add(weekOfDay); log.Info(" Day Of week " + DateTime.Now.AddDays(-1).DayOfWeek.ToString()); //weekDayList.Add("Thursday"); //weekDayList.Add("Friday"); //weekDayList.Add("Saturday"); //weekDayList.Add("Sunday"); //weekDayList.Add("Monday"); //weekDayList.Add("Tuesday"); StoreModel sm = new StoreModel(); // Get All Store List from local database // ArrayList list = sm.GetStoreList(); ArrayList list = ValidationUtility.GetActiveStoreList(true); foreach (StoreDTO dto in list) { ArrayList recordSale = new ArrayList(); foreach (string s in weekDayList) { //Get Business day record (which is high in year) DataTable dt = GetWeekDayRecord(dto.ConnectionString, s); RecordSalesDTO recordSaleDto = new RecordSalesDTO(); for (int i = 0; i < dt.Rows.Count; i++) { recordSaleDto.BusinessDate = (DateTime)dt.Rows[i]["BusinessDate"]; recordSaleDto.DayOfWeek = dt.Rows[i]["WeekOfDay"].ToString(); recordSaleDto.SalesAmount = ValidationUtility.ToDouble(dt.Rows[i]["PerDaySale"].ToString()); recordSaleDto.StoreId = dto.Id; } recordSale.Add(recordSaleDto); } // Now Update Records foreach (RecordSalesDTO rsDto in recordSale) { UpdateStore(rsDto, dto.ConnectionString); } } // UpdateLast sale foreach (StoreDTO dto in list) { RecordSaleModel rsm = new RecordSaleModel(); log.Info("Record update for StorId " + dto.Id); log.Info("Last Perday sale date " + DateTime.Now.AddDays(-1)); double perDaySalesAmount = GetPerDayUpdatedSalesAmount(dto.ConnectionString, DateTime.Now.AddDays(-1)); log.Info("Last date perday sales amount " + perDaySalesAmount); int opId = rsm.GetCurrentDateOpeningInfoId(DateTime.Now.AddDays(-1), dto.ConnectionString); log.Info("Opening Information Id of last per day sales " + opId); rsm.UpdatePerdaySales(perDaySalesAmount, dto.Id, DateTime.Now.AddDays(-1), opId); //ArrayList lastPerDaySales = GetLastDaySalesData(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-1).DayOfWeek.ToString(), dto.Id); //foreach (PerdaySalesDTO perdaySalesDTO in lastPerDaySales) //{ // double perDaySalesAmount = GetPerDayUpdatedSalesAmount(dto.ConnectionString, perdaySalesDTO.BusinessDate); // int opId = rsm.GetCurrentDateOpeningInfoId(perdaySalesDTO.BusinessDate, dto.ConnectionString); // rsm.UpdatePerdaySales(perDaySalesAmount, perdaySalesDTO.StoreId, perdaySalesDTO.BusinessDate, opId); //} } log.Info(" End Time " + DateTime.Now); } catch (Exception ex) { log.Error("Exception in UpdateRecordSale ", ex); } }
public JsonResult UpdateInActiveStore(string id, string storeName, string connectionString) { string error = ""; string msg = ""; try { StoreModel sm = new StoreModel(); if (!ValidationUtility.IsNull(id)) { int sId = ValidationUtility.ToInteger(id); StoreDTO dto = new StoreDTO(); dto.Id = sId; dto.StoreName = storeName; dto.ConnectionString = connectionString; dto.IsActive = true; sm.AddStore(dto); error = "Success"; msg = "Store Connected Successfully"; } } catch (Exception ex) { log.Error("Exception in UpdateInActiveStore method",ex); error = "Error"; msg = " Store is not connected."; } ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg }; return Json(resDTO, JsonRequestBehavior.AllowGet); }