private void LoadData() { List <CSPeriodsWorksType> ds = DAL.Periods.GetPeriodByCourseID(); CSPeriodsWorksType cs = new CSPeriodsWorksType(); cs.PeriodTitle = ""; cs.PeriodID = 0; List <CSPeriodsWorksType> dsTmp = new List <CSPeriodsWorksType>(); dsTmp.Add(cs); dsTmp.AddRange(ds); ddlQiCi.DataSource = dsTmp; ddlQiCi.DataTextField = "PeriodTitle"; ddlQiCi.DataValueField = "PeriodID"; ddlQiCi.DataBind(); if (dsTmp.Count > 1) { if (Request.QueryString["PeriodID"] != null) { ListItem lstItem = ddlQiCi.Items.FindByValue(Request.QueryString["PeriodID"]); if (lstItem == null) { ddlQiCi.SelectedIndex = 1; } else { ddlQiCi.SelectedIndex = ddlQiCi.Items.IndexOf(lstItem); } } else { ddlQiCi.SelectedIndex = 1; } } List <WorksType> lstTmp = BLL.WorksType.GetWorksTypeTopLevel(); ddlWorksType.DataSource = lstTmp; ddlWorksType.DataTextField = "WorksTypeName"; ddlWorksType.DataValueField = "WorksTypeID"; ddlWorksType.DataBind(); }
/// <summary> /// 行命令 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void gvPeriod_RowCommand(object sender, GridViewCommandEventArgs e) { long userId = BLL.User.GetUserID(SPContext.Current.Web.CurrentUser); if (e.CommandName == "Del") { GridViewRow drv = ((GridViewRow)(((Button)(e.CommandSource)).Parent.Parent)); Periods dr = new Periods(); dr.PeriodID = long.Parse(drv.Cells[0].Text); DateTime dtNow = DateTime.Now; DAL.Periods.DelPeriodsByID(dr, userId, dtNow); BindGvDate(); ClearDateTime(dateTimeStartSubmit); ClearDateTime(dateTimeEndSubmit); ClearDateTime(dateTimeStartScore); ClearDateTime(dateTimeEndScore); ClearDateTime(dateTimeStartPublic); ClearDateTime(dateTimeEndPublic); SetValue(); SetControls(1); } if (e.CommandName == "Down") { ClearDateTime(dateTimeStartSubmit); ClearDateTime(dateTimeEndSubmit); ClearDateTime(dateTimeStartScore); ClearDateTime(dateTimeEndScore); ClearDateTime(dateTimeStartPublic); ClearDateTime(dateTimeEndPublic); // GridViewRow drv = ((GridViewRow)(((Button)(e.CommandSource)).Parent.Parent)); CSPeriodsWorksType dt = DAL.Periods.GetPeriodsByID(long.Parse(drv.Cells[0].Text)); txtName.Text = dt.PeriodTitle; txtRequire.Text = dt.Require; txtNum.Text = dt.Number.ToString(); if (dt.StartSubmit.ToString() != "") { dateTimeStartSubmit.SelectedDate = DateTime.Parse(dt.StartSubmit.ToString()); } if (dt.EndSubmit.ToString() != "") { dateTimeEndSubmit.SelectedDate = DateTime.Parse(dt.EndSubmit.ToString()); } // if (dt.StartScore.ToString() != "") { dateTimeStartScore.SelectedDate = DateTime.Parse(dt.StartScore.ToString()); } if (dt.EndScore.ToString() != "") { dateTimeEndScore.SelectedDate = DateTime.Parse(dt.EndScore.ToString()); } // if (dt.StartPublic.ToString() != "") { dateTimeStartPublic.SelectedDate = DateTime.Parse(dt.StartPublic.ToString()); } if (dt.EndPublic.ToString() != "") { dateTimeEndPublic.SelectedDate = DateTime.Parse(dt.EndPublic.ToString()); } //当存的不是不限时 if (dt.LevelID.ToString() != "") { //有小类 if (dt.LevelID.ToString() != "0") { BindOneWorksType(WorksType); //加载作品类别 ddlOneWorksType.SelectedIndex = -1; ddlOneWorksType.Items.FindByValue(dt.ParentID.ToString()).Selected = true; BindTwoWorksType(WorksType, ddlOneWorksType.SelectedValue); ddlTwoWorksType.SelectedIndex = -1; ddlTwoWorksType.Items.FindByValue(dt.WorksTypeID.ToString()).Selected = true; } else { BindOneWorksType(WorksTypeDt); //加载作品类别 ddlOneWorksType.SelectedIndex = -1; ddlOneWorksType.Items.FindByValue(dt.WorksTypeID.ToString()).Selected = true; BindTwoWorksType(WorksType, ddlOneWorksType.SelectedValue); ddlTwoWorksType.SelectedIndex = -1; ddlTwoWorksType.Items.FindByValue("0").Selected = true; } } else { BindOneWorksType(WorksTypeDt); //加载作品类别 BindTwoWorksType(WorksTypeDt, ddlOneWorksType.SelectedValue); } hfID.Value = drv.Cells[0].Text; BindGvDate(); SetControls(2); } }