コード例 #1
0
        public ActionResult ProcessOrder(FormCollection frc)
        {
            List <Cart> lsCart = (List <Cart>)Session[strCart];

            order Order = new order()
            {
                customerName    = frc["cusName"],
                customerPhone   = frc["cusPhone"],
                customerEmail   = frc["cusEmail"],
                customerAddress = frc["cusAddress"],
                orderDate       = DateTime.Now,
                paymentType     = "card",
                status          = "processing"
            };

            db.orders.Add(Order);
            db.SaveChanges();

            foreach (Cart cart in lsCart)
            {
                orderdetail OrderDetail = new orderdetail()
                {
                    orderID    = Order.orderID,
                    product_ID = cart.Storeproduct.product_ID,
                    quantity   = cart.Storeproduct.quantity,
                    price      = cart.Storeproduct.price
                };
                db.orderdetails.Add(OrderDetail);
                db.SaveChanges();
            }
            Session.Remove(strCart);
            return(View("OrderSuccess"));
        }
コード例 #2
0
        public ActionResult Create(storeproduct st)
        {
            try
            {
                db.storeproducts.Add(st);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #3
0
        public ActionResult Attendance(int id)
        {
            using (inventorymgtEntities dbModel = new inventorymgtEntities())
            {
                var userDetails = dbModel.users.Where(x => x.regId == id).FirstOrDefault();
                var atndDetails = dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault();

                //if (DateTime.Now.Date > atndDetails.date_)

                DateTime dt = DateTime.Parse(atndDetails.date_);
                if (DateTime.Now.Date.CompareTo(dt) > 0)
                {
                    atndDetails.status_ = "false";

                    dbModel.Entry(atndDetails).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                int cdays = (int)atndDetails.no_of_days;

                Session["username"] = userDetails.fname + " " + userDetails.lname;
                Session["userId"]   = userDetails.regId;
                Session["progress"] = (100 / 45) * cdays;
                Session["rDays"]    = 45 - cdays;

                return(View(dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault()));
            }
        }
コード例 #4
0
        public ActionResult addOrEdit(user userModel)
        {
            using (inventorymgtEntities dbModel = new inventorymgtEntities())
            {
                if (dbModel.users.Any(x => x.email == userModel.email))
                {
                    ViewBag.DuplicateMsg = "Your Email is already exist.";

                    return(View("addOrEdit", userModel));
                }

                if (userModel.gender == "Male")
                {
                    userModel.img_path = "~/image/male.png";
                }
                else if (userModel.gender == "Female")
                {
                    userModel.img_path = "~/image/female.png";
                }

                dbModel.users.Add(userModel);
                dbModel.SaveChanges();
            }

            ViewBag.SuccessMessage = "Registration Successful.";
            ModelState.Clear();
            user user = new user();

            return(View("addOrEdit", user));
        }
コード例 #5
0
 public ActionResult Create(supplier sup)
 {
     try
     {
         using (invtModel)
         {
             invtModel.suppliers.Add(sup);
             invtModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #6
0
        public ActionResult Edit(int id, schedule sc)
        {
            try
            {
                using (inventorymgtEntities db = new inventorymgtEntities())
                {
                    db.Entry(sc).State = EntityState.Modified;
                    if (sc.Image == null)
                    {
                        var scheduleContext = db.Entry(sc);
                        scheduleContext.State = EntityState.Modified;

                        var clientValues = scheduleContext.CurrentValues.Clone().ToObject();
                        scheduleContext.Reload();
                        scheduleContext.CurrentValues.SetValues(clientValues);

                        var currentValues  = scheduleContext.Entity;
                        var databaseValues = (schedule)scheduleContext.OriginalValues.ToObject();

                        scheduleContext.Entity.Image = databaseValues.Image;
                    }
                    db.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #7
0
        public ActionResult Details(user user)
        {
            try
            {
                using (inventorymgtEntities dbModel = new inventorymgtEntities())
                {
                    string filename  = user.fname.ToLower() + "_" + user.lname.ToLower();
                    string extension = Path.GetExtension(user.ImageFile.FileName);
                    filename      = filename + DateTime.Now.ToString("yymmssfff") + extension;
                    user.img_path = "~/image/" + filename;
                    filename      = Path.Combine(Server.MapPath("~/image/"), filename);
                    user.ImageFile.SaveAs(filename);

                    dbModel.Entry(user).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                return(RedirectToAction("Details", new { id = user.regId }));
            }
            catch (Exception e)
            {
                Response.Write(e.StackTrace.ToString());
                return(RedirectToAction("Details", new { id = user.regId }));
            }
        }
コード例 #8
0
        public ActionResult addOrEdit(user userModel)
        {
            using (inventorymgtEntities dbModel = new inventorymgtEntities())
            {
                if (dbModel.users.Any(x => x.email == userModel.email))
                {
                    ViewBag.DuplicateMsg = "Your Email is already exist.";

                    return(View("addOrEdit", userModel));
                }

                if (userModel.gender == "Male")
                {
                    userModel.img_path = "~/image/male.png";
                }
                else if (userModel.gender == "Female")
                {
                    userModel.img_path = "~/image/female.png";
                }

                dbModel.users.Add(userModel);
                dbModel.SaveChanges();

                attendance atnModel = new attendance();


                var initialUser = dbModel.users.Where(x => x.email == userModel.email).FirstOrDefault();



                atnModel.user_      = initialUser.regId;
                atnModel.no_of_days = 0;
                atnModel.status_    = "false";
                atnModel.date_      = DateTime.Now.Date.AddDays(-1).ToString();
                //atnModel.date_ = DateTime.Now.ToString("MM-dd-yyyy");

                dbModel.attendances.Add(atnModel);
                dbModel.SaveChanges();
            }

            ViewBag.SuccessMessage = "Registration Successful.";
            ModelState.Clear();
            user user = new user();

            return(View("addOrEdit", user));
        }
コード例 #9
0
 public ActionResult Create(bill Bill)
 {
     using (DBModel dBModel = new DBModel())
     {
         dbmodel.bills.Add(Bill);
         dbmodel.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
コード例 #10
0
        public ActionResult Attendance(int id)
        {
            using (inventorymgtEntities dbModel = new inventorymgtEntities())
            {
                var userDetails = dbModel.users.Where(x => x.regId == id).FirstOrDefault();
                var atndDetails = dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault();

                //if (DateTime.Now.Date > atndDetails.date_)



                DateTime dt = DateTime.Parse(atndDetails.date_);
                if (DateTime.Now.Date.CompareTo(dt) > 0)
                {
                    atndDetails.status_ = "false";

                    dbModel.Entry(atndDetails).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                int cdays = (int)atndDetails.no_of_days;
                int sPlan = 0;
                if (userDetails != null && userDetails.shedule != null)
                {
                    if (userDetails.shedule.ToString() == "D30")
                    {
                        sPlan = 30;
                    }
                    else if (userDetails.shedule.ToString() == "D40")
                    {
                        sPlan = 40;
                    }
                    else if (userDetails.shedule.ToString() == "D45")
                    {
                        sPlan = 45;
                    }
                    else
                    {
                        sPlan = 50;
                    }
                }

                Session["username"] = userDetails.fname + " " + userDetails.lname;
                Session["userId"]   = userDetails.regId;
                Session["progress"] = ((double)cdays / (double)sPlan) * 100 /*/(100 / 45) * cdays*/;
                Session["rDays"]    = sPlan - cdays;

                return(View(dbModel.attendances.Where(x => x.user_ == id).FirstOrDefault()));
            }
        }
コード例 #11
0
 public ActionResult Create(inventory invent)
 {
     try
     {
         using (inventorymgtEntities invtModel = new inventorymgtEntities())
         {
             invtModel.inventories.Add(invent);
             invtModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #12
0
        public ActionResult deleteUser(int id)
        {
            bool status = false;

            using (inventorymgtEntities dbModel = new inventorymgtEntities()) {
                var usr = dbModel.users.Where(a => a.regId == id).FirstOrDefault();
                if (usr != null)
                {
                    dbModel.users.Remove(usr);
                    dbModel.SaveChanges();
                    status = true;
                }

                return(RedirectToAction("Index"));
            }
        }
コード例 #13
0
        public ActionResult Create(trainer Trainer)
        {
            try
            {
                dbModel.trainers.Add(Trainer);
                dbModel.SaveChanges();

                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #14
0
        public ActionResult Create(bill Bill)
        {
            try
            {
                dbmodel.bills.Add(Bill);
                dbmodel.SaveChanges();

                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #15
0
        public ActionResult Edit(int id, inventory invent)
        {
            try
            {
                using (inventorymgtEntities invtModel = new inventorymgtEntities())
                {
                    invtModel.Entry(invent).State = EntityState.Modified;
                    invtModel.SaveChanges();
                }

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #16
0
 public ActionResult ChangePassword(user user)
 {
     using (inventorymgtEntities dbModel = new inventorymgtEntities())
     {
         try
         {
             dbModel.Entry(user).State = EntityState.Modified;
             dbModel.SaveChanges();
             return(RedirectToAction("../Login/Login"));
         }
         catch (Exception e)
         {
             Response.Write(e.StackTrace.ToString());
             return(RedirectToAction("Details", new { id = user.regId }));
         }
     }
 }
コード例 #17
0
 public ActionResult Create(member Member)
 {
     try
     {
         // TODO: Add insert logic here
         using (inventorymgtEntities dbmodel = new inventorymgtEntities())
         {
             dbmodel.members.Add(Member);
             dbmodel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #18
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         using (inventorymgtEntities invtModel = new inventorymgtEntities())
         {
             inventory invent = invtModel.inventories.Where(x => x.itemCode == id).FirstOrDefault();
             invtModel.inventories.Remove(invent);
             invtModel.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #19
0
        public ActionResult Edit(int id, trainer Trainer)
        {
            try
            {
                using (inventorymgtEntities dbModel = new inventorymgtEntities()) {
                    dbModel.Entry(Trainer).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #20
0
        public ActionResult Edit(int id, leave leave)
        {
            try
            {
                using (inventorymgtEntities inventorymgtEntities = new inventorymgtEntities())
                {
                    inventorymgtEntities.Entry(leave).State = System.Data.Entity.EntityState.Modified;
                    inventorymgtEntities.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #21
0
        public ActionResult Create(leave leave)
        {
            try
            {
                using (inventorymgtEntities inventorymgtEntities = new inventorymgtEntities())
                {
                    inventorymgtEntities.leaves.Add(leave);
                    inventorymgtEntities.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #22
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         // TODO: Add delete logic here
         using (inventorymgtEntities mv = new inventorymgtEntities())
         {
             schedule sc = mv.schedules.Where(x => x.ID == id).FirstOrDefault();
             mv.schedules.Remove(sc);
             mv.SaveChanges();
         }
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
コード例 #23
0
        public ActionResult Create(employee employee)
        {
            try
            {
                using (inventorymgtEntities empModel = new inventorymgtEntities())
                {
                    empModel.employees.Add(employee);
                    empModel.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #24
0
        public ActionResult Edit(int id, employee employee)
        {
            try
            {
                using (inventorymgtEntities empModel = new inventorymgtEntities())
                {
                    empModel.Entry(employee).State = System.Data.Entity.EntityState.Modified;
                    empModel.SaveChanges();
                }
                // TODO: Add update logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #25
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (inventorymgtEntities dbmodel = new inventorymgtEntities()) {
                    bill Bill = dbmodel.bills.Where(x => x.billId == id).FirstOrDefault();
                    dbmodel.bills.Remove(Bill);
                    dbmodel.SaveChanges();
                }
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #26
0
        public ActionResult Edit(user user)
        {
            // TODO: Add update logic here
            try
            {
                using (inventorymgtEntities dbModel = new inventorymgtEntities())
                {
                    dbModel.Entry(user).State = EntityState.Modified;
                    dbModel.SaveChanges();
                }

                return(RedirectToAction("Details", new { id = user.regId }));
            }
            catch
            {
                return(View());
            }
        }
コード例 #27
0
        public ActionResult Create2(trainer Trainer)
        {
            try
            {
                using (inventorymgtEntities dbModel = new inventorymgtEntities())
                {
                    dbModel.trainers.Add(Trainer);
                    dbModel.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #28
0
        public ActionResult Create(inventory_pay Inventory)
        {
            try
            {
                using (inventorymgtEntities dbmodel = new inventorymgtEntities())
                {
                    dbmodel.inventory_pay.Add(Inventory);
                    dbmodel.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #29
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (inventorymgtEntities dbModel = new inventorymgtEntities())
                {
                    trainer Trainer = dbModel.trainers.Where(x => x.PaymentID == id).FirstOrDefault();
                    dbModel.trainers.Remove(Trainer);
                    dbModel.SaveChanges();
                }
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
コード例 #30
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                using (inventorymgtEntities inventorymgtEntities = new inventorymgtEntities())
                {
                    leave leave1 = inventorymgtEntities.leaves.Where(x => x.empId == id).FirstOrDefault();
                    inventorymgtEntities.leaves.Remove(leave1);
                    inventorymgtEntities.SaveChanges();
                }
                // TODO: Add delete logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }