示例#1
0
        public ActionResult Create(SuplierTable suplierTable)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            int userid = Convert.ToInt32(Convert.ToString(Session["UserID"]));

            suplierTable.UserID = userid;
            if (ModelState.IsValid)
            {
                var find = db.SuplierTables.Where(s => s.SuplierName == suplierTable.SuplierName && s.ContactNo == suplierTable.ContactNo).FirstOrDefault();
                if (find == null)
                {
                    db.SuplierTables.Add(suplierTable);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Massege = "Suplier Alredy Registerd";
                }
            }

            return(View(suplierTable));
        }
示例#2
0
        // GET: SuplierTables/Details/5
        public ActionResult Details(int?id)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SuplierTable suplierTable = db.SuplierTables.Find(id);

            if (suplierTable == null)
            {
                return(HttpNotFound());
            }
            return(View(suplierTable));
        }
示例#3
0
        public ActionResult Edit(SuplierTable suplierTable)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            int userid = Convert.ToInt32(Convert.ToString(Session["UserID"]));

            suplierTable.UserID = userid;
            if (ModelState.IsValid)
            {
                db.Entry(suplierTable).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.UserID = new SelectList(db.UserTables, "UserID", "UserName", suplierTable.UserID);
            return(View(suplierTable));
        }
示例#4
0
        // GET: SuplierTables/Edit/5
        public ActionResult Edit(int?id)
        {
            if (string.IsNullOrEmpty(Convert.ToString(Session["UserID"])))
            {
                return(RedirectToAction("Login", "Home"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SuplierTable suplierTable = db.SuplierTables.Find(id);

            if (suplierTable == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserID = new SelectList(db.UserTables, "UserID", "UserName", suplierTable.UserID);
            return(View(suplierTable));
        }