public JsonResult AddCurrentYearGoals(string foodCost, string laborCost, string salesIncrease, string auv, string unitFootlongSales, string fsPercent, string drinkCount, string checkItem, string checkIndex, string customerCount, string customerCountIndex, string unit, string ui, string productivity, string factor) { GoalsModel goalsModel = new GoalsModel(); double fCost = ValidationUtility.ToDouble(foodCost); double lCost = ValidationUtility.ToDouble(laborCost); double foodLaborCost = fCost + lCost; // ArrayList storeList = ValidationUtility.GetStoreList(false); ArrayList storeList = ValidationUtility.GetActiveStoreList(false); ResponseDTO responseDTO = null; foreach (StoreDTO StoreDTO in storeList) { GoalsDTO goalsDTO = new GoalsDTO(); goalsDTO.StoreId = StoreDTO.Id; goalsDTO.Year = DateTime.Now.Year; goalsDTO.FoodCost = fCost; goalsDTO.LaborCost = lCost; goalsDTO.FoodLaborCost = foodLaborCost; goalsDTO.SalesIncrease = ValidationUtility.ToDouble(salesIncrease); goalsDTO.Auv = ValidationUtility.ToDouble(auv); goalsDTO.UnitFootlongSales = ValidationUtility.ToDouble(unitFootlongSales); goalsDTO.FsPercent = ValidationUtility.ToDouble(fsPercent); goalsDTO.DrinkCount = ValidationUtility.ToDouble(drinkCount); goalsDTO.CheckItem = ValidationUtility.ToDouble(checkItem); goalsDTO.CheckIndex = ValidationUtility.ToDouble(checkIndex); goalsDTO.CustomerCount = ValidationUtility.ToDouble(customerCount); goalsDTO.CustomerCountIndex = ValidationUtility.ToDouble(customerCountIndex); goalsDTO.Unit = ValidationUtility.ToDouble(unit); goalsDTO.Ui = ValidationUtility.ToDouble(ui); goalsDTO.Productivity = ValidationUtility.ToDouble(productivity); goalsDTO.Factor = ValidationUtility.ToDouble(factor); if (!goalsModel.IsCurrentYearGoalsExist(StoreDTO.Id, DateTime.Now.Year)) { // goalsModel.AddPreviousYearAchiveGoals(goalsDTO); goalsModel.AddGoals(goalsDTO); goalsModel.AddCurrentYearYTDGoals(goalsDTO); goalsModel.AddPreviousYearAchiveGoals(goalsDTO); responseDTO = new ResponseDTO { Error = "Success", Message = "Add Successfully" }; } else { responseDTO = new ResponseDTO { Error = "Error", Message = "Records Allready Exists Now you can Update Only" }; } } return Json(responseDTO, JsonRequestBehavior.AllowGet); }
/* * Add Last Year Control sheet date */ public void AddControlSheetData(ArrayList previousYearGoalList, int storeId, DateTime date) { try { double foodCost = (double)previousYearGoalList[0]; double laborCost = (double)previousYearGoalList[1]; double foodLaborCost = foodCost + laborCost; double totalSubWaySale = (double)previousYearGoalList[2]; double unitFootlongSales = (double)previousYearGoalList[3]; double fsPercent = ValidationUtility.IsNan(unitFootlongSales / totalSubWaySale); double totalDrinkcountSale = (double)previousYearGoalList[4]; double drinkCount = ValidationUtility.IsNan(totalDrinkcountSale / totalSubWaySale); double totalUnitSold = (double)previousYearGoalList[5]; double totalFactor = (double)previousYearGoalList[6]; double totalCustomerCount = (double)previousYearGoalList[7]; double totalAverageTicket = (double)previousYearGoalList[8]; double totalProductivity = (double)previousYearGoalList[9]; GoalsDTO goalsDTO = new GoalsDTO(); goalsDTO.StoreId = storeId; goalsDTO.Year = DateTime.Now.AddYears(-1).Year; goalsDTO.FoodCost = foodCost; goalsDTO.LaborCost = laborCost; goalsDTO.FoodLaborCost = foodLaborCost; goalsDTO.SalesIncrease = 0; goalsDTO.Auv = totalSubWaySale; goalsDTO.UnitFootlongSales = unitFootlongSales; goalsDTO.FsPercent = fsPercent; goalsDTO.DrinkCount = drinkCount; goalsDTO.CheckItem = totalAverageTicket; goalsDTO.CheckIndex = 0; goalsDTO.CustomerCount = totalCustomerCount; goalsDTO.CustomerCountIndex = 0; goalsDTO.Unit = totalUnitSold; goalsDTO.Ui = 0; goalsDTO.Productivity = totalProductivity; goalsDTO.Factor = totalFactor; AddGoals(goalsDTO); } catch (Exception ex) { log.Error("Exception in AddControlSheetData Method", ex); } }
public JsonResult UpdateCurrentYearGoals(string tId, string sId, string foodCost, string laborCost, string salesIncrease, string auv, string unitFootlongSales, string fsPercent, string drinkCount, string checkItem, string checkIndex, string customerCount, string customerCountIndex, string unit, string ui, string productivity, string factor) { GoalsModel goalsModel = new GoalsModel(); double fCost = ValidationUtility.ToDouble(foodCost); double lCost = ValidationUtility.ToDouble(laborCost); double foodLaborCost = fCost + lCost; GoalsDTO goalsDTO = new GoalsDTO(); goalsDTO.Id = ValidationUtility.ToInteger(tId); goalsDTO.StoreId = ValidationUtility.ToInteger(sId); goalsDTO.FoodCost = fCost; goalsDTO.LaborCost = lCost; goalsDTO.FoodLaborCost = foodLaborCost; goalsDTO.SalesIncrease = ValidationUtility.ToDouble(salesIncrease); goalsDTO.Auv = ValidationUtility.ToDouble(auv); goalsDTO.UnitFootlongSales = ValidationUtility.ToDouble(unitFootlongSales); goalsDTO.FsPercent = ValidationUtility.ToDouble(fsPercent); goalsDTO.DrinkCount = ValidationUtility.ToDouble(drinkCount); goalsDTO.CheckItem = ValidationUtility.ToDouble(checkItem); goalsDTO.CheckIndex = ValidationUtility.ToDouble(checkIndex); goalsDTO.CustomerCount = ValidationUtility.ToDouble(customerCount); goalsDTO.CustomerCountIndex = ValidationUtility.ToDouble(customerCountIndex); goalsDTO.Unit = ValidationUtility.ToDouble(unit); goalsDTO.Ui = ValidationUtility.ToDouble(ui); goalsDTO.Productivity = ValidationUtility.ToDouble(productivity); goalsDTO.Factor = ValidationUtility.ToDouble(factor); goalsModel.UpdateGoals(goalsDTO); ResponseDTO responseDTO = new ResponseDTO { Error = "Success", Message = "Add Successfully" }; return Json(responseDTO, JsonRequestBehavior.AllowGet); }
public JsonResult GetGoalsList(string sId) { int storeId = ValidationUtility.ToInteger(sId); UserContext cont = (UserContext)Session["UserContext"]; if (!ValidationUtility.IsNull(cont) && ValidationUtility.IsEqual(cont.Role, "Manager")) { storeId = ValidationUtility.GetActiveStoredId(cont.Id); } if (storeId == 0) { ArrayList storeList = null; if (!ValidationUtility.IsNull(cont) && ValidationUtility.IsEqual(cont.Role, "Admin")) { storeList = ValidationUtility.GetActiveStoreList(true); } if (!ValidationUtility.IsNull(cont) && ValidationUtility.IsEqual(cont.Role, "Corporate")) { storeList = ValidationUtility.GetCorporateUserAssignActiveStore(cont.Id, true); } if (!ValidationUtility.IsNull(cont) && ValidationUtility.IsEqual(cont.Role, "GeneralManager")) { storeList = ValidationUtility.GetGeneralManagerAssignActiveStore(cont.Id); } if (!ValidationUtility.IsNull(cont) && ValidationUtility.IsEqual(cont.Role, "AreaManager")) { storeList = ValidationUtility.GetAreaMngAssignActiveStore(cont.Id); } ArrayList averageList = new ArrayList(); if (!ValidationUtility.IsNull(storeList) && storeList.Count > 0) { GoalsModel goalsModel = new GoalsModel(); ArrayList achiveGoalDTOList = new ArrayList(); ArrayList currentGoalsDTOList = new ArrayList(); ArrayList currentYTDDTOList = new ArrayList(); ArrayList PrviousYTDDTOList = new ArrayList(); foreach (StoreDTO storeDTO in storeList) { ArrayList allList = GetstoreGoalList(storeDTO.Id); GoalYTDDTO goalYTDDTO = (GoalYTDDTO)allList[0]; achiveGoalDTOList.Add(goalYTDDTO); GoalsDTO currnetGoalDTO = (GoalsDTO)allList[1]; // Current Year Goal may be null because if user not insert his goal then it will be blank if (ValidationUtility.IsNull(currnetGoalDTO)) { currnetGoalDTO = new GoalsDTO(); } currentGoalsDTOList.Add(currnetGoalDTO); GoalYTDDTO currYTDDTO = (GoalYTDDTO)allList[2]; currentYTDDTOList.Add(currYTDDTO); GoalYTDDTO previousYTDDTO = (GoalYTDDTO)allList[3]; PrviousYTDDTOList.Add(previousYTDDTO); } averageList.Add(goalsModel.GetAllStoreAverageGoals(achiveGoalDTOList)); averageList.Add(goalsModel.GetAllStoreCurrentGoalAverageGoals(currentGoalsDTOList)); averageList.Add(goalsModel.GetAllStoreAverageGoals(currentYTDDTOList)); averageList.Add(goalsModel.GetAllStoreAverageGoals(PrviousYTDDTOList)); } return Json(averageList, JsonRequestBehavior.AllowGet); } else { return Json(GetstoreGoalList(storeId), JsonRequestBehavior.AllowGet); } }
public GoalsDTO GetCurrentYearGoalsList(int sId, int goalYear) { GoalsDTO goalsDTO = null; DataBaseUtility db = new DataBaseUtility(); SqlConnection conn = null; try { string query = " select * from dbo.Goals g where g.StoreId=" + SQLUtility.getInteger(sId) + " and g.Year = " + SQLUtility.getInteger(goalYear) + " "; conn = db.OpenConnection(); SqlCommand comm = db.getSQLCommand(query, conn); SqlDataReader reader = comm.ExecuteReader(); if (reader.Read()) { int id = ValidationUtility.ToInteger(reader["Id"].ToString()); int storeId = ValidationUtility.ToInteger(reader["StoreId"].ToString()); int year = ValidationUtility.ToInteger(reader["Year"].ToString()); double foodCost = ValidationUtility.ToDouble(reader["FoodCost"].ToString()); double laborCost = ValidationUtility.ToDouble(reader["LaborCost"].ToString()); double foodLaborCost = ValidationUtility.ToDouble(reader["FoodLaborCost"].ToString()); double salesIncrease = ValidationUtility.ToDouble(reader["SalesIncrease"].ToString()); double auv = ValidationUtility.ToDouble(reader["Auv"].ToString()); double ufs = ValidationUtility.ToDouble(reader["UnitFootlongSales"].ToString()); double fsPercent = ValidationUtility.ToDouble(reader["FsPercent"].ToString()); double dc = ValidationUtility.ToDouble(reader["DrinkCount"].ToString()); double ck = ValidationUtility.ToDouble(reader["CheckItem"].ToString()); double cki = ValidationUtility.ToDouble(reader["CheckIndex"].ToString()); double cc = ValidationUtility.ToDouble(reader["CustomerCount"].ToString()); double cci = ValidationUtility.ToDouble(reader["CustomerCountIndex"].ToString()); double unit = ValidationUtility.ToDouble(reader["Unit"].ToString()); double ui = ValidationUtility.ToDouble(reader["Ui"].ToString()); double prod = ValidationUtility.ToDouble(reader["Productivity"].ToString()); double factor = ValidationUtility.ToDouble(reader["Factor"].ToString()); goalsDTO = new GoalsDTO { Id = id, StoreId = storeId, Year = year, FoodCost = foodCost, LaborCost = laborCost, FoodLaborCost = foodLaborCost, SalesIncrease = salesIncrease, Auv = auv, UnitFootlongSales = ufs, FsPercent = fsPercent, DrinkCount = dc, CheckItem = ck, CheckIndex = cki, CustomerCount = cc, CustomerCountIndex = cci, Unit = unit, Ui = ui, Productivity = prod, Factor = factor }; } reader.Close(); comm.Dispose(); } catch (Exception ex) { log.Error("Exception in GetAllGoalsList method", ex); } finally { db.CloseConnection(conn); } return goalsDTO; }
public GoalsDTO GetAllStoreCurrentGoalAverageGoals(ArrayList storeGoalList) { GoalsDTO newgoalYTDDTO = new GoalsDTO(); int storeCount = storeGoalList.Count; foreach (GoalsDTO previousYearGoalDTO in storeGoalList) { newgoalYTDDTO.FoodCost = newgoalYTDDTO.FoodCost + previousYearGoalDTO.FoodCost; newgoalYTDDTO.LaborCost = newgoalYTDDTO.LaborCost + previousYearGoalDTO.FoodCost; newgoalYTDDTO.FoodLaborCost = newgoalYTDDTO.FoodLaborCost + previousYearGoalDTO.FoodLaborCost; newgoalYTDDTO.SalesIncrease = newgoalYTDDTO.SalesIncrease + previousYearGoalDTO.SalesIncrease; newgoalYTDDTO.Auv = newgoalYTDDTO.Auv + previousYearGoalDTO.Auv; newgoalYTDDTO.UnitFootlongSales = newgoalYTDDTO.UnitFootlongSales + previousYearGoalDTO.UnitFootlongSales; newgoalYTDDTO.FsPercent = newgoalYTDDTO.FsPercent + previousYearGoalDTO.FsPercent; newgoalYTDDTO.DrinkCount = newgoalYTDDTO.DrinkCount + previousYearGoalDTO.DrinkCount; newgoalYTDDTO.CheckItem = newgoalYTDDTO.CheckItem + previousYearGoalDTO.CheckItem; newgoalYTDDTO.CheckIndex = newgoalYTDDTO.CheckIndex + previousYearGoalDTO.CheckIndex; newgoalYTDDTO.CustomerCount = newgoalYTDDTO.CustomerCount + previousYearGoalDTO.CustomerCount; newgoalYTDDTO.CustomerCountIndex = newgoalYTDDTO.CustomerCountIndex + previousYearGoalDTO.CustomerCountIndex; newgoalYTDDTO.Unit = newgoalYTDDTO.Unit + previousYearGoalDTO.Unit; newgoalYTDDTO.Ui = newgoalYTDDTO.Ui + previousYearGoalDTO.Ui; newgoalYTDDTO.Productivity = newgoalYTDDTO.Productivity + previousYearGoalDTO.Productivity; newgoalYTDDTO.Factor = newgoalYTDDTO.Factor + previousYearGoalDTO.Factor; } GoalsDTO jsonDTO = new GoalsDTO { FoodCost = newgoalYTDDTO.FoodCost / storeCount, LaborCost = newgoalYTDDTO.LaborCost / storeCount, FoodLaborCost = newgoalYTDDTO.FoodLaborCost / storeCount, SalesIncrease = newgoalYTDDTO.SalesIncrease / storeCount, Auv = newgoalYTDDTO.Auv / storeCount, UnitFootlongSales = newgoalYTDDTO.UnitFootlongSales / storeCount, FsPercent = newgoalYTDDTO.FsPercent / storeCount, DrinkCount = newgoalYTDDTO.DrinkCount / storeCount, CheckItem = newgoalYTDDTO.CheckItem / storeCount, CheckIndex = newgoalYTDDTO.CheckIndex / storeCount, CustomerCount = newgoalYTDDTO.CustomerCount / storeCount, CustomerCountIndex = newgoalYTDDTO.CustomerCountIndex / storeCount, Unit = newgoalYTDDTO.Unit / storeCount, Ui = newgoalYTDDTO.Ui / storeCount, Productivity = newgoalYTDDTO.Productivity / storeCount, Factor = newgoalYTDDTO.Factor / storeCount }; return jsonDTO; }
public void AddPreviousYearAchiveGoals(GoalsDTO goalsDTO) { DataBaseUtility db = new DataBaseUtility(); string query = "INSERT INTO [dbo].[Goals] ([StoreId] ,[Year] ,[FoodCost] ,[LaborCost] ,[FoodLaborCost] ," + " [SalesIncrease] ,[AUV] ,[UnitFootlongSales] ,[FsPercent] ,[DrinkCount] ,[CheckItem] ,[CheckIndex] ,[CustomerCount] , " + " [CustomerCountIndex] ,[Unit] ,[UI] ,[Productivity] ,[Factor] ,[CreatedDateTime] ,[LastUpdateDateTime]) " + " VALUES(" + SQLUtility.getInteger(goalsDTO.StoreId) + "," + SQLUtility.getInteger(goalsDTO.Year) + ", 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0," + " '" + SQLUtility.FormateDateYYYYMMDDWtithTime(DateTime.Now) + "','" + SQLUtility.FormateDateYYYYMMDDWtithTime(DateTime.Now) + "')"; db.ExecuteUpdate(query); }
public void UpdateGoals(GoalsDTO goalsDTO) { DataBaseUtility db = new DataBaseUtility(); string query = "update dbo.Goals set FoodCost=" + SQLUtility.getDouble(goalsDTO.FoodCost) + ",LaborCost=" + SQLUtility.getDouble(goalsDTO.LaborCost) + ",FoodLaborCost=" + SQLUtility.getDouble(goalsDTO.FoodLaborCost) + ", " + " SalesIncrease=" + SQLUtility.getDouble(goalsDTO.SalesIncrease) + ", Auv=" + SQLUtility.getDouble(goalsDTO.Auv) + ",UnitFootlongSales=" + SQLUtility.getDouble(goalsDTO.UnitFootlongSales) + " , " + " FsPercent=" + SQLUtility.getDouble(goalsDTO.FsPercent) + ", DrinkCount=" + SQLUtility.getDouble(goalsDTO.DrinkCount) + ", CheckItem=" + SQLUtility.getDouble(goalsDTO.CheckItem) + ",CheckIndex=" + SQLUtility.getDouble(goalsDTO.CheckIndex) + ", " + " CustomerCount=" + SQLUtility.getDouble(goalsDTO.CustomerCount) + ",CustomerCountIndex=" + SQLUtility.getDouble(goalsDTO.CustomerCountIndex) + ",Unit=" + SQLUtility.getDouble(goalsDTO.Unit) + ", Ui=" + SQLUtility.getDouble(goalsDTO.Ui) + ", " + " Productivity=" + SQLUtility.getDouble(goalsDTO.Productivity) + ",Factor=" + SQLUtility.getDouble(goalsDTO.Factor) + ",LastUpdateDateTime='" + SQLUtility.FormateDateYYYYMMDDWtithTime(DateTime.Now) + "' where Id=" + SQLUtility.getInteger(goalsDTO.Id) + " and StoreId=" + SQLUtility.getInteger(goalsDTO.StoreId) + ""; db.ExecuteUpdate(query); }