public void AddLastYearWeeklyPaperwork(DateTime date, ArrayList storeList)
        {
            try
            {
                StoreDTO storeDTO = (StoreDTO)storeList[0];

                WeeklyPaperworkModel model = new WeeklyPaperworkModel();

                bool isWeekExsist = false;

                DateTime yearFirstWeekDate = ValidationUtility.YearWeekStartDate(date);

                if (!model.IsWeeklyPaperExistIntoLocalDb(storeDTO.Id, yearFirstWeekDate))
                {
                    model.AddWeeklyPaperWork(yearFirstWeekDate, storeList, true);
                }

                DateTime everyWeekStarDate = yearFirstWeekDate;

                DateTime yearLastWeekDate = ValidationUtility.GetActualWeekStartDate(new DateTime(date.Year, 12, 31));

                while (!isWeekExsist)
                {
                    everyWeekStarDate = everyWeekStarDate.AddDays(7);

                    DateTime weekStartDate = ValidationUtility.GetActualWeekStartDate(everyWeekStarDate);

                    if (yearLastWeekDate.Date.Equals(weekStartDate.Date))
                    {
                        isWeekExsist = true;

                        if (!model.IsWeeklyPaperExistIntoLocalDb(storeDTO.Id, weekStartDate))
                        {
                            model.AddWeeklyPaperWork(weekStartDate, storeList, true);
                        }

                    }
                    else
                    {
                        if (!model.IsWeeklyPaperExistIntoLocalDb(storeDTO.Id, weekStartDate))
                        {
                            model.AddWeeklyPaperWork(weekStartDate, storeList, true);
                        }
                    }

                }
            }
            catch (Exception ex)
            {

                log.Error("Exception in AddLastYearWeeklyPaperwork Method",ex);
            }
        }
