コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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());
            }
        }
コード例 #3
0
        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());
            }
        }
コード例 #4
0
        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());
            }
        }
コード例 #5
0
        /* 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;
            }
        }
コード例 #6
0
 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;
     }
 }
コード例 #7
0
        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());
            }
        }
コード例 #8
0
        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());
            }
        }
コード例 #9
0
        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());
            }
        }
コード例 #10
0
        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;
            }
        }