protected void btnUpdate_Click(object sender, EventArgs e) { if (this.FormCheck()) { try { string sqlCheck = string.Format("select count(*) from Base_UseType where Name='{0}' and id<>{1} AND Type={2}", txtName.Text, Request["Id"], ddlType.SelectedItem.Value); if (Convert.ToInt32(DBHelp.ExeScalar(sqlCheck)) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, string.Format("<script>alert('名称[{0}],已经存在!');</script>", txtName.Text)); return; } Base_UseType model = getModel(); if (this.warnDaysService.Update(model)) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('修改成功!');</script>"); } else { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('修改失败!');</script>"); } } catch (Exception ex) { base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('" + ex.Message + "!');</script>"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { A_ProInfoService proSer = new A_ProInfoService(); if (base.Request["Id"] != null) { this.btnAdd.Visible = false; Base_UseType model = this.warnDaysService.GetModel(Convert.ToInt32(base.Request["Id"])); this.txtName.Text = model.Name; this.ddlType.Text = model.Type.ToString(); } else { this.btnUpdate.Visible = false; } } }