예제 #1
0
        public ActionResult Create([Bind(Include = "supplierid,suppliername,address1,county,country,telephone,address2,postcode,webstatus,status,LastreviewedBy,Whencompliant,Reviewdate")] supplier supplier)
        {
            if (ModelState.IsValid)
            {
                db.suppliers.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplier));
        }
예제 #2
0
        //use object of type customer to get value from formview
        // the value will be bound to customer automaticlly
        // or you can use the method TryUpdateMedel to populate your model
        public void FormView1_InsertItem(supplier supplier)
        {
            using (SupplierDBModel context = new SupplierDBModel())

            {
                //Customer customer=new Customer()
                //TryUpdateModel(customer)
                if (ModelState.IsValid)
                {
                    supplier.webstatus = "Invited To Portal";
                    context.suppliers.Add(supplier);

                    context.SaveChanges();
                }
            }
        }
        // The id parameter name should match the DataKeyNames value set on the control
        public void GridView1_UpdateItem(int supplierid)
        {
            using (SupplierDBModel context = new SupplierDBModel())

            {
                PrincePortalWeb.Models.supplier item = null;
                item = context.suppliers.Find(supplierid);
                // Load the item here, e.g. item = MyDataLayer.Find(id);
                if (item == null)
                {
                    // The item wasn't found
                    ModelState.AddModelError("", String.Format("Item with id {0} was not found", supplierid));
                    return;
                }
                TryUpdateModel(item);
                if (ModelState.IsValid)
                {
                    context.SaveChanges();
                }
            }
        }