public JsonResult GetLiveSales(string sId) { int storeId = ValidationUtility.ToInteger(sId); ArrayList collection = new ArrayList(); LiveSaleModel liveSaleModel = new LiveSaleModel(); ArrayList storeList = null; if (storeId == 0) { UserContext cont = (UserContext)Session["UserContext"]; if (!ValidationUtility.IsNull(cont) && ValidationUtility.IsEqual(cont.Role, "Corporate")) { storeList = ValidationUtility.GetCorporateUserAssignActiveStore(cont.Id, true); } else { storeList = ValidationUtility.GetActiveStoreList(true); } // storeList = ValidationUtility.GetStoreList(true); } else { ArrayList tempList = ValidationUtility.GetActiveStoreList(true); foreach (StoreDTO storeDTO in tempList) { if (storeId == storeDTO.Id) { storeList = new ArrayList(); storeList.Add(storeDTO); break; } } } foreach (StoreDTO storeDTO in storeList) { ArrayList paymentList = liveSaleModel.GetData(storeDTO.ConnectionString); double currentYearAmount = liveSaleModel.GetTotalAmountWithTax(storeDTO.ConnectionString, DateTime.Now); double PreviousYearAmount = liveSaleModel.GetTotalAmountWithTax(storeDTO.ConnectionString, DateTime.Now.AddYears(-1)); if (!ValidationUtility.IsNull(paymentList) && paymentList.Count > 0) { paymentList.Add(currentYearAmount); paymentList.Add(PreviousYearAmount); string itemName = ValidationUtility.ToString(paymentList[0]); double lastSaleAmountWithTax = ValidationUtility.ToDouble(paymentList[1].ToString()); double tax = ValidationUtility.ToDouble(paymentList[2].ToString()); string lastSaleTime = paymentList[3].ToString(); double totalSalesTodayWithTax = ValidationUtility.ToDouble(paymentList[4].ToString()); double previousYearSaleWithTax = ValidationUtility.ToDouble(paymentList[5].ToString()); double difference = totalSalesTodayWithTax - previousYearSaleWithTax; double differencePercent = ValidationUtility.IsNan(difference / totalSalesTodayWithTax) * 100; LiveSaleDTO dto = new LiveSaleDTO { StoreNumber = storeDTO.StoreNumber, ItemName = itemName, LastSaleAmountWithTax = lastSaleAmountWithTax, Tax = tax, LastSaleTime = lastSaleTime, TadayTotalSale = totalSalesTodayWithTax, PreviousYearTotalSale = previousYearSaleWithTax, DifferencePercent = differencePercent }; collection.Add(dto); } } return Json(collection, JsonRequestBehavior.AllowGet); }