protected void btnSure_Click(object sender, EventArgs e) { SchoolCarInfo entity = new SchoolCarInfo(); WebFormHelper.GetDataFromForm(this, entity); entity.DepName = this.cbDepCodeValue.SelectedItem.Text; if (entity.Id < 0) { if (SimpleOrmOperator.Create(entity)) { WebTools.Alert("添加成功!"); } else { WebTools.Alert("添加失败!"); } } else { if (SimpleOrmOperator.Update(entity)) { WebTools.Alert("修改成功!"); } else { WebTools.Alert("修改失败!"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DepartMentOperator.Bind(this.cbDepCodeValue, "驾校"); if (Request.Params["id"] != null) { SchoolCarInfo entity = SimpleOrmOperator.Query <SchoolCarInfo>(Convert.ToInt32(Request.Params["id"])); WebFormHelper.SetDataToForm(this, entity); } if (!string.IsNullOrEmpty(Request.Params["depId"])) { int depId = this.Operator.DeptId; DepartMent dep = SimpleOrmOperator.Query <DepartMent>(depId); cbDepCodeValue.SelectedValue = dep.DepCode; cbDepCodeValue.Enabled = false; } } }