Esempio n. 2
0
        public ArrayList GetstoreGoalList(int storeId)
        {
            ArrayList goalList = new ArrayList();

            WeeklyPaperworkModel weekPaperModel = new WeeklyPaperworkModel();

            //  int storeId = ValidationUtility.ToInteger(sId);

            AddPreviousYearInfoModel previouseYear = new AddPreviousYearInfoModel();
            GoalsModel goalsModel = new GoalsModel();

             //   ArrayList storeList = ValidationUtility.GetStoreList(true);

            ArrayList storeList = ValidationUtility.GetActiveStoreList(true);

            ArrayList goalStoreList = new ArrayList();

            foreach (StoreDTO storDTO in storeList)
            {
                if (storDTO.Id == storeId)
                {
                    goalStoreList.Add(storDTO);
                    break;
                }
            }

            DateTime previousYearWeekStartDate = ValidationUtility.YearWeekStartDate(new DateTime(DateTime.Now.AddYears(-1).Year, 1, 1));

            DateTime currentYearWeekStartDate = ValidationUtility.YearWeekStartDate(new DateTime(DateTime.Now.Year, 1, 1));

            if (!weekPaperModel.IsAllWeeklyPaperYearWeekRecordExsist(goalStoreList, DateTime.Now))
            {
                previouseYear.AddLastYearWeeklyPaperwork(new DateTime(DateTime.Now.AddYears(-1).Year, 1, 1), goalStoreList);
            }

            if (!goalsModel.IsAllYearWeekRecordExsist(goalStoreList, DateTime.Now))
            {
                goalsModel.AddPreviousYearYTD(previousYearWeekStartDate, goalStoreList);
            }

            goalsModel.AddCurrentYearYTD(new DateTime(DateTime.Now.Year, 1, 1), goalStoreList);

            ArrayList currentYTDList = goalsModel.GetCurrentWeekGoalsYTD(DateTime.Now, goalStoreList);
            goalsModel.UpdateCurrentYTD(currentYTDList);

            GoalYTDDTO previousYearYtd = goalsModel.GetPreviousGoalYTDList(storeId, currentYearWeekStartDate);

            goalList.Add(previousYearYtd);

            goalList.Add(goalsModel.GetCurrentYearGoalsList(storeId, DateTime.Now.Year));

            goalList.Add(goalsModel.GetCurrrentYTDList(storeId, currentYearWeekStartDate, previousYearYtd));

            goalList.Add(goalsModel.GetPreviousYTDList(storeId, previousYearWeekStartDate));

            //if (!goalsModel.IsCurrentYearGoalsExist(storeId, DateTime.Now.AddYears(-1).Year))
            //{

            //    ArrayList PreviousYearDataList = previouseYear.GetControlSheetDataOfYear(new DateTime(DateTime.Now.AddYears(-1).Year, 1, 1), goalStoreList);

            //    goalsModel.AddControlSheetData(PreviousYearDataList, storeId, new DateTime(DateTime.Now.AddYears(-2).Year, 1, 1));
            //}

            //if (!goalsModel.IsGoalsYTDPreviousYearRecordExist(previousYearWeekStartDate, goalStoreList))
            //{
            //    goalsModel.AddPreviousYearYTD(previousYearWeekStartDate, goalStoreList);
            //}

            //DateTime currentYearWeekStartDate = ValidationUtility.YearWeekStartDate(new DateTime(DateTime.Now.Year, 1, 1));

            //if (!goalsModel.IsGoalsYTDCurrentYearRecordExist(currentYearWeekStartDate, goalStoreList))
            //{
            //    goalsModel.AddCurrentYearYTD(new DateTime(DateTime.Now.Year, 1, 1), goalStoreList);

            //}
            //else
            //{
            //    ArrayList currentYTDList = goalsModel.GetCurrentWeekGoalsYTD(currentYearWeekStartDate, goalStoreList);
            //    goalsModel.UpdateCurrentYTD(currentYTDList);
            //}
            //DateTime everyWeekStarDate = currentYearWeekStartDate;

            //bool isWeekExsist = false;

            //while (!isWeekExsist)
            //{
            //    everyWeekStarDate = everyWeekStarDate.AddDays(7);

            //    DateTime currenWeekStartDate = ValidationUtility.GetActualWeekStartDate(DateTime.Now);

            //    if (!goalsModel.IsGoalsYTDCurrentYearRecordExist(everyWeekStarDate, goalStoreList))
            //    {
            //        ArrayList currentYTDList = goalsModel.GetCurrentWeekGoalsYTD(everyWeekStarDate, goalStoreList);
            //        goalsModel.AddGoalYTD(currentYTDList);
            //    }

            //    if (currenWeekStartDate.Date.Equals(everyWeekStarDate.Date))
            //    {
            //        isWeekExsist = true;
            //        ArrayList currentYTDList = goalsModel.GetCurrentWeekGoalsYTD(everyWeekStarDate, goalStoreList);
            //        goalsModel.UpdateCurrentYTD(currentYTDList);
            //    }

            //}

            //DateTime currenWeekStartDate = ValidationUtility.GetActualWeekStartDate(DateTime.Now);

            //ArrayList currentYTDList = goalsModel.GetCurrentWeekGoalsYTD(currenWeekStartDate, goalStoreList);

            //if (!goalsModel.IsGoalsYTDCurrentYearRecordExist(currenWeekStartDate, goalStoreList))
            //{
            //    goalsModel.AddGoalYTD(currentYTDList);
            //}
            //else
            //{
            //    goalsModel.UpdateCurrentYTD(currentYTDList);
            //}

            //  ArrayList goalList = goalsModel.GetAllGoalsList(storeId);

            //goalList.Add(goalsModel.GetAllGoalsList(storeId));

            ////Get CurrentYearYTD
            //goalList.Add(goalsModel.GetCurrrentYTDList(storeId, currentYearWeekStartDate));

            ////GetPreviousYear YTD
            //goalList.Add(goalsModel.GetPreviousYTDList(storeId, previousYearWeekStartDate));

            //  return Json(goalList, JsonRequestBehavior.AllowGet);

            return goalList;
        }
        //Get Data From server For Actual Value
        public WeeklyPaperworkDTO GetWeeklyPaperWork(DateTime currentWeekStartDate, ArrayList storeList)
        {
            WeeklyPaperworkDTO dto = null;

            try
            {
                ReportModel reportModel = new ReportModel();

                StoreDTO storeDTO = (StoreDTO)storeList[0];

                WeeklyPaperworkModel model = new WeeklyPaperworkModel();

                DateTime weekStartDate = ValidationUtility.GetActualWeekStartDate(currentWeekStartDate);

                bool flag = model.IsWeeklyPaperExistIntoLocalDb(storeDTO.Id, weekStartDate);

                if (!flag)
                {
                    model.AddWeeklyPaperWork(weekStartDate, storeList, true);
                    dto = model.GetWeeklyPaperWorkOfWeek(storeDTO.Id, weekStartDate);

                }

                else
                {
                    dto = model.GetWeeklyPaperWorkOfWeek(storeDTO.Id, weekStartDate);

                }

            }
            catch (Exception ex)
            {

                log.Error("Exception in GetCurrentWeekGoalsYTD Method", ex);
            }

            return dto;
        }
        public JsonResult GetPaperworkList(string sId, string selectedDate)
        {
            WeeklyPaperworkModel weeklyPaperworkModel = new WeeklyPaperworkModel();

            List<ArrayList> mainList = new List<ArrayList>();

            int storeId = ValidationUtility.ToInteger(sId);

            DateTime formatedDate;

            if (!ValidationUtility.IsNull(selectedDate))
            {
                formatedDate = ValidationUtility.ToDate(selectedDate);
            }
            else
            {
                formatedDate = DateTime.Now;
            }

            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.GetStoreList(true);

                    storeList = ValidationUtility.GetActiveStoreList(true);
                }
                //storeList = ValidationUtility.GetStoreList(true);
            }
            else
            {
             //   ArrayList tempList = ValidationUtility.GetStoreList(true);

                ArrayList tempList = ValidationUtility.GetActiveStoreList(true);

                foreach (StoreDTO storeDTO in tempList)
                {
                    if (storeId == storeDTO.Id)
                    {
                        storeList = new ArrayList();
                        storeList.Add(storeDTO);
                        break;

                    }

                }

            }

            DateTime weekStartDay = ValidationUtility.GetActualWeekStartDate(formatedDate);

            ArrayList paperList = weeklyPaperworkModel.GetWeeklyPaperListFromLocalDB(storeList, weekStartDay);

            mainList.Add(paperList);

            //if (paperList.Count != 0)
            //{
            //    mainList.Add(paperList);

            //}

            //else
            //{
            //    weeklyPaperworkModel.AddWeeklyPaperWork(formatedDate, storeList);

            //    paperList = weeklyPaperworkModel.GetWeeklyPaperListFromLocalDB(storeList, weekStartDay);
            //    mainList.Add(paperList);
            //}

            mainList.Add(weeklyPaperworkModel.GetTotal(paperList));

            return Json(mainList, JsonRequestBehavior.AllowGet);
        }
        public JsonResult UpdatePaperworkList(string id, string ar, string paidOuts, string pettyExpense, string storeTransfer, string pfg1, string pfg2, string coke, string laborCost, string taxPercent, string nonTaxableSale)
        {
            WeeklyPaperworkModel weeklyPaperworkModel = new WeeklyPaperworkModel();

            GoalsModel goalsModel = new GoalsModel();

            string error = "";
            string msg = "";

            try
            {
                WeeklyPaperworkDTO weeklyPaperworkDTO = new WeeklyPaperworkDTO();
                weeklyPaperworkDTO.Id = ValidationUtility.ToInteger(id);

                weeklyPaperworkDTO.Ar = ValidationUtility.ToDouble(ar);
                weeklyPaperworkDTO.PaidOuts = ValidationUtility.ToDouble(paidOuts);
                weeklyPaperworkDTO.PettyExpense = ValidationUtility.ToDouble(pettyExpense);
                weeklyPaperworkDTO.StoreTransfer = ValidationUtility.ToDouble(storeTransfer);

                weeklyPaperworkDTO.Pfg1 = ValidationUtility.ToDouble(pfg1);
                weeklyPaperworkDTO.Pfg2 = ValidationUtility.ToDouble(pfg2);
                weeklyPaperworkDTO.Coke = ValidationUtility.ToDouble(coke);
                weeklyPaperworkDTO.LaborCost = ValidationUtility.ToDouble(laborCost);
                weeklyPaperworkDTO.TaxPercent = ValidationUtility.ToDouble(taxPercent);
                weeklyPaperworkDTO.NonTaxableSale = ValidationUtility.ToDouble(nonTaxableSale);

                weeklyPaperworkModel.UpdateWeeklyPaperSales(weeklyPaperworkDTO);

                weeklyPaperworkDTO = weeklyPaperworkModel.GetWeeklyPaperWorkOfWeek(ValidationUtility.ToInteger(id));

                ArrayList goalStoreList = new ArrayList();

               // ArrayList storeList = ValidationUtility.GetStoreList(true);

                ArrayList storeList = ValidationUtility.GetActiveStoreList(true);

                foreach (StoreDTO storDTO in storeList)
                {
                    if (storDTO.Id == weeklyPaperworkDTO.StoreId)
                    {
                        goalStoreList.Add(storDTO);
                        break;
                    }
                }

                if (!goalsModel.IsGoalsYTDCurrentYearRecordExist(weeklyPaperworkDTO.WeekStartDate, goalStoreList))
                {

                    ArrayList currentYTDList = goalsModel.GetCurrentWeekGoalsYTD(weeklyPaperworkDTO.WeekStartDate, goalStoreList);
                    goalsModel.AddGoalYTD(currentYTDList);
                }
                else
                {
                    goalsModel.UpdateCurrentYTD(weeklyPaperworkDTO);
                }

                error = "Success";
                msg = "Update Successfully";
            }
            catch (Exception ex)
            {
                error = "Error";
                msg = " Not Update ";
                log.Error("Exception in UpdatePaperworkList ", ex);

            }

            ResponseDTO resDTO = new ResponseDTO { Error = error, Message = msg };
            return Json(resDTO, JsonRequestBehavior.AllowGet);
        }
