protected void Page_Load(object sender, EventArgs e) { if (!base.IsPostBack) { TB_CarInfoService carInfoSer = new TB_CarInfoService(); System.Collections.Generic.List <TB_CarInfo> carInfos = carInfoSer.GetListArray(""); carInfos.Insert(0, new TB_CarInfo()); ddlCarNo.DataSource = carInfos; ddlCarNo.DataBind(); ddlCarNo.DataTextField = "CarNo"; ddlCarNo.DataValueField = "CarNo"; if (base.Request["Id"] != null) { this.btnAdd.Visible = false; TB_BreakRulesCar model = this.breakRulesCarSer.GetModel(Convert.ToInt32(base.Request["Id"])); txtBreakTime.Text = model.BreakTime.ToShortDateString(); txtAddress.Text = model.Address; txtDothing.Text = model.Dothing; txtRemark.Text = model.Remark; ddlState.Text = model.State; txtTotal.Text = model.Total.ToString(); txtDriver.Text = model.Driver; txtJiGuan.Text = model.JiGuan; ddlCarNo.Text = model.CarNo; txtScore.Text = model.Score.ToString(); if (model.CarNo != "") { TB_CarInfoService carSer = new TB_CarInfoService(); List <TB_CarInfo> car = carSer.GetListArray(string.Format(" 1=1 and CarNo='{0}'", model.CarNo)); if (car.Count > 0) { txtNianJian.Text = ""; txtBaoxian.Text = ""; if (car[0].NianJian != null) { txtNianJian.Text = car[0].NianJian.Value.ToString(); } if (car[0].Baoxian != null) { txtBaoxian.Text = car[0].Baoxian.Value.ToString(); } } } } else { this.btnUpdate.Visible = false; } } }
private void UpdateCarInfo() { TB_CarInfo model = new TB_CarInfo(); model.CarNo = ddlCarNo.Text; if (txtBaoxian.Text != "") { model.Baoxian = Convert.ToDateTime(txtBaoxian.Text); } if (txtNianJian.Text != "") { model.NianJian = Convert.ToDateTime(txtNianJian.Text); } TB_CarInfoService carSer = new TB_CarInfoService(); carSer.UpdateDate(model); }