Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["ID"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var    typeName = (string)Session["Type"];
            var    type     = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();
            SubBnd subBnd   = db.SubBnds.Find(id);
            var    Bndid    = subBnd.BndId;

            if (type.Finance == true)
            {
                db.SubBnds.Remove(subBnd);
                db.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult Edit(SubBnd subBnd)
        {
            if (Session["ID"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (ModelState.IsValid)
            {
                subBnd.Date            = DateTime.Now.Date;
                subBnd.SumPrice        = subBnd.PeacePrice * subBnd.Quantity;
                db.Entry(subBnd).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CenterID     = new SelectList(db.Centers, "id", "Name", subBnd.CenterID);
            ViewBag.TitleSideBar = "Study_subject";

            return(View(subBnd));
        }
Пример #3
0
        public ActionResult Create(SubBnd subBnd)
        {
            if (Session["ID"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            int empid = Convert.ToInt32(Session["ID"]);

            if (ModelState.IsValid)
            {
                try
                {
                    subBnd.id = db.SubBnds.OrderByDescending(x => x.id).FirstOrDefault().id + 1;
                }
                catch (Exception)
                {
                    subBnd.id = 1;
                }
                subBnd.CreatedBy = empid;
                subBnd.Date      = DateTime.Now.Date;
                subBnd.SumPrice  = subBnd.PeacePrice * subBnd.Quantity;
                PaymentsRecord paymentsRecord = new PaymentsRecord();
                try
                {
                    paymentsRecord.id = db.PaymentsRecords.OrderByDescending(x => x.id).FirstOrDefault().id + 1;
                }
                catch (Exception)
                {
                    paymentsRecord.id = 1;
                }
                db.SubBnds.Add(subBnd);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CenterID     = new SelectList(db.Centers, "id", "Name");
            ViewBag.TitleSideBar = "Study_subject";

            return(View(subBnd));
        }
Пример #4
0
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Bnds"));
            }
            if (Session["ID"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var    typeName = (string)Session["Type"];
            var    type     = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();
            int    empid    = Convert.ToInt32(Session["ID"]);
            SubBnd subBnd   = db.SubBnds.Find(id);
            var    Bndid    = subBnd.BndId;

            if (type.Finance == true && subBnd.CreatedBy == empid)
            {
                ViewBag.TitleSideBar = "Study_subject";

                return(View(subBnd));
            }
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Bnds"));
            }
            if (Session["ID"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            int    empid    = Convert.ToInt32(Session["ID"]);
            SubBnd subBnd   = db.SubBnds.Find(id);
            var    typeName = (string)Session["Type"];
            var    type     = db.EmployeeTypes.Where(x => x.Type == typeName).FirstOrDefault();

            if (empid == subBnd.CreatedBy && type.Finance == true)
            {
                ViewBag.TitleSideBar = "Study_subject";

                ViewBag.CenterID = new SelectList(db.Centers, "id", "Name", subBnd.CenterID);
                return(View(subBnd));
            }
            return(RedirectToAction("Index"));
        }