/// <summary> /// 添加学生资助类型 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_Add_Click(object sender, EventArgs e) { lab_Error.Text = ""; SubsidyForStudent model = new SubsidyForStudent(); try { model.SubsidyName = txt_SubsidyName.Text.Trim(); model.SubsidyDescription = txt_SubsidyDescription.Text.Trim(); model.BeginDate = DateTime.Now; List<SubsidyForStudent> temp = SubsidyForStudent.IsExists(0, model.SubsidyName) as List<SubsidyForStudent>; if (temp.Count > 0) { lab_Error.Text = "资助类别编号已存在"; return; } model.Save(); Page.ClientScript.RegisterStartupScript(typeof(string), "", "alert('添加成功');", true); BindData(); btn_AddSubsidyType.Enabled = true; btn_Delete.Visible = true; pan_Module.Visible = false; txt_SubsidyName.Text = ""; txt_SubsidyDescription.Text = ""; } catch (Exception ex) { lab_Error.Text = "错误信息:" + ex.Message; } }
//修改 protected void btn_Update_Click(object sender, EventArgs e) { lab_Error.Text = ""; SubsidyForStudent model = new SubsidyForStudent(); try { if (hid_typeId.Value!= null) { model = SubsidyForStudent.Load(Convert.ToInt32(hid_typeId.Value)); } model.SubsidyName = txt_SubsidyName.Text.Trim(); model.SubsidyDescription = txt_SubsidyDescription.Text.Trim(); List<SubsidyForStudent> temp = SubsidyForStudent.IsExists(model.Id, model.SubsidyName) as List<SubsidyForStudent>; if (temp.Count > 0) { lab_Error.Text = "资助类别编号已存在"; return; } model.Save(); hid_typeId.Value = ""; Page.ClientScript.RegisterStartupScript(typeof(string), "", "alert('修改成功');", true); BindData(); btn_Add.Visible = true; btn_Update.Visible = false; btn_AddSubsidyType.Text = "添加资助类型"; btn_AddSubsidyType.Enabled = true; btn_Delete.Visible = true; btn_Cancel_Click(sender, e); } catch (Exception ex) { hid_typeId.Value = ""; lab_Error.Text = "错误信息:" + ex.Message; } }