public bool AddOrderItem(OrderModal smodel) { SqlCommand cmd = new SqlCommand("AddItem", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@name", smodel.Name); cmd.Parameters.AddWithValue("@product", smodel.Product); cmd.Parameters.AddWithValue("@price", smodel.price); cmd.Parameters.AddWithValue("@product_qty", smodel.ProductQty); cmd.Parameters.AddWithValue("@total", smodel.Total); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i >= 1) { return(true); } else { return(false); } }
public ActionResult Orders(OrderModal om) { string user = (string)Session["Email"]; Orders trans = new Orders((int)Session["ID"], user, om.Quantity, om.DateOfTransaction, om.DateOrderDue, om.ItemType, om.Description, om.ClientEmail); try { db.Orders.Add(trans); db.SaveChanges(); return(RedirectToAction("Orders", "Home")); } catch (Exception e) { Console.WriteLine(e); return(RedirectToAction("Index", "Home")); } }
public bool DeleteItem(OrderModal smodel) { SqlCommand cmd = new SqlCommand("DeleteItem", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@name", smodel.Name); con.Open(); int i = cmd.ExecuteNonQuery(); con.Close(); if (i >= 1) { return(true); } else { return(false); } }