public ActionResult EditCourse(CourseVM cvm, FormCollection collection)
        {
            if (!string.IsNullOrEmpty(collection["activeState"]))
            {
                string checkResp  = collection["activeState"];
                bool   checkRespB = Convert.ToBoolean(checkResp);

                if (checkRespB)
                {
                    cvm.isActive = true;
                }
                else
                {
                    cvm.isActive = false;
                }
            }
            else
            {
                cvm.isActive = false;
            }

            courseBll.UpdateCourse(cvm);


            List <CourseVM> courses = courseBll.getAllCourses();

            ViewBag.courses = courses;
            return(RedirectToAction("getAllCourses", "Course", new { area = "AdminArea" }));
        }
 //添加、修改
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (btnAdd.Text == "添加")
     {
         Course model = new Course();
         model.CourseName = txtCourseName.Value.Trim();
         model.Credits    = Convert.ToInt32(txtCredits.Value.Trim());
         model.Note       = txtNote.Value.Trim();
         model.TeacherId  = Convert.ToInt32(ddlTeacherId.SelectedValue);
         if (CourseBLL.IsTrue(model.CourseName))
         {
             this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该课程名称已存在,不能重复!');</script>");
             return;
         }
         else
         {
             if (CourseBLL.AddCourse(model) > 0)
             {
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加成功!');window.location.replace('CourseManage.aspx');</script>");
                 return;
             }
             else
             {
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('添加失败!');</script>");
                 return;
             }
         }
     }
     else
     {
         Course model = CourseBLL.GetIdByCourse(Convert.ToInt32(Request.QueryString["uid"]));
         model.CourseName = txtCourseName.Value.Trim();
         model.Credits    = Convert.ToInt32(txtCredits.Value.Trim());
         model.Note       = txtNote.Value.Trim();
         model.TeacherId  = Convert.ToInt32(ddlTeacherId.SelectedValue);
         if (CourseBLL.IsTrue(model.CourseName, model.CourseId))
         {
             this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('该课程名称已存在,不能重复!');</script>");
             return;
         }
         else
         {
             if (CourseBLL.UpdateCourse(model) > 0)
             {
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改成功!');window.location.replace('CourseManage.aspx');</script>");
                 return;
             }
             else
             {
                 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('修改失败!');</script>");
                 return;
             }
         }
     }
 }
示例#3
0
        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            base.CheckAdminPower("UpdateCourse", PowerCheckType.Single);
            string courseID = RequestHelper.GetQueryString <string>("CourseID");

            if (this.CateId.SelectedValue == "-1")
            {
                ScriptHelper.Alert("请选择类别");
            }

            CourseBLL.UpdateCourse(courseID, Convert.ToInt32(this.CateId.SelectedValue));
            AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Course"), courseID);
            AdminBasePage.Alert(ShopLanguage.ReadLanguage("UpdateOK"), RequestHelper.RawUrl);
        }
示例#4
0
        //private Control FindControlById(Control parent, String id)
        //{
        //    foreach (Control item in parent.Controls)
        //    {
        //        if (item.ID == id) return item;
        //        Control subControl = FindControlById(item, id);
        //        if (subControl != null) return subControl;
        //    }
        //    return null;
        //}


        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            int queryString = RequestHelper.GetQueryString <int>("ID");

            CourseInfo CourseModel = new CourseInfo();

            //if (_CompanyId > 0 && TempGroupId != 1 && TempGroupId != 2)
            //{
            CourseModel.CompanyId = systemCompanyId;
            //}
            //else
            //{
            //    if (CompanyId.SelectedValue == "-1") ScriptHelper.Alert("请选择公司");
            //    CourseModel.CompanyId = Convert.ToInt32(this.CompanyId.SelectedValue);
            //}
            if (this.CateId.SelectedValue == "-1")
            {
                ScriptHelper.Alert("请选择类别");
            }
            CourseModel.CourseId   = queryString;
            CourseModel.CourseName = this.CourseName.Text;
            //CourseModel.CourseCode = this.CourseCode.Text;
            CourseModel.CateId     = Convert.ToInt32(this.CateId.SelectedValue);
            CourseModel.OrderIndex = Convert.ToInt32(this.OrderIndex.Text);

            string alertMessage = ShopLanguage.ReadLanguage("AddOK");

            if (CourseModel.CourseId == int.MinValue)
            {
                base.CheckAdminPower("AddCourse", PowerCheckType.Single);
                int id = CourseBLL.AddCourse(CourseModel);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("Course"), id);
            }
            else
            {
                base.CheckAdminPower("UpdateCourse", PowerCheckType.Single);
                CourseBLL.UpdateCourse(CourseModel);
                AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("UpdateRecord"), ShopLanguage.ReadLanguage("Course"), CourseModel.CourseId);
                alertMessage = ShopLanguage.ReadLanguage("UpdateOK");
            }
            AdminBasePage.Alert(alertMessage, RequestHelper.RawUrl);
        }