Ejemplo n.º 1
0
        public JsonResult StoreList()
        {
            ArrayList list = new ArrayList();
            LiveSaleModel liveSaleModel = new LiveSaleModel();

            UserContext cont = (UserContext)Session["UserContext"];
             //   ArrayList storeList = null;

            if (!ValidationUtility.IsNull(cont) && ValidationUtility.IsEqual(cont.Role, "Corporate"))
            {
                //storeList = ValidationUtility.GetCorporateUserAssignStore(cont.Id, false);
                list.Add(ValidationUtility.GetCorporateUserAssignActiveStore(cont.Id, false));
            }
            else
            {
                //list.Add(liveSaleModel.GetStoreList());

                list.Add(ValidationUtility.GetActiveStoreList(true));
            }

            list.Add(YearList());

            return Json(list, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public JsonResult GetYearSale(string sId, string date)
        {
            ArrayList list = new ArrayList();

             //   int storeId = 1;

            int selectDateYear = DateTime.Now.Year;

            if (!ValidationUtility.IsNull(date))
            {
                selectDateYear = ValidationUtility.ToInteger(date);
            }

              int storeId = ValidationUtility.ToInteger(sId);
              LiveSaleModel liveSaleModel = new LiveSaleModel();

              if (storeId != 0)
              {

                  Dictionary<int, string> connectionString = (Dictionary<int, string>)Session["ConnectionString"];

                  string storeNameConnectionString = "";

                  if (connectionString.ContainsKey(storeId))
                  {
                      storeNameConnectionString = connectionString[storeId];

                  }

                  list.Add(liveSaleModel.GetYearSaleOfStore(storeId, selectDateYear, storeNameConnectionString));
              }
              else
              {

                  ArrayList storeList = null;
                  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);
                  }

                  list.Add(liveSaleModel.GetYearSaleOfAllStore(selectDateYear, storeList));

              }

            return Json(list, JsonRequestBehavior.AllowGet);
        }