public ActionResult Create([Bind(Include = "cid,cname")] tbl_category tbl_category) { if (ModelState.IsValid) { db.tbl_category.Add(tbl_category); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tbl_category)); }
public ActionResult Create([Bind(Include = "pid,pname,pprice,pdetails,cid")] tbl_product tbl_product) { if (ModelState.IsValid) { db.tbl_product.Add(tbl_product); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.cid = new SelectList(db.tbl_category, "cid", "cname", tbl_product.cid); return(View(tbl_product)); }
public ActionResult doneorder(tbl_orders tb, string total) { tbl_orders obj = new tbl_orders(); obj.opname = tb.opname; obj.opphone = tb.opphone; obj.opaddress = tb.opaddress; obj.opsaddress = tb.opsaddress; obj.ostatus = 0; // obj.oamount = int.Parse(total); obj.oamount = total; db.tbl_orders.Add(obj); db.SaveChanges(); var moid = db.tbl_orders.Select(a => a.oid).DefaultIfEmpty(0).Max(); var pro = from prod in ok.c join od in db.tbl_product on prod.iid equals od.pid select new { PID = od.pid, PPRICE = od.pprice, PQTY = prod.iqty }; foreach (var item in pro) { tbl_order_details orderdetails = new tbl_order_details(); orderdetails.oid = moid; orderdetails.pid = item.PID; orderdetails.pprice = item.PPRICE; orderdetails.pqty = item.PQTY; orderdetails.pamount = item.PQTY * item.PPRICE; db.tbl_order_details.Add(orderdetails); db.SaveChanges(); } ok.amt = 0; ok.c.Clear(); return(RedirectToAction("Index")); }