public ActionResult DeleteConfirmed(int id) { AspNetSale aspNetSale = db.AspNetSales.Find(id); db.AspNetSales.Remove(aspNetSale); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult CashReceived(AspNetSale aspNetSale) { if (ModelState.IsValid) { db.AspNetSales.Add(aspNetSale); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.AspNetCustomers, "Id", "Name"); return(View(aspNetSale)); }
public ActionResult Edit([Bind(Include = "Id,CustomerID,Date,Particular,BillID,Quantity,Rate,Amount,Received,Discount,Remaining")] AspNetSale aspNetSale) { if (ModelState.IsValid) { db.Entry(aspNetSale).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.BillID = new SelectList(db.AspNetBills, "Id", "Truck_No", aspNetSale.BillID); ViewBag.CustomerID = new SelectList(db.AspNetCustomers, "Id", "Name", aspNetSale.CustomerID); return(View(aspNetSale)); }
// GET: AspNetSales/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AspNetSale aspNetSale = db.AspNetSales.Find(id); if (aspNetSale == null) { return(HttpNotFound()); } return(View(aspNetSale)); }
// GET: AspNetSales/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } AspNetSale aspNetSale = db.AspNetSales.Find(id); if (aspNetSale == null) { return(HttpNotFound()); } ViewBag.BillID = new SelectList(db.AspNetBills, "Id", "Truck_No", aspNetSale.BillID); ViewBag.CustomerID = new SelectList(db.AspNetCustomers, "Id", "Name", aspNetSale.CustomerID); return(View(aspNetSale)); }
public ActionResult Create([Bind(Include = "Id,Name,City,Address,Contact_No,CNIC,AccountNo,Picture")] AspNetCustomer aspNetCustomer) { if (ModelState.IsValid) { db.AspNetCustomers.Add(aspNetCustomer); db.SaveChanges(); int cutomerID = db.AspNetCustomers.Max(x => x.Id); AspNetSale aspNetSale = new AspNetSale(); aspNetSale.Particular = "Opening Balance"; aspNetSale.Date = DateTime.Now; aspNetSale.Remaining = Convert.ToInt32(Request.Form["OpeningBalance"]); aspNetSale.CustomerID = cutomerID; db.AspNetSales.Add(aspNetSale); return(RedirectToAction("Index")); } return(View(aspNetCustomer)); }
public ActionResult Creaoote([Bind(Include = "Id,Name,City,Address,Contact_No,CNIC,AccountNo,Picture,image")] Customer aspomer) { if (ModelState.IsValid) { AspNetCustomer obj = new AspNetCustomer(); obj.AccountNo = aspomer.AccountNo; obj.Address = aspomer.Address; obj.City = aspomer.City; obj.CNIC = aspomer.CNIC; obj.Contact_No = aspomer.Contact_No; obj.Name = aspomer.Name; db.AspNetCustomers.Add(obj); db.SaveChanges(); string kk = ""; if (aspomer.image != null) { MemoryStream target = new MemoryStream(); aspomer.image.InputStream.CopyTo(target); byte[] data = target.ToArray(); string ImageName = System.IO.Path.GetFileName(aspomer.image.FileName); //file2 to store path and url string physicalPath = Server.MapPath("~/Content/img/customer/" + obj.Id); if (!Directory.Exists(physicalPath)) { Directory.CreateDirectory(physicalPath); } try { obj.Imagepath = physicalPath + "\\Pic.jpg"; System.IO.File.WriteAllBytes(obj.Imagepath, data); } catch (Exception ex) { if (ex.InnerException.Message == null) { ViewBag.error = ex.Message; } else { ViewBag.error = ex.InnerException.Message; } } //aspomer.image.SaveAs(physicalPath); kk = "/Content" + obj.Imagepath.Split(new string[] { "\\Content" }, StringSplitOptions.None)[1]; } else { kk = "/Content/img/user.png"; } db.AspNetCustomers.Where(p => p.Id == obj.Id).FirstOrDefault().Imagepath = kk; db.SaveChanges(); //obj.Picture = BinaryReader.ReadBytes(dd); //byte[] image = BinaryReader.ReadBytes(108732); //db.AspNetCustomers.Add(aspNetCustomer); //db.SaveChanges(); int cutomerID = db.AspNetCustomers.Max(x => x.Id); AspNetSale aspNetSale = new AspNetSale(); aspNetSale.Particular = "Opening Balance"; aspNetSale.Date = DateTime.Now; aspNetSale.Remaining = Convert.ToInt32(Request.Form["OpeningBalance"]); aspNetSale.CustomerID = cutomerID; db.AspNetSales.Add(aspNetSale); return(RedirectToAction("Index")); } return(View(aspomer)); }