コード例 #1
0
 public ActionResult Index(Cleint cl)
 {
     if (ModelState.IsValid)
     {
         return(View(db.Cleint.Where(x => x.AccountID == cl.AccountID).ToList()));
     }
     return(RedirectToAction("Index"));
 }
コード例 #2
0
        public ActionResult DeleteConfirmed(string id)
        {
            Cleint cleint = db.Cleint.Find(id);

            db.Cleint.Remove(cleint);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "ClientID,ClientName,Address,PhoneNo,SetupDate,OldServiceDate,ServiceDate,NextServiceDate,ProductModel")] Cleint cleint)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cleint).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(cleint));
 }
コード例 #4
0
        public ActionResult Create([Bind(Include = "ClientID,ClientName,Address,PhoneNo,SetupDate,OldServiceDate,ServiceDate,NextServiceDate,ProductModel")] Cleint cleint)
        {
            if (ModelState.IsValid)
            {
                db.Cleints.Add(cleint);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cleint));
        }
コード例 #5
0
        // GET: Cleints/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Cleint cleint = db.Cleint.Find(id);

            if (cleint == null)
            {
                return(HttpNotFound());
            }
            return(View(cleint));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "AccountID,AccountName")] Cleint cleint)
        {
            bool IsIdExist = db.Cleint.Any(x => x.AccountID == cleint.AccountID);

            if (IsIdExist == true)
            {
                ModelState.AddModelError("AccountID", "ID already exists");
            }

            if (ModelState.IsValid)
            {
                db.Cleint.Add(cleint);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cleint));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "ProductID,Description,Size,Session,ValueToID,Incoming,Price")] Product product)
        {
            bool IsIdExist = db.Product.Any(x => x.ProductID == product.ProductID);

            if (IsIdExist == true)
            {
                ModelState.AddModelError("ProductID", "ID already exists");
            }


            if (ModelState.IsValid)
            {
                Cleint c = new Cleint();
                c.AccountName = product.Size + product.Description;
                c.AccountID   = product.ValueToID + product.ProductID;
                db.Cleint.Add(c);
                db.Product.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }