/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { #region 验证 if (string.IsNullOrEmpty(ddlYear.SelectedValue)) { Common.JShelper.JSAlert(this.Page,"","学年不能为空!"); ddlYear.Focus(); } else if (string.IsNullOrEmpty(ddlAcadmic.SelectedValue)) { Common.JShelper.JSAlert(this.Page,"","学期不能为空!"); ddlAcadmic.Focus(); } else if (string.IsNullOrEmpty(tbSTime.Text.Trim())) { Common.JShelper.JSAlert(this.Page,"","开学时间不能为空!"); tbSTime.Focus(); } else if (string.IsNullOrEmpty(tbETime.Text.Trim())) { Common.JShelper.JSAlert(this.Page,"","结束时间不能为空!"); tbETime.Focus(); } #endregion else { DateTime Stime =DateTime.Parse(tbSTime.Text.Trim()); DateTime Etime =DateTime.Parse(tbETime.Text.Trim()); int a=Etime.CompareTo(Stime); if (a != 1) { Common.JShelper.JSAlert(this.Page, "", "结束时间不能早于开学时间!"); tbETime.Text = ""; tbETime.Focus(); } else { LabMS.Model.Semester MS = new LabMS.Model.Semester(); MS.ID = int.Parse(Request.QueryString["ID"].ToString()); MS.ETime = DateTime.Parse(tbETime.Text.Trim()); MS.STime = DateTime.Parse(tbSTime.Text.Trim()); MS.Year = int.Parse(ddlYear.SelectedValue.ToString()); MS.MSemester = int.Parse(ddlAcadmic.SelectedValue.ToString()); LabMS.BLL.Semester BS = new LabMS.BLL.Semester(); try { BS.Update(MS); Common.JShelper.JSAlertAndRedirect(this.Page, "", "修改成功!", "academic-year.aspx"); } catch { Common.JShelper.JSAlert(this.Page, "", "修改失败!"); } } } }
/////对于学期: 1为春季,2为秋季 /// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { #region 验证 if (string.IsNullOrEmpty(tbETime.Text.Trim())) { Common.JShelper.JSAlert(this.Page,"","开学时间不能为空!"); tbETime.Focus(); } else if (string.IsNullOrEmpty(tbSTime.Text.Trim())) { Common.JShelper.JSAlert(this.Page, "", "结束时间不能为空!"); tbSTime.Focus(); } #endregion else { DateTime ETime=DateTime.Parse(tbETime.Text.Trim());//结束时间 DateTime STime=DateTime.Parse(tbSTime.Text.Trim());//开学时间 int a = ETime.CompareTo(STime); if (a != 1) { Common.JShelper.JSAlert(this.Page, "", "结束时间应该比开学时间晚!"); tbETime.Text = ""; tbETime.Focus(); } else { LabMS.Model.Semester MS = new LabMS.Model.Semester(); MS.ETime = DateTime.Parse(tbETime.Text.Trim()); MS.STime = DateTime.Parse(tbSTime.Text.Trim()); MS.Year = int.Parse(ddlYear.SelectedValue.ToString()); MS.MSemester = int.Parse(ddlAcadmic.SelectedValue.ToString()); LabMS.BLL.Semester BS = new LabMS.BLL.Semester(); int count = BS.Add(MS); if (count > 0) { Common.JShelper.JSAlertAndRedirect(this.Page, "", "保存成功!", "academic-year.aspx"); } else { Common.JShelper.JSAlert(this.Page, "", "保存失败!"); } } } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.Semester GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,Year,MSemester,STime,ETime from Semester "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4)}; parameters[0].Value = ID; LabMS.Model.Semester model=new LabMS.Model.Semester(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["ID"].ToString()!="") { model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } if(ds.Tables[0].Rows[0]["Year"].ToString()!="") { model.Year=int.Parse(ds.Tables[0].Rows[0]["Year"].ToString()); } if(ds.Tables[0].Rows[0]["MSemester"].ToString()!="") { model.MSemester=int.Parse(ds.Tables[0].Rows[0]["MSemester"].ToString()); } if(ds.Tables[0].Rows[0]["STime"].ToString()!="") { model.STime=DateTime.Parse(ds.Tables[0].Rows[0]["STime"].ToString()); } if(ds.Tables[0].Rows[0]["ETime"].ToString()!="") { model.ETime=DateTime.Parse(ds.Tables[0].Rows[0]["ETime"].ToString()); } return model; } else { return null; } }