//添加 protected void btn_Save_Click(object sender, EventArgs e) { lab_Error.Text = ""; Profess model = new Profess(); try { if (hid_id.Value != "") { model=Profess.Load(Convert.ToInt32(hid_id.Value)); } model.ProCode = txt_MajorCode.Text.Trim(); model.ProName = txt_MajorName.Text.Trim(); model.ProSetting =Convert.ToInt32(ddl_seting.SelectedValue); model.ProShortName = txt_MajorShortName.Text.Trim(); model.SchoolCate = ddlSchoolCate.SelectedValue.ToString() ; model.Des = txt_Des.Text.Trim(); model.IsHighLevel = int.Parse(ddlishigh.SelectedValue); if (hid_id.Value != "") { Profess temp = Profess.IsExists(model.Id,model.ProCode); if (temp != null) { lab_Error.Text = "专业编号已经存在"; return; } model.Save(); txt_MajorCode.Text = ""; txt_MajorName.Text = ""; txt_MajorShortName.Text = ""; txt_Des.Text = ""; Page.ClientScript.RegisterStartupScript(typeof(string), "", "alert('修改成功');location.href='MajorList.aspx'", true); hid_id.Value = ""; } else { Profess temp = Profess.GetInstance(model.ProCode); if (temp != null) { lab_Error.Text = "专业编号已经存在"; return; } model.Save(); txt_MajorCode.Text = ""; txt_MajorName.Text = ""; txt_MajorShortName.Text = ""; txt_Des.Text = ""; Page.ClientScript.RegisterStartupScript(typeof(string),"","alert('添加成功');",true); } } catch (Exception ex) { lab_Error.Text =ex.Message; } }