public ActionResult delete(int id) { using (var db = new InvoiceEntities1()) { tblcustomer cust = db.tblcustomers.FirstOrDefault(x => x.idcustomer == id); db.tblcustomers.Remove(cust); db.SaveChanges(); return(RedirectToAction("Indexcust")); } }
public ActionResult deleteproduct(int id) { using (var db = new InvoiceEntities1()) { tblproduct product = db.tblproducts.FirstOrDefault(x => x.idproduct == id); db.tblproducts.Remove(product); db.SaveChanges(); return(RedirectToAction("indexproduct")); } }
public ActionResult editproduct(tblproduct obj) { using (var db = new InvoiceEntities1()) { tblproduct product = db.tblproducts.Where(x => x.idproduct == obj.idproduct).FirstOrDefault(); product.name = obj.name; product.price = obj.price; db.SaveChanges(); return(RedirectToAction("indexproduct")); } }
public ActionResult edit(tblcustomer obj) { using (var db = new InvoiceEntities1()) { tblcustomer customer = db.tblcustomers.Where(x => x.idcustomer == obj.idcustomer).FirstOrDefault(); customer.name = obj.name; customer.mobileno = obj.mobileno; customer.emailid = obj.emailid; customer.address = obj.address; db.SaveChanges(); return(RedirectToAction("Indexcust")); } }
public ActionResult addproduct(tblproduct obj) { if (ModelState.IsValid) { InvoiceEntities1 db = new InvoiceEntities1(); tblproduct product = new tblproduct(); product.name = obj.name; product.price = obj.price; product.srno = obj.srno; db.tblproducts.Add(product); db.SaveChanges(); } return(View(obj)); }
public ActionResult addcustomer(tblcustomer obj) { if (ModelState.IsValid) { int billno; InvoiceEntities1 db = new InvoiceEntities1(); tblcustomer customer = new tblcustomer(); customer.name = obj.name; customer.mobileno = obj.mobileno; customer.emailid = obj.emailid; customer.address = obj.address; customer.billno = db.tblcustomers.Count() + 1; db.tblcustomers.Add(customer); db.SaveChanges(); } return(View(obj)); }