public ActionResult Create([Bind(Include = "ID,Name,Address,City,Pincode,ContactNumber,EmailId")] Customer_Master customer_Master) { try { if (ModelState.IsValid) { customer_Master.Name = customer_Master.Name.Trim(); customer_Master.EmailId = customer_Master.EmailId.Trim(); customer_Master.Address = customer_Master.Address.Trim(); customer_Master.City = customer_Master.City.Trim(); // to trim end spaces db.Customer_Master.Add(customer_Master); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer_Master)); } catch (Exception e) { Console.WriteLine(e.InnerException); return(View("Error")); // throw; } }
public ActionResult DeleteConfirmed(int id) { try { Customer_Master customer_Master = db.Customer_Master.Find(id); db.Customer_Master.Remove(customer_Master); db.SaveChanges(); return(RedirectToAction("Index")); } catch (System.Data.Entity.Infrastructure.DbUpdateException ue) { Console.WriteLine(ue.InnerException); // return View("~/Views/Shared/Error.cshtml"); return(View("ActiveRecordException")); // throw; } catch (Exception e) { Console.WriteLine(e.InnerException); // ViewBag.Message = "Foreign key violation"; return(View("Error")); // throw; } }
// GET: Orders/Details/5 public ActionResult Invoice(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } try { var resultSet = from o in db.Order_line_item join p in db.Product_Master on o.ProductID equals p.Id where o.OrderId == id select new InvoiceOrder { Product_name = p.Product_name, Rate = p.Rate, GST_rate = p.GST_rate, Quantity = o.Quantity, Price = o.Price, GST = o.GST, Total_price = o.Total_price }; ////use Ienumerable Order orderrow = db.Orders.Single(x => x.ID == id); if (orderrow == null) { return(HttpNotFound()); } ViewBag.OrderDate = orderrow.Order_date; ViewBag.DeliveryDate = orderrow.Scheduled_del_date; ViewBag.billDate = DateTime.Now; ViewBag.TotalGST = orderrow.Total_GST; ViewBag.OrderTotal = orderrow.Total_order_price; Customer_Master customer_MasterRow = db.Customer_Master.Single(z => z.ID == orderrow.CustomerId); if (customer_MasterRow == null) { return(HttpNotFound()); } ViewBag.CustomerName = customer_MasterRow.Name; ViewBag.CustomerAddress = customer_MasterRow.City + "," + customer_MasterRow.Address + "," + customer_MasterRow.Pincode; if (resultSet == null) { return(HttpNotFound()); } return(View(resultSet.ToList())); } catch (Exception e) { Console.WriteLine(e.InnerException); return(View("Error")); // throw; } }
// GET: Customer_Master/Edit/5 public ActionResult Edit(int?id) { try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Customer_Master customer_Master = db.Customer_Master.Find(id); if (customer_Master == null) { return(HttpNotFound()); } return(View(customer_Master)); } catch (Exception e) { Console.WriteLine(e.InnerException); return(View("Error")); } }
public ActionResult Edit([Bind(Include = "ID,Name,Address,City,Pincode,ContactNumber,EmailId")] Customer_Master customer_Master) { try { if (ModelState.IsValid) { db.Entry(customer_Master).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(customer_Master)); //} } catch (Exception e) { Console.WriteLine(e.InnerException); return(View("Error")); // throw; } }