public ActionResult DeleteConfirmed(int id) { tblAdded_service tblAdded_service = db.tblAdded_service.Find(id); db.tblAdded_service.Remove(tblAdded_service); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Add_service_for_client([Bind(Include = "ID,Client_id,Service_id,Quantity,Payable_amount,Added_date")] tblAdded_service tblAdded_service) { if (ModelState.IsValid) { db.tblAdded_service.Add(tblAdded_service); db.SaveChanges(); } return(View()); }
public ActionResult Edit([Bind(Include = "ID,Client_id,Service_id,Quantity,Payable_amount,Added_date")] tblAdded_service tblAdded_service) { if (ModelState.IsValid) { db.Entry(tblAdded_service).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Client_id = new SelectList(db.tblClient_profile, "ID", "Company_name", tblAdded_service.Client_id); ViewBag.Service_id = new SelectList(db.tblCompany_services, "ID", "C_service_name", tblAdded_service.Service_id); return(View(tblAdded_service)); }
// GET: tblAdded_service/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblAdded_service tblAdded_service = db.tblAdded_service.Find(id); if (tblAdded_service == null) { return(HttpNotFound()); } return(View(tblAdded_service)); }
public void Invoice_for_price(tblAdded_service tblAdded_service) { invoice.Invoice_no = r.Next(0, 1000000); invoice.Payment_status = 0; invoice.Payment_type = 2; var price = db.tblCompany_services.Where(s => s.ID == tblAdded_service.Service_id).Select(p => new { service_price = p.Price }).Single(); invoice.Due = (tblAdded_service.Quantity * price.service_price); invoice.Added_service_id = tblAdded_service.ID; invoice.Date = DateTime.Now; db.tblInvoices.Add(invoice); }
// GET: tblAdded_service/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } tblAdded_service tblAdded_service = db.tblAdded_service.Find(id); if (tblAdded_service == null) { return(HttpNotFound()); } ViewBag.Client_id = new SelectList(db.tblClient_profile, "ID", "Company_name", tblAdded_service.Client_id); ViewBag.Service_id = new SelectList(db.tblCompany_services, "ID", "C_service_name", tblAdded_service.Service_id); return(View(tblAdded_service)); }
public ActionResult Add_service_for_client([Bind(Include = "ID,Client_id,Service_id,Quantity,Payable_amount,Added_date")] tblAdded_service tblAdded_service, int paidAmount = 0) { if (ModelState.IsValid) { invoice.Invoice_no = r.Next(0, 1000000); invoice.Payment_status = 0; invoice.Payment_type = 1; invoice.Due = tblAdded_service.Payable_amount - paidAmount; db.tblAdded_service.Add(tblAdded_service); db.SaveChanges(); invoice.Added_service_id = tblAdded_service.ID; invoice.Date = DateTime.Now; db.tblInvoices.Add(invoice); db.SaveChanges(); Invoice_for_price(tblAdded_service); Client_Transaction.Client_id = tblAdded_service.Client_id; Client_Transaction.Paid_amount = paidAmount; Client_Transaction.Paid_date = tblAdded_service.Added_date; var category = db.tblCompany_services.Where(c => c.ID == tblAdded_service.Service_id).FirstOrDefault(); Client_Transaction.Payment_type = category.Category; var Invoice = db.tblInvoices.Where(i => i.Added_service_id == tblAdded_service.ID).Select(p => new { invoiceId = p.ID }).Single(); Client_Transaction.Invoice_id = Invoice.invoiceId; db.tblClient_transaction.Add(Client_Transaction); db.SaveChanges(); RedirectToAction("Index", "Added_service"); } ViewBag.Service_id = new SelectList(db.tblCompany_services, "ID", "C_service_name"); return(RedirectToAction("Index", "Added_service")); }