using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using WeiSha.Common; using Song.ServiceInterfaces; using Song.Entities; using WeiSha.WebControl; using System.Collections.Generic; namespace Song.Site.Manage.Exam { public partial class TestPaper : Extend.CustomPage { Song.Entities.Organization org = null; protected void Page_Load(object sender, EventArgs e) { org = Business.Do().OrganCurrent(); if (!this.IsPostBack) { InitBind(); BindData(null, null); } } #region /// /// 界面的初始绑定 /// private void InitBind() { Song.Entities.Subject[] eas = null; eas = Business.Do().SubjectCount(org.Org_ID, null, true, -1, -1); ddlTree.DataSource = eas; this.ddlTree.DataTextField = "Sbj_Name"; this.ddlTree.DataValueField = "Sbj_ID"; this.ddlTree.Root = 0; this.ddlTree.DataBind(); ddlTree.Items.Insert(0, new ListItem("-- 专业 --", "0")); ddlTree_SelectedIndexChanged(null, null); } /// /// 当专业下拉菜单更改时 /// /// /// protected void ddlTree_SelectedIndexChanged(object sender, EventArgs e) { //课程 int sbjid; int.TryParse(ddlTree.SelectedValue, out sbjid); if (sbjid > 0) { List cous = Business.Do().CourseCount(org.Org_ID, sbjid, null, true, -1); ddlCourse.DataSource = cous; this.ddlCourse.DataTextField = "Cou_Name"; this.ddlCourse.DataValueField = "Cou_ID"; this.ddlCourse.Root = 0; this.ddlCourse.DataBind(); } if (ddlCourse.Items.Count < 1) { ddlCourse.Items.Add(new ListItem("--课程--", "0")); } } /// /// 当前课程下拉菜单更改时 /// /// /// protected void ddlCourse_SelectedIndexChanged(object sender, EventArgs e) { BindData(null, null); } #endregion /// /// 绑定列表 /// protected void BindData(object sender, EventArgs e) { //总记录数 int count = 0; int sbj = Convert.ToInt32(ddlTree.SelectedValue); string sear = tbSear.Text.Trim(); int couid = 0; int.TryParse(ddlCourse.SelectedValue, out couid); // Song.Entities.TestPaper[] eas = null; Song.Entities.Organization org = Business.Do().OrganCurrent(); eas = Business.Do().PaperPager(org.Org_ID, sbj, couid,-1, null, sear, Pager1.Size, Pager1.Index, out count); GridView1.DataSource = eas; GridView1.DataKeyNames = new string[] { "Tp_Id" }; GridView1.DataBind(); Pager1.RecordAmount = count; } protected void btnsear_Click(object sender, EventArgs e) { Pager1.Index = 1; BindData(null, null); } /// /// 删除 /// /// /// protected void DeleteEvent(object sender, EventArgs e) { try { string keys = GridView1.GetKeyValues; foreach (string id in keys.Split(',')) { Business.Do().PagerDelete(Convert.ToInt16(id)); } BindData(null, null); } catch (Exception ex) { this.Alert(ex.Message); } } /// /// 单个删除 /// /// /// protected void btnDel_Click(object sender, ImageClickEventArgs e) { try { WeiSha.WebControl.RowDelete img = (WeiSha.WebControl.RowDelete)sender; int index = ((GridViewRow)(img.Parent.Parent)).RowIndex; int id = int.Parse(this.GridView1.DataKeys[index].Value.ToString()); Business.Do().PagerDelete(id); BindData(null, null); } catch (Exception ex) { this.Alert(ex.Message); } } /// /// 修改是否显示的状态 /// /// /// protected void sbUse_Click(object sender, EventArgs e) { try { StateButton ub = (StateButton)sender; int index = ((GridViewRow)(ub.Parent.Parent)).RowIndex; int id = int.Parse(this.GridView1.DataKeys[index].Value.ToString()); // Song.Entities.TestPaper entity = Business.Do().PagerSingle(id); entity.Tp_IsUse = !entity.Tp_IsUse; Business.Do().PagerSave(entity); BindData(null, null); } catch (Exception ex) { Alert(ex.Message); } } } }