Exemple #1
0
        public ActionResult Create(FormCollection collection)
        {
            if (SUserRole() != "Customer" && SUserRole() != null)
            {
                ViewBag.displayMenu = "Yes";
            }
            try
            {
                // TODO: Add insert logic here
                Staff newStaff = new Models.Staff();
                newStaff.Address   = Request.Form["Address"];
                newStaff.AspId     = Request.Form["AspId"];
                newStaff.Contact   = Request.Form["Contact"];
                newStaff.Email     = Request.Form["Email"];
                newStaff.Position  = Request.Form["ddlPosition"];
                newStaff.StaffName = Request.Form["StaffName"];
                newStaff.UserName  = Request.Form["UserName"];
                db.Staffs.Add(newStaff);
                db.SaveChanges();

                return(RedirectToAction("Index", "Home"));
            }
            catch (Exception e)
            {
                string error  = e.InnerException.Message;
                string error2 = e.InnerException.InnerException.Message;
                return(View());
            }
        }
Exemple #2
0
        public ActionResult Create(FormCollection collection)
        {
            if (SUserRole() != "Customer" && SUserRole() != null)
            {
                ViewBag.displayMenu = "Yes";
            }
            try
            {
                // TODO: Add insert logic here
                Customer cust = new Models.Customer();
                cust.Address = Request.Form["Address"];
                cust.AspId = Request.Form["AspId"];
                cust.BankDeatils = Request.Form["BankDeatils"];
                cust.Contact = Request.Form["Contact"];
                cust.CustName = Request.Form["CustName"];
                cust.Email = Request.Form["Email"];
                cust.UserName = Request.Form["UserName"];
                db.Customers.Add(cust);
                db.SaveChanges();

                return RedirectToAction("Index", "Home");
        }
            catch(Exception e)
            {
                string error = e.InnerException.Message;
                string error2 = e.InnerException.InnerException.Message;
                return View();
    }
}
        public ActionResult Create([Bind(Include = "SalaryNum,Amount,Benefits,Deductions,StaffNum,Description")] Salary salary)
        {
            if (SUserRole() != "Customer" && SUserRole() != null)
            {
                ViewBag.displayMenu = "Yes";
            }
            if (ModelState.IsValid)
            {
                db.Salaries.Add(salary);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StaffNum = new SelectList(db.Staffs, "StaffNum", "StaffName", salary.StaffNum);
            return(View(salary));
        }
        public ActionResult Create([Bind(Include = "ProdNum,ProdName,ProdDesc,Price,QtyOnHand,SuppNum")] Product product)
        {
            if (SUserRole() != "Customer" && SUserRole() != null)
            {
                ViewBag.displayMenu = "Yes";
            }
            ViewBag.displayMenu = "yes";
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SuppNum = new SelectList(db.Suppliers, "SuppNum", "SuppName", product.SuppNum);
            return(View(product));
        }
 public ActionResult Create([Bind(Include = "SuppName, Address, Contact, Email")] Supplier supplier)
 {
     if (SUserRole() != "Customer" && SUserRole() != null)
     {
         ViewBag.displayMenu = "Yes";
     }
     try
     {
         if (ModelState.IsValid)
         {
             db.Suppliers.Add(supplier);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (DataException ex)
     {
         ModelState.AddModelError("", "Unable To Save Changes, Try Again");
         string emessage  = ex.InnerException.Message.ToString();
         string eemessage = ex.InnerException.InnerException.Message.ToString();
     }
     return(View(supplier));
 }