Esempio n. 6
0
        //public GoalsDTO GetLast(DateTime date)
        //{
        //}
        public void AddCurrentYearYTD(DateTime date, ArrayList storeList)
        {
            try
            {
                ArrayList ytdList = new ArrayList();

                ArrayList list = new ArrayList();

                ReportModel reportModel = new ReportModel();

                GoalYTDDTO ytdDTO = new GoalYTDDTO();

                bool isWeekExsist = false;

                StoreDTO storeDTO = (StoreDTO)storeList[0];

                WeeklyPaperworkModel model = new WeeklyPaperworkModel();

                DateTime yearFirstWeekStartDate = ValidationUtility.YearWeekStartDate(date);

                bool flag = model.IsWeeklyPaperExistIntoLocalDb(storeDTO.Id, yearFirstWeekStartDate);

                ytdDTO.StoreId = storeDTO.Id;
                ytdDTO.Year = date.Year;
                ytdDTO.WeekStartDate = yearFirstWeekStartDate;
                ytdDTO.WeekEndDate = yearFirstWeekStartDate.AddDays(6);

                if (!flag)
                {
                    model.AddWeeklyPaperWork(yearFirstWeekStartDate, storeList, true);
                    WeeklyPaperworkDTO dto = model.GetWeeklyPaperWorkOfWeek(storeDTO.Id, yearFirstWeekStartDate);
                    ytdDTO.FoodCost = dto.CostPercent;
                    ytdDTO.LaborCost = dto.LaborCostPercent;
                    ytdDTO.FoodLaborCost = dto.CostPercent + dto.LaborCostPercent;

                }
                else
                {
                    WeeklyPaperworkDTO dto = model.GetWeeklyPaperWorkOfWeek(storeDTO.Id, yearFirstWeekStartDate);
                    ytdDTO.FoodCost = dto.CostPercent;
                    ytdDTO.LaborCost = dto.LaborCostPercent;
                    ytdDTO.FoodLaborCost = dto.CostPercent + dto.LaborCostPercent;
                }

                double totalsubWaySale = reportModel.TotalSabWaySaleOfYear(yearFirstWeekStartDate, yearFirstWeekStartDate.AddDays(6), storeDTO.ConnectionString);
                ytdDTO.Auv = totalsubWaySale;

                double totalDrinkSale = reportModel.TotalDrinkSale(yearFirstWeekStartDate, yearFirstWeekStartDate.AddDays(6), storeDTO.ConnectionString);
                ytdDTO.DrinkCount = ValidationUtility.IsNan(totalDrinkSale / totalsubWaySale);

                list = reportModel.GetSalesItemizationFoodLong(yearFirstWeekStartDate, storeDTO.ConnectionString);
                ytdDTO.UnitFootlongSales = (double)list[0];
                ytdDTO.FsPercent = ValidationUtility.IsNan(ytdDTO.UnitFootlongSales/ytdDTO.Auv);
                ytdDTO.Unit = (double)list[1];
                ytdDTO.Factor = (double)list[2];
                ytdDTO.CustomerCount = (double)list[3];
                ytdDTO.CheckItem = (double)list[4];
                ytdDTO.Productivity = (double)list[5];
                ytdDTO.HoursWorked = (double)list[6];

                DateTime everyWeekStarDate = yearFirstWeekStartDate;

                DateTime currenWeekStartDate = ValidationUtility.GetActualWeekStartDate(DateTime.Now);

                ytdList.Add(ytdDTO);

                while (!isWeekExsist)
                {
                    ytdDTO = new GoalYTDDTO();

                    ytdDTO.StoreId = storeDTO.Id;
                    ytdDTO.Year = date.Year;

                    everyWeekStarDate = everyWeekStarDate.AddDays(7);

                    DateTime weekStartDate = ValidationUtility.GetActualWeekStartDate(everyWeekStarDate);
                    ytdDTO.WeekStartDate = weekStartDate;
                    ytdDTO.WeekEndDate = weekStartDate.AddDays(6);

                    flag = model.IsWeeklyPaperExistIntoLocalDb(storeDTO.Id, weekStartDate);

                    if (currenWeekStartDate.Date.Equals(weekStartDate.Date))
                    {
                        isWeekExsist = true;

                        if (!flag)
                        {
                            model.AddWeeklyPaperWork(weekStartDate, storeList, true);
                            WeeklyPaperworkDTO dto = model.GetWeeklyPaperWorkOfWeek(storeDTO.Id, weekStartDate);
                            ytdDTO.FoodCost = dto.CostPercent;
                            ytdDTO.LaborCost = dto.LaborCostPercent;
                            ytdDTO.FoodLaborCost = dto.CostPercent + dto.LaborCostPercent;
                        }

                        totalsubWaySale = reportModel.TotalSabWaySaleOfYear(weekStartDate, weekStartDate.AddDays(6), storeDTO.ConnectionString);
                        ytdDTO.Auv = totalsubWaySale;

                        totalDrinkSale = reportModel.TotalDrinkSale(weekStartDate, weekStartDate.AddDays(6), storeDTO.ConnectionString);
                        ytdDTO.DrinkCount = ValidationUtility.IsNan(totalDrinkSale / totalsubWaySale);

                        list = reportModel.GetSalesItemizationFoodLong(weekStartDate, storeDTO.ConnectionString);
                        ytdDTO.UnitFootlongSales = (double)list[0];
                        ytdDTO.FsPercent = ValidationUtility.IsNan(ytdDTO.UnitFootlongSales / ytdDTO.Auv);
                        ytdDTO.Unit = (double)list[1];
                        ytdDTO.Factor = (double)list[2];
                        ytdDTO.CustomerCount = (double)list[3];
                        ytdDTO.CheckItem = (double)list[4];
                        ytdDTO.Productivity = (double)list[5];
                        ytdDTO.HoursWorked = (double)list[6];

                    }
                    else
                    {
                        if (!flag)
                        {
                            model.AddWeeklyPaperWork(weekStartDate, storeList, true);
                            WeeklyPaperworkDTO dto = model.GetWeeklyPaperWorkOfWeek(storeDTO.Id, weekStartDate);
                            ytdDTO.FoodCost = dto.CostPercent;
                            ytdDTO.LaborCost = dto.LaborCostPercent;
                            ytdDTO.FoodLaborCost = dto.CostPercent + dto.LaborCostPercent;
                        }

                        totalsubWaySale= reportModel.TotalSabWaySaleOfYear(weekStartDate, weekStartDate.AddDays(6), storeDTO.ConnectionString);
                        ytdDTO.Auv = totalsubWaySale;

                        totalDrinkSale = reportModel.TotalDrinkSale(weekStartDate, weekStartDate.AddDays(6), storeDTO.ConnectionString);
                        ytdDTO.DrinkCount = ValidationUtility.IsNan(totalDrinkSale / totalsubWaySale);

                        list = reportModel.GetSalesItemizationFoodLong(weekStartDate, storeDTO.ConnectionString);
                        ytdDTO.UnitFootlongSales = (double)list[0];
                        ytdDTO.FsPercent = ValidationUtility.IsNan(ytdDTO.UnitFootlongSales / ytdDTO.Auv);
                        ytdDTO.Unit = (double)list[1];
                        ytdDTO.Factor = (double)list[2];
                        ytdDTO.CustomerCount = (double)list[3];
                        ytdDTO.CheckItem = (double)list[4];
                        ytdDTO.Productivity = (double)list[5];
                        ytdDTO.HoursWorked = (double)list[6];

                    }
                    ytdList.Add(ytdDTO);

                }

                AddGoalYTD(ytdList);
            }
            catch (Exception ex)
            {
                log.Error("Exception in  AddCurrentYearYTD Method", ex);
            }
        }
