Example #1
0
        public ActionResult Create(_class cl)
        {
            //Phải khởi tạo lại viewBag mới lấy được dữ liệu
            BatchList    Batchlist = new BatchList();
            LevelList    Levellist = new LevelList();
            List <batch> obj       = Batchlist.ListAll();
            List <level> obj1      = Levellist.ListAll();

            ViewBag.batchCode = new SelectList(obj, "code", "name");
            ViewBag.levelCode = new SelectList(obj1, "code", "name");
            try
            {
                // TODO: Add insert logic here
                ClassList Classlist = new ClassList();
                Classlist.addClass(cl); //Gọi đến hàm addClass trong class ClassList trong models
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Example #2
0
        private void btnSave_ClickEvent(object sender, EventArgs e)
        {
            if (ValidateFomControls.CheckTextboxes(this, errorProvider1))
            {
                try
                {
                    var _unitOfWork = new UnitOfWork(new Model1());
                    if (_unitOfWork.dClassRepository.CheckIfItExists(_txtClassName.Text.Trim()))
                    {
                        MessageBox.Show("This class already exists.");
                        return;
                    }

                    var cl = new _class()
                    {
                        classes    = _txtClassName.Text.Trim(),
                        date_added = DateTime.Today.ToString("d"),
                        time_added = DateTime.Now
                    };

                    _unitOfWork.dClassRepository.Add(cl);
                    _unitOfWork.Save();
                    _unitOfWork.Dispose();
                    MessageBox.Show("Class Added Successfully");

                    using (var db = new Model1())
                    {
                        classes = db.classes.ToList();
                        dGridAllClass.DataSource = classes;
                    }
                }
                catch (Exception ex)
                {
                    Utils.LogException(ex);
                    MessageBox.Show("Error occured. Contact support");
                }
            }
        }
Example #3
0
        public ActionResult addAll(_class info)
        {
            ClassManager bll = new ClassManager();
            _class       cla = new _class()
            {
                Morning         = Request.Form["Morning"],
                Afertnoon       = Request.Form["Afertnoon"],
                UserIde         = Convert.ToInt32(Request.Form["UserIde"]),
                UserId          = Convert.ToInt32(Request.Form["UserId"]),
                DataTime        = Convert.ToDateTime(Request.Form["DataTime"]),
                require         = Request.Form["require"],
                class_Condition = "可见"
            };
            var add = bll.Add(cla);

            if (add)
            {
                return(Redirect("/LiuYi/workhou/addAll"));
            }
            else
            {
                return(Redirect("/LiuYi/workhou/deleteIndex"));
            }
        }