private void getGuestMeals(string mid) { string response = ""; GuestMealsModel gmm = new GuestMealsModel(); List <GuestMealsModel> gmList = new List <GuestMealsModel>(); //Get all guest meals gmm.memberId = mid; gmm.date = getDate(); foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberIdAndDate()) { gmList.Add(gm); } //Process result if (gmm.response == "500") { response = "e"; ViewBag.GuestTotal = 0; } else { response = "s"; //Count meals int countB = 0; int countL = 0; int countD = 0; foreach (GuestMealsModel g in gmList) { if (g.breakfast == "1") { countB++; } if (g.lunch == "1") { countL++; } if (g.dinner == "1") { countD++; } } ViewBag.GuestB = countB; ViewBag.GuestL = countL; ViewBag.GuestD = countD; ViewBag.GuestTotal = countB + countL + countD; } ViewBag.GuestResponse = response; }
public ActionResult DeleteGuestMeal(int id) { if (Session["user"] != null) { UserSessionModel session = (UserSessionModel)Session["user"]; if (session.acctype == "u" || session.acctype == "m") { GuestMealsModel gmm = new GuestMealsModel(); gmm.id = id.ToString(); gmm.deleteMeal(); if (gmm.response == "500") { return(Json(new { msgtype = "e", msg = "Something went wrong! Try again..." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { msgtype = "s", msg = "Deleted successfully!" }, JsonRequestBehavior.AllowGet)); } } else { return(RedirectToAction("UserLogin", "User")); } } else { return(RedirectToAction("UserLogin", "User")); } }
private void processReport(string month, string year) { //Get all users string response = ""; UsersModel usm = new UsersModel(); List <UsersModel> usList = new List <UsersModel>(); //Get preferences PreferencesModel pm = new PreferencesModel(); pm.getPrefrences(); foreach (UsersModel user in usm.getAllUsers()) { usList.Add(user); } if (usm.response == "500") { response = "e"; } else { response = "s"; int totalMeals = 0; int totalMealCost = 0; int serviceCharge = 0; int totalCost = 0; string showing = ""; string costInfo = ""; string details = ""; //Check for valid date input bool isValid = false; string date = year + "-" + month + "-01"; DateTime dt2; if (DateTime.TryParse(date, out dt2)) { isValid = true; int inM = (int)dt2.Month; int inY = (int)dt2.Year; month = inM.ToString(); year = inY.ToString(); } else { isValid = false; } //Get member's meal info foreach (UsersModel u in usList) { List <SelfMealsModel> smList = new List <SelfMealsModel>(); List <GuestMealsModel> gmList = new List <GuestMealsModel>(); SelfMealsModel smm = new SelfMealsModel(); GuestMealsModel gmm = new GuestMealsModel(); smm.memberId = u.id; gmm.memberId = u.id; foreach (SelfMealsModel sm in smm.getAllMealByMemberId()) { smList.Add(sm); } foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberId()) { gmList.Add(gm); } //List by month and year List <SelfMealsModel> smlistByMonth = new List <SelfMealsModel>(); List <GuestMealsModel> gmlistByMonth = new List <GuestMealsModel>(); //List by month if (isValid) { showing = getMonth(month) + ", " + year; //Get self list by month foreach (SelfMealsModel item in smList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { smlistByMonth.Add(item); } } //Get guest list by month foreach (GuestMealsModel item in gmList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { gmlistByMonth.Add(item); } } } else { //Get list by current month showing = "Current Month"; month = getCurrentMonth(); year = getCurrentYear(); foreach (SelfMealsModel item in smList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { smlistByMonth.Add(item); } } //Get guest list by month foreach (GuestMealsModel item in gmList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { gmlistByMonth.Add(item); } } } //Get totals int totalSelf = 0; int totalGuest = 0; foreach (SelfMealsModel s in smlistByMonth) { if (s.breakfast == "1") { totalSelf++; } if (s.lunch == "1") { totalSelf++; } if (s.dinner == "1") { totalSelf++; } } //Calculate guest meals foreach (GuestMealsModel g in gmlistByMonth) { if (g.breakfast == "1") { totalGuest++; } if (g.lunch == "1") { totalGuest++; } if (g.dinner == "1") { totalGuest++; } } //Process subtotal details int subTotalMeals = totalSelf + totalGuest; int subTotalCost = int.Parse(pm.mealrate) * subTotalMeals; details = details + "<tr>" + "<td>" + u.fullname + "</td>" + "<td>" + subTotalMeals + "</td>" + "<td>" + subTotalCost + " Tk</td>" + "</tr>"; ViewBag.Details = details; //Process total cost info totalMeals = totalMeals + subTotalMeals; totalMealCost = totalMealCost + subTotalCost; serviceCharge = serviceCharge + int.Parse(pm.servicecharge); } //Process info totalCost = totalMealCost + serviceCharge; costInfo = costInfo + "<h3 class='text-danger'>Total Meal: <span class='text-success'>" + totalMeals + "</span></h3>" + "<h3 class='text-danger'>Meal Rate: <span class='text-success'>" + pm.mealrate + " Tk</span></h3>" + "<h3 class='text-danger'>Total Meal Cost: <span class='text-success'>" + totalMealCost + " Tk</span></h3>" + "<h3 class='text-danger'>Service Charge: <span class='text-success'>" + serviceCharge + " Tk</span></h3><hr />" + "<h3 class='text-danger'>Total Cost: <span class='text-success'>" + totalCost + " Tk</span></h3>"; ViewBag.CostInfo = costInfo; ViewBag.Showing = showing; } ViewBag.ReportResponse = response; }
private void processMealData() { //Get all member string response = ""; UsersModel usm = new UsersModel(); List <UsersModel> usList = new List <UsersModel>(); foreach (UsersModel user in usm.getAllUsers()) { usList.Add(user); } if (usm.response == "500") { response = "e"; } else { response = "s"; int breakfastT = 0; int lunchT = 0; int dinnerT = 0; int breakfastM = 0; int lunchM = 0; int dinnerM = 0; int breakfastG = 0; int lunchG = 0; int dinnerG = 0; string membersB = ""; string membersL = ""; string membersD = ""; foreach (UsersModel u in usList) { //Collect daily meals SelfMealsModel smm = new SelfMealsModel(); GuestMealsModel gmm = new GuestMealsModel(); smm.memberId = u.id; gmm.memberId = u.id; smm.date = getDate(); gmm.date = getDate(); //List all meals by member List <SelfMealsModel> smList = new List <SelfMealsModel>(); List <GuestMealsModel> gmList = new List <GuestMealsModel>(); foreach (SelfMealsModel sm in smm.getAllMealByMemberIdAndDate()) { smList.Add(sm); } foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberIdAndDate()) { gmList.Add(gm); } //Get all self meals int sb = 0; int sl = 0; int sd = 0; foreach (SelfMealsModel s in smList) { if (s.breakfast == "1") { sb++; } if (s.lunch == "1") { sl++; } if (s.dinner == "1") { sd++; } } if (sb > 0) { membersB = membersB + "<btn id='b_" + u.id + "' class='btn btn-danger' value='" + Url.Action("cancelBreakfast", new { m = u.id }) + "' name='" + u.fullname + "' onclick='confirmRemovingB(" + u.id + ")'>" + u.fullname + "</btn> "; } if (sl > 0) { membersL = membersL + "<btn id='l_" + u.id + "' class='btn btn-danger' value='" + Url.Action("cancelLunch", new { m = u.id }) + "' name='" + u.fullname + "' onclick='confirmRemovingL(" + u.id + ")'>" + u.fullname + "</btn> "; } if (sd > 0) { membersD = membersD + "<btn id='d_" + u.id + "' class='btn btn-danger' value='" + Url.Action("cancelDinner", new { m = u.id }) + "' name='" + u.fullname + "' onclick='confirmRemovingD(" + u.id + ")'>" + u.fullname + "</btn> "; } breakfastM = breakfastM + sb; lunchM = lunchM + sl; dinnerM = dinnerM + sd; //Get all guest meals int gb = 0; int gl = 0; int gd = 0; foreach (GuestMealsModel g in gmList) { if (g.breakfast == "1") { gb++; } if (g.lunch == "1") { gl++; } if (g.dinner == "1") { gd++; } } breakfastG = breakfastG + gb; lunchG = lunchG + gl; dinnerG = dinnerG + gd; } breakfastT = breakfastM + breakfastG; lunchT = lunchM + lunchG; dinnerT = dinnerM + dinnerG; //Process all data ViewBag.Bt = breakfastT; ViewBag.Lt = lunchT; ViewBag.Dt = dinnerT; ViewBag.Bm = breakfastM; ViewBag.Lm = lunchM; ViewBag.Dm = dinnerM; ViewBag.Bg = breakfastG; ViewBag.Lg = lunchG; ViewBag.Dg = dinnerG; ViewBag.mB = membersB; ViewBag.mL = membersL; ViewBag.mD = membersD; } ViewBag.HomeResponse = response; }
private void processReport(string month, string year) { //Get all meals string response = ""; List <SelfMealsModel> smList = new List <SelfMealsModel>(); List <GuestMealsModel> gmList = new List <GuestMealsModel>(); SelfMealsModel smm = new SelfMealsModel(); GuestMealsModel gmm = new GuestMealsModel(); UserSessionModel usm = (UserSessionModel)Session["user"]; smm.memberId = usm.userid; gmm.memberId = usm.userid; foreach (SelfMealsModel sm in smm.getAllMealByMemberId()) { smList.Add(sm); } foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberId()) { gmList.Add(gm); } //Get preferences PreferencesModel pm = new PreferencesModel(); pm.getPrefrences(); if (smm.response == "500" || gmm.response == "500" || pm.response == "500") { response = "e"; } else { response = "s"; string showing = ""; string mealInfo = ""; string costInfo = ""; string details = ""; bool isValid = false; List <SelfMealsModel> smlistByMonth = new List <SelfMealsModel>(); List <GuestMealsModel> gmlistByMonth = new List <GuestMealsModel>(); //Check for valid date input string date = year + "-" + month + "-01"; DateTime dt2; if (DateTime.TryParse(date, out dt2)) { isValid = true; int inM = (int)dt2.Month; int inY = (int)dt2.Year; month = inM.ToString(); year = inY.ToString(); } else { isValid = false; } //List by month if (isValid) { showing = getMonth(month) + ", " + year; //Get self list by month foreach (SelfMealsModel item in smList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { smlistByMonth.Add(item); } } //Get guest list by month foreach (GuestMealsModel item in gmList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { gmlistByMonth.Add(item); } } } else { //Get list by current month showing = "Current Month"; month = getCurrentMonth(); year = getCurrentYear(); foreach (SelfMealsModel item in smList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { smlistByMonth.Add(item); } } //Get guest list by month foreach (GuestMealsModel item in gmList) { DateTime dt = DateTime.ParseExact(item.date, "dd/MM/yyyy", null); int m = (int)dt.Month; int y = (int)dt.Year; string dbYear = y.ToString(); string dbMonth = m.ToString(); if (dbMonth == month && dbYear == year) { gmlistByMonth.Add(item); } } } //Get totals int totalSelf = 0; int totalGuest = 0; foreach (SelfMealsModel s in smlistByMonth) { int countB = 0; int countL = 0; int countD = 0; int subTotal = 0; int selfB = 0; int selfL = 0; int selfD = 0; if (s.breakfast == "1") { selfB++; } if (s.lunch == "1") { selfL++; } if (s.dinner == "1") { selfD++; } totalSelf = totalSelf + selfB + selfL + selfD; subTotal = subTotal + selfB + selfL + selfD; countB = countB + selfB; countL = countL + selfL; countD = countD + selfD; //Calculate guest meals string d = s.date; foreach (GuestMealsModel g in gmlistByMonth) { int guestB = 0; int guestL = 0; int guestD = 0; if (g.date == d) { if (g.breakfast == "1") { guestB++; } if (g.lunch == "1") { guestL++; } if (g.dinner == "1") { guestD++; } totalGuest = totalGuest + guestB + guestL + guestD; subTotal = subTotal + guestB + guestL + guestD; countB = countB + guestB; countL = countL + guestL; countD = countD + guestD; } } details = details + "<tr>" + "<td>" + d + "</td>" + "<td>" + countB + "</td>" + "<td>" + countL + "</td>" + "<td>" + countD + "</td>" + "<td>" + subTotal + "</td>" + "</tr>"; } //Generate results int totalMeal = totalSelf + totalGuest; mealInfo = "<p><b>Total Meal: <span class='text-success'>" + totalMeal + "</span></b></p>" + "<p><b>Self: <span class='text-success'>" + totalSelf + "</span></b></p>" + "<p><b>Guest: <span class='text-success'>" + totalGuest + "</span></b></p>"; int mealRate = int.Parse(pm.mealrate.Trim()); int serviceCharge = int.Parse(pm.servicecharge.Trim()); int totalMealCost = totalMeal * mealRate; int totalCost = totalMealCost + serviceCharge; costInfo = "<p><b>Meal rate: <span class='text-success'>" + pm.mealrate + " Tk/person</span></b></p>" + "<p><b>Meal cost: <span class='text-success'>" + totalMealCost + " Tk</span></b></p>" + "<p><b>Service charge: <span class='text-success'>" + pm.servicecharge + " Tk/person</span></b></p>" + "<p><b>Total cost: <span class='text-success'>" + totalCost + " Tk</span></b></p>"; ViewBag.Showing = showing; ViewBag.CostInfo = costInfo; ViewBag.Info = mealInfo; ViewBag.Details = details; } ViewBag.ReportResponse = response; }
private void processGuestDetails() { string response = ""; string msg = ""; GuestMealsModel gmm = new GuestMealsModel(); List <GuestMealsModel> gmList = new List <GuestMealsModel>(); //Get all guest meals UserSessionModel usm = (UserSessionModel)Session["user"]; gmm.memberId = usm.userid; gmm.date = getDate(); foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberIdAndDate()) { gmList.Add(gm); } //Process result if (gmm.response == "500") { response = "e"; msg = "<h3>Something went wrong! Try again...</h3>"; } else { response = "s"; msg = msg + "<table class='table table-bordered'>" + "<tr>" + "<td><b>#</b></td>" + "<td><b>Breakfast</b></td>" + "<td><b>Lunch</b></td>" + "<td><b>Dinner</b></td>" + "<td><b>Options</b></td>" + "</tr>"; int count = 1; foreach (GuestMealsModel gm in gmList) { msg = msg + "<tr><td>" + count + "</td>"; if (gm.breakfast == "1") { msg = msg + "<td><p class='text-success'>Y</p></td>"; } else { msg = msg + "<td><p class='text-danger'>N</p></td>"; } if (gm.lunch == "1") { msg = msg + "<td><p class='text-success'>Y</p></td>"; } else { msg = msg + "<td><p class='text-danger'>N</p></td>"; } if (gm.dinner == "1") { msg = msg + "<td><p class='text-success'>Y</p></td>"; } else { msg = msg + "<td><p class='text-danger'>N</p></td>"; } msg = msg + "<td>" + "<a class='btn btn-success' data-ajax='true' data-ajax-success='getMealData' href='" + Url.Action("ModifyGuestMeal", new { id = gm.id }) + "'>Modify</a>" + " <a class='btn btn-danger' data-ajax='true' data-ajax-success='serverResponse' href='" + Url.Action("DeleteGuestMeal", new { id = gm.id }) + "'>Remove</a>" + "</td></tr>"; count++; } msg = msg + "</table>"; } ViewBag.GuestDetailsData = msg; ViewBag.GuestDetailsResponse = response; }
public ActionResult AddGuestMeal(string b, string l, string d) { if (b == null && l == null && d == null) { return(Json(new { msgtype = "e", msg = "Please select at least one item..." })); } else { GuestMealsModel gmm = new GuestMealsModel(); //Breakfst if (b != "1") { gmm.breakfast = "0"; } else { gmm.breakfast = "1"; } //Lunch if (l != "1") { gmm.lunch = "0"; } else { gmm.lunch = "1"; } //Dinner if (d != "1") { gmm.dinner = "0"; } else { gmm.dinner = "1"; } //Other info UserSessionModel usm = (UserSessionModel)Session["user"]; gmm.memberId = usm.userid; gmm.date = getDate(); //Add meal gmm.addGuestMeal(); if (gmm.response == "500") { return(Json(new { msgtype = "e", msg = "Something went wrong! Try again..." })); } else { return(Json(new { msgtype = "s", msg = "Added successfully!" })); } } }
public ActionResult ModifyGuestMeal(string mealId, string b, string l, string d) { if (b == null && l == null && d == null) { return(Json(new { msgtype = "e", msg = "Please select at least one item..." })); } else { GuestMealsModel gmm = new GuestMealsModel(); //Breakfst if (b != "1") { gmm.breakfast = "0"; } else { gmm.breakfast = "1"; } //Lunch if (l != "1") { gmm.lunch = "0"; } else { gmm.lunch = "1"; } //Dinner if (d != "1") { gmm.dinner = "0"; } else { gmm.dinner = "1"; } //Other info gmm.id = mealId; //Update meal gmm.updateMeal(); if (gmm.response == "500") { return(Json(new { msgtype = "e", msg = "Something went wrong! Try again..." })); } else { return(Json(new { msgtype = "s", msg = "Added successfully!" })); } } }
public ActionResult ModifyGuestMeal(int id) { if (Session["user"] != null) { UserSessionModel session = (UserSessionModel)Session["user"]; if (session.acctype == "u" || session.acctype == "m") { GuestMealsModel gmm = new GuestMealsModel(); gmm.id = id.ToString(); gmm.getMealData(); if (gmm.response == "500") { return(Json(new { msgtype = "e", msg = "Something went wrong! Try again..." }, JsonRequestBehavior.AllowGet)); } else { string r = ""; if (gmm.breakfast == "1") { r = r + "<input type='checkbox' name='b' value='1' checked> Breakfast<br>"; } else { r = r + "<input type='checkbox' name='b' value='1'> Breakfast<br>"; } if (gmm.lunch == "1") { r = r + "<input type='checkbox' name='l' value='1' checked> Lunch<br>"; } else { r = r + "<input type='checkbox' name='l' value='1'> Lunch<br>"; } if (gmm.dinner == "1") { r = r + "<input type='checkbox' name='d' value='1' checked> Dinner<br>"; } else { r = r + "<input type='checkbox' name='d' value='1'> Dinner<br>"; } r = r + "<input type='hidden' name='mealId' value='" + id + "' />"; r = r + "<div class='text-center'>" + "<input type='submit' id='submitInfo' value='Update' class='btn btn-success' /></div>"; return(Json(new { msgtype = "s", msg = r }, JsonRequestBehavior.AllowGet)); } } else { return(RedirectToAction("UserLogin", "User")); } } else { return(RedirectToAction("UserLogin", "User")); } }