/// <summary> /// 在ListControl上更改SelectedValueChanged属性的值时引发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbxMenGangName_SelectedValueChanged(object sender, EventArgs e) { if (this.cbxPositionID.Items.Count > 0) // 门岗编号 { this.cbxPositionID.Items.Clear(); } if (this.cbxPositionValue.Items.Count > 0) // 门岗值 { this.cbxPositionValue.Items.Clear(); } if (this.cbxMenGangName.Text == "") { return; } string PositionName = this.cbxMenGangName.Text; var name = PositionDAL.GetViewPosition(String.Format("select * from Position where Position_Name='{0}'", PositionName)); if (name != null) { foreach (var item in name) { if (item.Position_ID != null) { if (item.Position_Value != null) { cbxPositionID.Items.Add(item.Position_ID); cbxPositionID.SelectedIndex = 0; cbxPositionValue.Items.Add(item.Position_Value); cbxPositionValue.SelectedIndex = 0; } } } } }
/// <summary> /// 绑定门岗名称 /// </summary> private void BindPositionName() { try { string sql = String.Format("select * from Position"); this.cbxMenGangName.DataSource = PositionDAL.GetViewPosition(sql); if (PositionDAL.GetViewPosition(sql).Count() > 0) { this.cbxMenGangName.DisplayMember = "Position_Name"; this.cbxMenGangName.ValueMember = "Position_ID"; cbxMenGangName.SelectedIndex = 0; } } catch { MessageBox.Show("系统设置“门岗”绑定有误,请查看门岗信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
/// <summary> /// 搜索 --绑定门岗 /// </summary> private void BindMenGang1() { try { string sql = "select * from Position where Position_State='启动'"; this.comboxMenGang.DataSource = PositionDAL.GetViewPosition(sql); if (PositionDAL.GetViewPosition(sql).Count() > 0) { this.comboxMenGang.DisplayMember = "Position_Name"; this.comboxMenGang.ValueMember = "Position_ID"; comboxMenGang.SelectedIndex = -1; } else { MessageBox.Show("门岗暂无数据!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { MessageBox.Show("摄像头管理“门岗”绑定有误,请查看门岗信息!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
private void BindPositionName() { try { string sql = "select * from Position where Position_State='启动'"; this.cbxDriveway_PositionName.DataSource = PositionDAL.GetViewPosition(sql); if (PositionDAL.GetViewPosition(sql).Count() > 0) { this.cbxDriveway_PositionName.DisplayMember = "Position_Name"; this.cbxDriveway_PositionName.ValueMember = "Position_ID"; cbxDriveway_PositionName.SelectedIndex = 0; } else { return; } //在绑定门岗完成后,绑定一个此门岗的最大通道值+1 int drid = int.Parse(cbxDriveway_PositionName.SelectedValue.ToString()); Expression <Func <Driveway, bool> > funuserinfo = p => p.Driveway_Position_ID == drid; DataTable dt = LinQBaseDao.Query("select MAX(Driveway_Value) from Driveway where Driveway_Position_ID=" + drid).Tables[0]; if (dt.Rows.Count > 0) { int num = Convert.ToInt32(dt.Rows[0][0].ToString()); txtDriveway_Value.Text = "0" + (num + 1).ToString(); } boo = true; } catch { CommonalityEntity.WriteTextLog("DrivewayFrom .BindPositionName()"); } }