// GET: Detail public ActionResult Detail(int id) { try { // Check autherization User staffUser = Session["User"] as User; if (staffUser == null || Session["UserRole"] == null) { return RedirectToAction("Index", "Home"); } OrderBusiness orderBusiness = new OrderBusiness(); OrderViewModel orderViewModel = orderBusiness.GetOrderViewModel(id); if (orderViewModel == null) { return RedirectToAction("ManageError", "Error"); } ViewBag.TreeView = "order"; ViewBag.TaxRate = orderBusiness.GetVatRateAtTime(orderViewModel.Order.CreateTime); if (!orderViewModel.IsEnoughMaterial) { ViewBag.ShortageOfMaterial = true; } return View(orderViewModel); } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }
public ActionResult AddInputBill() { try { User staffUser = Session["User"] as User; if (staffUser == null || Session["UserRole"] == null || (int)Session["UserRole"] != 2) { return RedirectToAction("Index", "Home"); } else { try { ViewBag.TreeView = "inputBill"; ViewBag.TreeViewMenu = "addInputBill"; OrderBusiness business = new OrderBusiness(); ViewBag.TaxRate = business.GetVatRateAtTime(DateTime.Now); List<InputBill> inputBills = db.InputBills.ToList(); return View(inputBills); } catch (Exception) { return RedirectToAction("ManageError", "Error"); } } } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }
public ActionResult CheckoutWithCustomer(int customerId) { try { // Check autherization User staffUser = Session["User"] as User; if (staffUser == null || Session["UserRole"] == null || (int)Session["UserRole"] != 2) { Session["Cart"] = null; return RedirectToAction("Index", "Home"); } List<CartViewModel> inputCartList = Session["Cart"] as List<CartViewModel>; OrderBusiness orderBusiness = new OrderBusiness(); OrderViewModel order = orderBusiness.MakeOrderViewModel(inputCartList, customerId, null); if (!order.IsEnoughMaterial) { ViewBag.ShortageOfMaterial = true; } ViewBag.TaxRate = orderBusiness.GetVatRateAtTime(DateTime.Now); Session["CustomerId"] = customerId; ViewBag.TreeView = "order"; ViewBag.TreeViewMenu = "addOrder"; return View(order); } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }
public ActionResult EditInputBill(int id) { try { User staffUser = Session["User"] as User; if (staffUser == null || Session["UserRole"] == null || (int)Session["UserRole"] != 2) { return RedirectToAction("Index", "Home"); } else { try { ViewBag.TreeView = "inputBill"; OrderBusiness business = new OrderBusiness(); ViewBag.TaxRate = business.GetVatRateAtTime(DateTime.Now); InputBill inputBill = db.InputBills.SingleOrDefault(m => m.InputBillId == id); if (inputBill == null) { return RedirectToAction("InputBillIndex", "InputBill"); } else return View(inputBill); } catch (Exception) { return RedirectToAction("ManageError", "Error"); } } } catch (Exception) { return RedirectToAction("ManageError", "Error"); } }