protected void btnUpdate_Click(object sender, EventArgs e) { if (this.FormCheck()) { try { string sqlCheck = string.Format("select count(*) from CAR_YearCheck where CarNo='{0}' and YearDate='{2}' and id<>{1}", ddlCarNo.Text, Request["Id"], txtYearDate.Text); if (Convert.ToInt32(DBHelp.ExeScalar(sqlCheck)) > 0) { base.ClientScript.RegisterStartupScript(base.GetType(), null, string.Format("<script>alert('车牌号[{0}],有效期[{1}]已经存在!');</script>", ddlCarNo.Text, txtYearDate.Text)); return; } CAR_YearCheck model = getModel(); if (this.CAR_YearCheckService.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) { if (base.Request["Id"] != null) { this.btnAdd.Visible = false; CAR_YearCheck model = this.CAR_YearCheckService.GetModel(Convert.ToInt32(base.Request["Id"])); this.ddlCarNo.Text = model.CarNo; this.txtYearDate.Text = model.YearDate.ToString("yyyy-MM-dd"); txtRemark.Text = model.Remark; } else { this.btnUpdate.Visible = false; } } }