日期:2014-05-18 浏览次数:20747 次
private void 场内车辆_Load(object sender, EventArgs e) { Bind(); } public void Bind() { dgvRuChang.AutoGenerateColumns = false; dgvRuChang.DataSource = bsb.GetNoExitCar(); } //根据车主姓名查询 private void button1_Click(object sender, EventArgs e) { dgvRuChang.DataSource = null; dd(); } public void dd() { string param = ""; switch (cbbTiaoJian.Text) { case "卡号": param = txtParam.Text; dgvRuChang.DataSource = bsb.GetByUserName(param); break; case "车主姓名": param = txtParam.Text; dgvRuChang.DataSource = bsb.GetByUserName(param); break; default: param = txtParam.Text; dgvRuChang.DataSource = bsb.GetByUserName(param); break; } }
//场内车辆页面,根据车主名字查询 public BusResordModel GetByUserName(string userName) { try { SqlParameter[] parm = { sqlH.MakeInParam("@userName", SqlDbType.NVarChar, 50, userName)}; using (SqlDataReader dr = sqlH.ExecuteReader("SelectByUserName", CommandType.StoredProcedure, parm)) { BusResordModel busM = new BusResordModel(); while (dr.Read()) { busM.CardNo = dr["cardNo"].ToString(); busM.UserName = dr["userName"].ToString(); busM.BusNo = dr["busNo"].ToString(); busM.BusType = dr["busType"].ToString(); busM.InTime = dr["inTime"].ToString(); busM.InAddr = dr["inAddr"].ToString(); busM.Picture = dr["picture"].ToString(); busM.Guid = dr["guid"].ToString(); } return busM; } } catch { return null; } }