Esempio n. 7
0
        public ArrayList GetCurrentWeekGoalsYTD(DateTime currentWeekStartDate, ArrayList storeList)
        {
            ArrayList currentYTDList = new ArrayList();

            try
            {

                GoalYTDDTO ytdDTO = new GoalYTDDTO();

                ReportModel reportModel = new ReportModel();

                StoreDTO storeDTO = (StoreDTO)storeList[0];

                WeeklyPaperworkModel model = new WeeklyPaperworkModel();

                ytdDTO.StoreId = storeDTO.Id;

                ytdDTO.Year = currentWeekStartDate.Year;

                DateTime weekStartDate = ValidationUtility.GetActualWeekStartDate(currentWeekStartDate);
                ytdDTO.WeekStartDate = weekStartDate;
                ytdDTO.WeekEndDate = weekStartDate.AddDays(6);

                bool flag = model.IsWeeklyPaperExistIntoLocalDb(storeDTO.Id, weekStartDate);

                if (!flag)
                {
                    model.AddWeeklyPaperWork(weekStartDate, storeList, true);
                    WeeklyPaperworkDTO dto = model.GetWeeklyPaperWorkOfWeek(storeDTO.Id, weekStartDate);
                    ytdDTO.FoodCost = dto.CostPercent;
                    ytdDTO.LaborCost = dto.LaborCostPercent;
                    ytdDTO.FoodLaborCost = dto.CostPercent + dto.LaborCostPercent;
                }

                else
                {
                    WeeklyPaperworkDTO dto = model.GetWeeklyPaperWorkOfWeek(storeDTO.Id, weekStartDate);
                    ytdDTO.FoodCost = dto.CostPercent;
                    ytdDTO.LaborCost = dto.LaborCostPercent;
                    ytdDTO.FoodLaborCost = dto.CostPercent + dto.LaborCostPercent;
                }

                double totalsubWaySale = reportModel.TotalSabWaySaleOfYear(weekStartDate, weekStartDate.AddDays(6), storeDTO.ConnectionString);
                ytdDTO.Auv = totalsubWaySale;

                double totalDrinkSale = reportModel.TotalDrinkSale(weekStartDate, weekStartDate.AddDays(6), storeDTO.ConnectionString);
                ytdDTO.DrinkCount = ValidationUtility.IsNan(totalDrinkSale / totalsubWaySale);

                ArrayList list = reportModel.GetSalesItemizationFoodLong(weekStartDate, storeDTO.ConnectionString);
                ytdDTO.UnitFootlongSales = (double)list[0];
                ytdDTO.FsPercent = ValidationUtility.IsNan(ytdDTO.UnitFootlongSales/ytdDTO.Auv);
                ytdDTO.Unit = (double)list[1];
                ytdDTO.Factor = (double)list[2];
                ytdDTO.CustomerCount = (double)list[3];
                ytdDTO.CheckItem = (double)list[4];
                ytdDTO.Productivity = (double)list[5];
                ytdDTO.HoursWorked = (double)list[6];

                currentYTDList.Add(ytdDTO);
            }
            catch (Exception ex)
            {

                log.Error("Exception in GetCurrentWeekGoalsYTD Method", ex);
            }

            return currentYTDList;
        }