public ActionResult Edit(OrderViewModel s, int id) { try { DB3Entities2 db = new DB3Entities2(); var cs = db.Orders.Where(x => x.order_id == id).First(); List <Order> c = db.Orders.ToList(); s.Medicine_Name = cs.Medicine_Name; // s.Quantity = cs.Quantity; // s.Price = cs.Price; // var g = db.Medicines.Where() // s.medicine_id = cs.medicine_id; db.SaveChanges(); // TODO: Add update logic here return(RedirectToAction("Index", new { id = cs.medicine_id })); } catch { return(View()); } }
public ActionResult Edit(CustomerViewModel s, int id) { try { DB3Entities2 db = new DB3Entities2(); var cs = db.Customers.Where(x => x.user_id == id).First(); List <Customer> c = db.Customers.ToList(); cs.Name = s.Name; cs.Address = s.Address; cs.Phone = s.Phone; cs.status = s.status; //cs.status = Convert.ToInt32('Pending'); cs.city = s.city; db.SaveChanges(); // TODO: Add update logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(OrderViewModel s) { try { DB3Entities2 db = new DB3Entities2(); // Order o = new Order(); var order = new Order(); order.Medicine_Name = s.Medicine_Name; order.Quantity = s.Quantity; order.Price = s.Price; var c = db.Medicines.Where(x => x.Medicine_Name == s.Medicine_Name).First(); order.medicine_id = c.Medicine_id; //var d = db.Medicines.Where(x => x.Medicine_id == s.medicine_id).First(); db.Orders.Add(order); db.SaveChanges(); // TODO: Add insert logic here return(RedirectToAction("Index")); } catch (Exception ex) { return(View()); } }
public ActionResult MedicineAdd(MedicineModel obj) { try { // TODO: Add insert logic here DB3Entities2 entity = new DB3Entities2(); var medicine = new Medicine(); medicine.Medicine_Name = obj.name; medicine.Mfg_Date = obj.mfg_date; medicine.Exp_Date = obj.exp_date; medicine.Type = obj.type; medicine.Batch = obj.batch; medicine.Price = obj.price; var c = entity.Companies.Where(x => x.C_Name == obj.company_Name).First(); medicine.CompanyID = c.Company_id; entity.Medicines.Add(medicine); entity.SaveChanges(); return(RedirectToAction("MedicineList")); } catch { return(View()); } }
/* public ActionResult CompanyEdit(int id, CompanyModel obj) * { * try * { * // TODO: Add update logic here * DB3Entities1 entity = new DB3Entities1(); * var company = entity.Companies.Where(x => x.Company_id == id).First(); * // Company c = new Company(); * company.C_Name = obj.Name; * company.Address = obj.Address; * company.Mobile_Number = obj.Contact; * //e.Companies.Add(c); * entity.SaveChanges(); * * ViewBag.message = "Data is Successfully edited"; * return RedirectToAction("CompanyDetails", new { id = company.Company_id }); * } * catch(Exception ex) * { * throw ex; * } * }*/ // GET: Company/Delete/5 /* public ActionResult CompanyDelete(int id) * { * DB3Entities1 entity = new DB3Entities1(); * var c = entity.Companies.Where(x => x.Company_id == id).First(); * CompanyModel cm = new CompanyModel(); * cm.Name = c.C_Name; * cm.Address = c.Address; * cm.Contact = c.Mobile_Number; * return View(cm); * }*/ // POST: Company/Delete/5 //[HttpPost] public ActionResult CompanyDelete(int id, FormCollection collection) { try { // TODO: Add delete logic here DB3Entities2 entity = new DB3Entities2(); var c = entity.Companies.Where(x => x.Company_id == id).First(); entity.Companies.Remove(c); entity.SaveChanges(); return(RedirectToAction("CompanyList")); } catch (Exception ex) { throw ex; } }
// GET: Customer/Edit/5 public ActionResult Edit(int id) { DB3Entities2 db = new DB3Entities2(); var s = db.Customers.Where(x => x.user_id == id).First(); //List<Customer> c = db.Customers.ToList(); CustomerViewModel cs = new CustomerViewModel(); cs.Name = s.Name; cs.Address = s.Address; cs.Phone = s.Phone; cs.status = s.status; //cs.status = Convert.ToInt32('Pending'); cs.city = s.city; return(View(cs)); }
public ActionResult MedicineDelete(int id, MedicineModel m) { try { // TODO: Add delete logic here DB3Entities2 entity = new DB3Entities2(); // Medicine m = entity.Medicines.Where(x => x.Medicine_id == id).First(); //entity.prDelMedicine(id); entity.SaveChanges(); return(RedirectToAction("MedicineList")); } catch (Exception ex) { throw ex; } }
// GET: Customer/Delete/5 public ActionResult Delete(int id) { DB3Entities2 db = new DB3Entities2(); var cs = db.Customers.Where(x => x.user_id == id).First(); CustomerViewModel s = new CustomerViewModel(); s.Name = cs.Name; s.Address = cs.Address; s.Phone = cs.Phone; // c.status = Convert.ToString(s.status); s.status = cs.status; s.city = cs.city; return(View(s)); }
// GET: Medicine/Edit/5 public ActionResult MedicineEdit(int id) { DB3Entities2 entity = new DB3Entities2(); var m = entity.Medicines.Where(x => x.Medicine_id == id).First(); MedicineModel mm = new MedicineModel(); mm.name = m.Medicine_Name; mm.mfg_date = m.Mfg_Date; mm.exp_date = Convert.ToDateTime(m.Exp_Date); mm.batch = m.Batch; mm.type = m.Type; mm.price = Convert.ToInt32(m.Price); var c = entity.Companies.Where(x => x.Company_id == m.CompanyID).First(); mm.company_Name = c.C_Name; return(View(mm)); }
// GET: Order/Edit/5 public ActionResult Edit(int id) { DB3Entities2 db = new DB3Entities2(); var s = db.Orders.Where(x => x.order_id == id).First(); //List<Order> c = db.Orders.ToList(); OrderViewModel cs = new OrderViewModel(); cs.Medicine_Name = s.Medicine_Name; // cs.Quantity = s.Quantity; // cs.Price = s.Price; var g = db.Medicines.Where(x => x.Medicine_id == s.medicine_id).First(); cs.type = g.Type; //cs.medicine_id = s.medicine_id; return(View(cs)); }
// GET: Company public ActionResult CompanyList() { DB3Entities2 e = new DB3Entities2(); List <CompanyModel> cml = new List <CompanyModel>(); List <Company> cl = e.Companies.ToList(); foreach (Company c in cl) { CompanyModel cm = new CompanyModel(); cm.id = c.Company_id; cm.Name = c.C_Name; cm.Address = c.Address; cm.Contact = c.Mobile_Number; cml.Add(cm); } return(View(cml)); }
public ActionResult Delete(CustomerViewModel s, int id) { try { // TODO: Add delete logic here DB3Entities2 db = new DB3Entities2(); //List<Customer> c = db.Customers.ToList(); var del = db.Customers.Where(x => x.user_id == id).First(); db.Customers.Remove(del); db.SaveChanges(); // TODO: Add delete logic here return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Customer/Details/5 public ActionResult Details(int id) { DB3Entities2 db = new DB3Entities2(); List <Customer> cs = db.Customers.ToList(); //userid = id; CustomerViewModel c = new CustomerViewModel(); foreach (Customer s in cs) { if (s.user_id == id) { c.Name = s.Name; c.Address = s.Address; c.Phone = s.Phone; c.status = s.status; //c.status = s.status; c.city = s.city; } } return(View(c)); }
// GET: Bill public ActionResult Index() { DB3Entities2 db = new DB3Entities2(); List <Bill> b = new List <Bill>(); List <BillViewModel> bl = new List <BillViewModel>(); BillViewModel bi = new BillViewModel(); foreach (Bill o in b) { bi.Date = o.Date; //bi.CustomerID = o.CustomerID; // Medicine c = db.Medicines.Where(x => x.Medicine_id == s.medicine_id).First(); Order c = db.Orders.Where(x => x.order_id == o.OrderID).First(); bi.OrderID = c.order_id; // bi.Price = c.Price; // bi.Quantity = c.Quantity; bl.Add(bi); } return(View(bl)); }
// GET: Customer public ActionResult Index() { DB3Entities2 db = new DB3Entities2(); List <Customer> cs = db.Customers.ToList(); List <CustomerViewModel> csv = new List <CustomerViewModel>(); //CustomerViewModel c = new CustomerViewModel(); foreach (Customer s in cs) { CustomerViewModel c = new CustomerViewModel(); c.Name = s.Name; c.Address = s.Address; c.Phone = s.Phone; c.status = s.status; c.user_id = s.user_id; //c.status = Convert.ToInt32('Pending'); c.city = s.city; csv.Add(c); } return(View(csv)); }
// GET: Medicine public ActionResult MedicineList() { DB3Entities2 entity = new DB3Entities2(); List <MedicineModel> mml = new List <MedicineModel>(); List <Medicine> ml = entity.Medicines.ToList(); foreach (Medicine m in ml) { MedicineModel mm = new MedicineModel(); mm.name = m.Medicine_Name; mm.mfg_date = m.Mfg_Date; mm.exp_date = Convert.ToDateTime(m.Exp_Date); mm.batch = m.Batch; mm.type = m.Type; // mm.weight = m.Weight; mm.price = Convert.ToInt32(m.Price); Company c = entity.Companies.Where(x => x.Company_id == m.CompanyID).First(); mm.company_Name = c.C_Name; mml.Add(mm); } return(View(mml)); }
public ActionResult Create(BillViewModel s) { try { DB3Entities2 db = new DB3Entities2(); Bill b = new Bill(); b.Date = s.Date; b.Price = s.Price; b.Quantity = s.Quantity; b.CustomerID = s.CustomerID; b.OrderID = s.OrderID; db.Bills.Add(b); db.SaveChanges(); // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(CustomerViewModel s) { try { DB3Entities2 db = new DB3Entities2(); Customer c = new Customer(); c.Name = s.Name; c.Address = s.Address; c.Phone = s.Phone; c.status = s.status; c.city = s.city; db.Customers.Add(c); db.SaveChanges(); // TODO: Add insert logic here return(RedirectToAction("Index")); } catch { return(View()); } }
// GET: Order public ActionResult Index() { // DB3Entities2 db = new DB3Entities2(); List <Order> o = db.Orders.ToList(); List <OrderViewModel> ol = new List <OrderViewModel>(); //OrderViewModel oi = new OrderViewModel(); foreach (Order s in o) { OrderViewModel oi = new OrderViewModel(); oi.order_id = s.order_id; // oi.Medicine_Name = s.Medicine_Name; // oi.Quantity = s.Quantity; // oi.Price = s.Price; Medicine c = db.Medicines.Where(x => x.Medicine_id == s.medicine_id).First(); oi.Medicine_Name = c.Medicine_Name; oi.type = c.Type; //oi.medicine_id = s.medicine_id; ol.Add(oi); } return(View(ol)); }
public ActionResult OrderReport() { DB3Entities2 db = new DB3Entities2(); List <Order> exam = new List <Order>(); exam = db.Orders.ToList(); ReportDocument rd = new ReportDocument(); rd.Load(Path.Combine(Server.MapPath("~/Report"), "CrystalReport2.rpt")); rd.SetDataSource(exam); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rd.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); stream.Seek(0, SeekOrigin.Begin); return(File(stream, "application/pdf", "OrderList.pdf")); }
public ActionResult CompanyAdd(CompanyModel obj) { try { // TODO: Add insert logic here Company company = new Company(); company.C_Name = obj.Name; company.Address = obj.Address; company.Mobile_Number = obj.Contact; DB3Entities2 e = new DB3Entities2(); e.Companies.Add(company); e.SaveChanges(); ViewBag.message = "Data is Successfully added"; //Session["CompanyId"] = company.Company_id; return(RedirectToAction("CompanyList")); } catch (Exception ex) { //ViewBag.message = "Data is not added "; throw ex; } }
public ActionResult MedicineEdit(int id, MedicineModel obj) { try { // TODO: Add update logic here DB3Entities2 entity = new DB3Entities2(); var m = entity.Medicines.Where(x => x.Medicine_id == id).First(); obj.name = m.Medicine_Name; obj.mfg_date = m.Mfg_Date; obj.exp_date = Convert.ToDateTime(m.Exp_Date); obj.batch = m.Batch; obj.type = m.Type; obj.price = Convert.ToInt32(m.Price); var c = entity.Companies.Where(x => x.Company_id == m.CompanyID).First(); obj.company_Name = c.C_Name; return(RedirectToAction("MedicineEdit", new { id = m.Medicine_id })); } catch (Exception ex) { throw ex; } }