protected void Page_Load(object sender, EventArgs e) { int id = RequestHelper.GetQueryString <int>("ID"); string Action = RequestHelper.GetQueryString <string>("Action"); if (Action == "Delete") { if (id != int.MinValue) { base.CheckAdminPower("DeleteCourse", PowerCheckType.Single); CourseBLL.DeleteCourse(id); AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("DeleteRecord"), ShopLanguage.ReadLanguage("Course"), id); } } base.CheckAdminPower("ReadCourse", PowerCheckType.Single); if (!IsPostBack) { //在此处加载搜索框的类别信息 CourseCateInfo CourseCateModel = new CourseCateInfo(); CourseCateModel.Condition = CompanyBLL.SystemCompanyId.ToString(); SearchCategory.DataSource = CourseCateBLL.ReadCourseCateNamedList(CourseCateModel); SearchCategory.DataTextField = "CateName"; SearchCategory.DataValueField = "CateId"; SearchCategory.DataBind(); SearchCategory.Items.Insert(0, new ListItem("可以指定类别", "-1")); CourseInfo Model = new CourseInfo(); Model.CourseName = RequestHelper.GetQueryString <string>("CourseName"); Model.CateIdCondition = RequestHelper.GetQueryString <string>("CateIdCondition"); Model.Condition = CompanyBLL.SystemCompanyId.ToString(); Model.Field = "CompanyId"; base.BindControl(CourseBLL.ReadList(Model, base.CurrentPage, base.PageSize, ref this.Count), this.RecordList, this.MyPager); } }
//DELETE public ActionResult DeleteCourse(int id) { courseBll.DeleteCourse(id); List <CourseVM> courses = courseBll.getAllCourses(); ViewBag.courses = courses; return(RedirectToAction("getAllCourses", "Course")); }
protected void Button2_Click(object sender, EventArgs e) { base.CheckAdminPower("DeleteCourse", PowerCheckType.Single); string ID = RequestHelper.GetIntsForm("SelectID"); string[] Arr = ID.Split(','); for (int i = 0; i < Arr.Length; i++) { CourseBLL.DeleteCourse(int.Parse(Arr[i])); QuestionBLL.DeleteQuestionByCateId(int.Parse(Arr[i])); } AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("DeleteRecord"), ShopLanguage.ReadLanguage("Course"), ID); ScriptHelper.Alert(ShopLanguage.ReadLanguage("DeleteOK"), RequestHelper.RawUrl); }
//删除课程 private void ucBtnDelete_BtnClick(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count > 0) { string sid = dataGridView1.SelectedRows[0].Cells[0].Value.ToString(); CourseBLL bll = new CourseBLL(); string msg = bll.DeleteCourse(sid) ? "删除成功" : "删除失败"; MessageBox.Show(msg); LoadCourseInfo(); } else { MessageBox.Show("请选中要删除的行"); } }
protected void lnkbDel_Click(object sender, EventArgs e) { LinkButton lnkbDel = (LinkButton)sender; if (CourseBLL.DeleteCourse(Convert.ToInt32(lnkbDel.CommandArgument)) > 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; } }