/// <summary> /// 更多选项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lblMore_Click(object sender, EventArgs e) { try { chkList.Items.Clear(); chkList.Visible = true; btnOK.Visible = true; btnCel.Visible = true; //获取所有的字段信息。 List <string> lists = PositionLEDDAL.GetLEDShow("GetLEDView", "View_ShowLED"); foreach (var item in lists) { //去掉重复的字段 if (item == "车牌号" || item == "排队号" || item == "车辆类型") { continue; } //去掉英文字段 System.Text.RegularExpressions.Regex chk = new System.Text.RegularExpressions.Regex(@"[a-z]"); if (chk.IsMatch(item)) { continue; } chkList.Items.Add(item); } } catch { } }
/// <summary> /// 验证LED设置状态是否重复 /// </summary> /// <returns></returns> public bool ChkPositionLEDState() { bool chkState = false; try { string sql = ""; if (isUpdate == 0) { sql = "Select * from PositionLED where PositionLED_State='启动' and PositionLED_id!=" + int.Parse(this.lvwUserList.SelectedRows[0].Cells["PositionLED_id"].Value.ToString()) + " and PositionLED_Position_ID = " + chkPositionLED_Position_Id.SelectedValue + ""; } else if (isUpdate == -1) { sql = "Select * from PositionLED where PositionLED_State='启动' and PositionLED_id!=" + int.Parse(this.lvwUserList.SelectedRows[0].Cells["PositionLED_id"].Value.ToString()) + " and PositionLED_Position_ID = " + int.Parse(this.lvwUserList.SelectedRows[0].Cells["PositionLED_Position_ID"].Value.ToString()) + ""; } else { sql = "Select * from PositionLED where PositionLED_State='启动' and PositionLED_Position_ID = " + chkPositionLED_Position_Id.SelectedValue + ""; } chkState = PositionLEDDAL.ChkPositionLEDState(sql); } catch { CommonalityEntity.WriteTextLog("LEDSetForm ChkPositionLEDState()"); } return(chkState); }
/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { try { if (this.lvwUserList.SelectedRows.Count <= 0) { MessageBox.Show("请选择要删除的项!"); return; } if (this.lvwUserList.SelectedRows[0].Cells["PositionLED_ID"].Value.ToString() == "") { MessageBox.Show("请选择要删除的项!"); return; } for (int i = 0; i < this.lvwUserList.SelectedRows.Count; i++) { if (this.lvwUserList.SelectedRows[i].Cells["PositionLED_State"].Value.ToString() == "启动") { MessageBox.Show("启动状态的LED设置,不能删除!"); return; } //删除条件 int positionled_id = int.Parse(this.lvwUserList.SelectedRows[i].Cells["positionLED_ID"].Value.ToString()); Expression <Func <PositionLED, bool> > fun = n => n.PositionLED_ID == positionled_id; PositionLEDDAL.DeletePositionLED(fun); CommonalityEntity.WriteLogData("删除", "删除编号为:" + positionled_id + "的LED显示信息", CommonalityEntity.USERNAME);//添加操作日志 } } catch { CommonalityEntity.WriteTextLog("LEDSetForm btnDelete_Click()"); } finally { GetGriddataviewLoad("");//加载 } }
/// <summary> /// 保存用户操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { try { isUpdate = 1; if (!ChkContent()) { return; } //判断是否修改 //添加数据到数据库 PositionLED pLED = new PositionLED(); #region 获取页面的数据 pLED.PositionLED_Position_ID = int.Parse(chkPositionLED_Position_Id.SelectedValue.ToString()); if (cboleixing.Text == "排队信息") { pLED.PositionLED_Type = 1; } else if (cboleixing.Text == "欢迎语") { pLED.PositionLED_Type = 2; } pLED.PositionLED_ScreenHeight = int.Parse(txtPositionLED_ScreenHeight.Text.Trim()); pLED.PositionLED_ScreenWeight = int.Parse(txtPositionLED_ScreenWeight.Text.Trim()); pLED.PositionLED_X = int.Parse(txtPositionLED_X.Text.Trim()); pLED.PositionLED_Y = int.Parse(txtPositionLED_Y.Text.Trim()); pLED.PositionLED_Count = int.Parse(cbotiaoshu.Text.Trim()); pLED.PositionLED_Remark = txtPositionLED_Remark.Text.Trim(); //pLED.PositionLED_PassageState = chkboxLEDPassState.Text.ToString(); //保存选择的字体设置项目 pLED.PositionLED_Font = fontdlgFont.Font.Name.ToString(); pLED.PositionLED_FontSize = fontdlgFont.Font.Size.ToString(); pLED.PositionLED_Color = colordlgFont.Color.ToString(); if (cboleixing.Text == "欢迎语") { pLED.PositionLED_Content = ""; pLED.PositionLED_Operate = CommonalityEntity.USERNAME; pLED.PositionLED_Time = CommonalityEntity.GetServersTime(); #endregion pLED.PositionLED_State = chkboxLEDState.Text.Trim(); if (chkboxLEDState.Text.Trim() == "启动") { if (ChkPositionLEDState()) { DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.OK) { //修改条件 Expression <Func <PositionLED, bool> > fun = n => n.PositionLED_State == "启动" && n.PositionLED_Position_ID == int.Parse(chkPositionLED_Position_Id.SelectedValue.ToString()); //需要修改的内容 Action <PositionLED> action = p => { p.PositionLED_State = "暂停"; }; //执行更新 PositionLEDDAL.UpdatePositionLED(fun, action); PositionLEDDAL.InsertPositionLED(pLED); } else { pLED.PositionLED_State = "暂停"; PositionLEDDAL.InsertPositionLED(pLED); } } else { PositionLEDDAL.InsertPositionLED(pLED); } } else { PositionLEDDAL.InsertPositionLED(pLED); } DataTable dt = dt = LinQBaseDao.Query("select PositionLED_ID,PositionLED_State from PositionLED order by PositionLED_ID desc").Tables[0]; string positionled_id = dt.Rows[0][0].ToString(); string state = dt.Rows[0][1].ToString(); if (state == "启动") { CommonalityEntity.WriteLogData("新增", "新增并启动编号为:" + positionled_id + "的LED显示信息", CommonalityEntity.USERNAME);//添加操作日志 } else { CommonalityEntity.WriteLogData("新增", "新增编号为:" + positionled_id + "的LED显示信息", CommonalityEntity.USERNAME);//添加操作日志 } } else if (cboleixing.Text == "排队信息") { string serialnumber = ""; string carType = ""; string carNumber = ""; if (chkCarNumber.Checked) { carNumber = chkCarNumber.Text.Trim() + ","; } if (chkCarType.Checked) { carType = chkCarType.Text.Trim() + ","; } if (chkSerialnumber.Checked) { serialnumber = "distinct(" + chkSerialnumber.Text.Trim() + "),"; } string chklists = ""; if (list.Count() > 1) { foreach (var item in list) { chklists += (item.ToString() + ","); } list.Clear(); } string listsql = serialnumber + carNumber + carType + chklists; listsql = listsql.TrimEnd(','); //限定选择的显示内容只能为3个 string[] split = listsql.Split(','); int num = 0; for (int i = 0; i < split.Length; i++) { num++; } if (num > 3) { MessageBox.Show("排队信息显示的项目最多选择3项", "错误提示"); return; } else { string sql = "Select " + listsql + " from View_LEDShow_zj"; pLED.PositionLED_Content = sql; pLED.PositionLED_Operate = CommonalityEntity.USERNAME; pLED.PositionLED_Time = CommonalityEntity.GetServersTime(); pLED.PositionLED_State = chkboxLEDState.Text.Trim(); if (chkboxLEDState.Text.Trim() == "启动") { if (ChkPositionLEDState()) { DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.OK) { //修改条件 Expression <Func <PositionLED, bool> > fun = n => n.PositionLED_State == "启动" && n.PositionLED_Position_ID == int.Parse(chkPositionLED_Position_Id.SelectedValue.ToString()); //需要修改的内容 Action <PositionLED> action = p => { p.PositionLED_State = "暂停"; }; //执行更新 PositionLEDDAL.UpdatePositionLED(fun, action); PositionLEDDAL.InsertPositionLED(pLED); } else { pLED.PositionLED_State = "暂停"; PositionLEDDAL.InsertPositionLED(pLED); } } else { PositionLEDDAL.InsertPositionLED(pLED); } } else { PositionLEDDAL.InsertPositionLED(pLED); } DataTable dt = dt = LinQBaseDao.Query("select PositionLED_ID,PositionLED_State from PositionLED order by PositionLED_ID desc").Tables[0]; string positionled_id = dt.Rows[0][0].ToString(); string state = dt.Rows[0][1].ToString(); if (state == "启动") { CommonalityEntity.WriteLogData("新增", "新增并启动编号为:" + positionled_id + "的LED显示信息", CommonalityEntity.USERNAME);//添加操作日志 } else { CommonalityEntity.WriteLogData("新增", "新增编号为:" + positionled_id + "的LED显示信息", CommonalityEntity.USERNAME);//添加操作日志 } } } } catch { //记录错误日志 CommonalityEntity.WriteTextLog("LEDSetForm btnAdd_Click()"); } finally { GetGriddataviewLoad("");//绑定列表 Empty(); } }
/// <summary> /// 应用当前选中的LED设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLEDApplication_Click(object sender, EventArgs e) { try { CommonalityEntity.IsCancellation = false; isUpdate = -1; if (ChkPositionLEDState()) { DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.OK) { //修改条件 Expression <Func <PositionLED, bool> > funs = n => n.PositionLED_State == "启动" && n.PositionLED_Position_ID == int.Parse(this.lvwUserList.SelectedRows[0].Cells["PositionLED_Position_ID"].Value.ToString()); //需要修改的内容 Action <PositionLED> actions = p => { p.PositionLED_State = "暂停"; }; //执行更新 PositionLEDDAL.UpdatePositionLED(funs, actions); //应用当前选中的设置 //条件 int id = int.Parse(this.lvwUserList.SelectedRows[0].Cells["PositionLED_ID"].Value.ToString()); Expression <Func <PositionLED, bool> > fun = n => n.PositionLED_ID == id; //需要的内容 Action <PositionLED> action = p => { p.PositionLED_State = "启动"; }; //执行更新 PositionLEDDAL.UpdatePositionLED(fun, action); CommonalityEntity.WriteLogData("修改", "启动编号为:" + id + "的LED显示信息", CommonalityEntity.USERNAME);//操作日志 } else { return; } } else { //应用当前选中的设置 //条件 int id = int.Parse(this.lvwUserList.SelectedRows[0].Cells["PositionLED_ID"].Value.ToString()); Expression <Func <PositionLED, bool> > fun = n => n.PositionLED_ID == id; //需要的内容 Action <PositionLED> action = p => { p.PositionLED_State = "启动"; }; //执行更新 PositionLEDDAL.UpdatePositionLED(fun, action); CommonalityEntity.WriteLogData("修改", "启动编号为:" + id + "的LED显示信息", CommonalityEntity.USERNAME);//操作日志 } } catch { CommonalityEntity.WriteTextLog("LEDSerForm btnLEDApplication_Click()"); } finally { GetGriddataviewLoad("");//加载 } }
/// <summary> /// 选中列表中的项进行修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { try { if (this.lvwUserList.SelectedRows.Count <= 0) { MessageBox.Show("请选择要修改的项!"); return; } else if (!ChkContent()) { return; } //修改条件 Expression <Func <PositionLED, bool> > fun = n => n.PositionLED_ID == int.Parse(this.lvwUserList.SelectedRows[0].Cells["PositionLED_ID"].Value.ToString()); string positionLED_State = chkboxLEDState.Text.Trim(); if (chkboxLEDState.Text.Trim() == "启动") { if (ChkPositionLEDState()) { DialogResult dlgResult = MessageBox.Show("已经存在启动状态的设置,是否替换?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.OK) { //修改条件 Expression <Func <PositionLED, bool> > funs = n => n.PositionLED_State == "启动" && n.PositionLED_Position_ID == int.Parse(this.lvwUserList.SelectedRows[0].Cells["PositionLED_Position_ID"].Value.ToString()); //需要修改的内容 Action <PositionLED> actions = p => { p.PositionLED_State = "暂停"; }; //执行更新 PositionLEDDAL.UpdatePositionLED(funs, actions); } else { return; } } } string id = ""; string strfront = ""; string strcontent = ""; //需要修改的内容 Action <PositionLED> action = pLED => { strfront = pLED.PositionLED_Position_ID + "," + pLED.PositionLED_ScreenHeight + "," + pLED.PositionLED_ScreenWeight + "," + pLED.PositionLED_X + "," + pLED.PositionLED_Y + "," + pLED.PositionLED_IntervalX + "," + pLED.PositionLED_IntervalY + "," + pLED.PositionLED_Count + "," + pLED.PositionLED_Remark + "," + pLED.PositionLED_State + "," + pLED.PositionLED_Font + "," + pLED.PositionLED_FontSize + "," + pLED.PositionLED_Color + "," + pLED.PositionLED_Content; pLED.PositionLED_Position_ID = int.Parse(chkPositionLED_Position_Id.SelectedValue.ToString()); if (cboleixing.Text == "排队信息") { pLED.PositionLED_Type = 1; } else if (cboleixing.Text == "欢迎语") { pLED.PositionLED_Type = 2; } pLED.PositionLED_ScreenHeight = int.Parse(txtPositionLED_ScreenHeight.Text.Trim()); pLED.PositionLED_ScreenWeight = int.Parse(txtPositionLED_ScreenWeight.Text.Trim()); pLED.PositionLED_X = int.Parse(txtPositionLED_X.Text.Trim()); pLED.PositionLED_Y = int.Parse(txtPositionLED_Y.Text.Trim()); pLED.PositionLED_Count = int.Parse(cbotiaoshu.Text.Trim()); pLED.PositionLED_Remark = txtPositionLED_Remark.Text.Trim(); //pLED.PositionLED_PassageState = chkboxLEDPassState.Text.ToString(); pLED.PositionLED_State = chkboxLEDState.Text.Trim(); pLED.PositionLED_Font = fontdlgFont.Font.Name.ToString(); pLED.PositionLED_FontSize = fontdlgFont.Font.Size.ToString(); pLED.PositionLED_Color = colordlgFont.Color.ToString(); string userialnumber = ""; string ucarType = ""; string ucarNumber = ""; if (chkCarNumber.Checked) { ucarNumber = chkCarNumber.Text.Trim() + ","; } if (chkCarType.Checked) { ucarType = chkCarType.Text.Trim() + ","; } if (chkSerialnumber.Checked) { userialnumber = "distinct(" + chkSerialnumber.Text.Trim() + "),"; } string uchklists = ""; if (list.Count() > 0) { foreach (var item in list) { uchklists += (item.ToString() + ","); } list.Clear(); } string ulistsql = userialnumber + ucarNumber + ucarType + uchklists; string sql = "Select " + ulistsql.TrimEnd(',') + " from View_LEDShow_zj"; pLED.PositionLED_Content = sql; strcontent = pLED.PositionLED_Position_ID + "," + pLED.PositionLED_ScreenHeight + "," + pLED.PositionLED_ScreenWeight + "," + pLED.PositionLED_X + "," + pLED.PositionLED_Y + "," + pLED.PositionLED_IntervalX + "," + pLED.PositionLED_IntervalY + "," + pLED.PositionLED_Count + "," + pLED.PositionLED_Remark + "," + pLED.PositionLED_State + "," + pLED.PositionLED_Font + "," + pLED.PositionLED_FontSize + "," + pLED.PositionLED_Color + "," + pLED.PositionLED_Content; id = pLED.PositionLED_ID.ToString(); }; //执行更新 PositionLEDDAL.UpdatePositionLED(fun, action); CommonalityEntity.WriteLogData("修改", "更新编号为:" + id + "的LED显示信息,修改前:" + strfront + ";修改后:" + strcontent, CommonalityEntity.USERNAME); btnUpdate.Enabled = false; btnAdd.Enabled = true; } catch { //记录错误日志 CommonalityEntity.WriteTextLog("LEDSetForm btnAdd_Click()"); } finally { GetGriddataviewLoad("");//绑定列表 Empty(); } }
/// <summary> /// 加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LEDPreviewForm_Load(object sender, EventArgs e) { try { DataTable dts = LinQBaseDao.Query("select CarType_ID,CarType_DriSName from CarType where CarType_State='启动'").Tables[0]; if (dts.Rows.Count > 0) { for (int i = 0; i < dts.Rows.Count; i++) { int kk = Convert.ToInt32(LinQBaseDao.GetSingle("select count(0) from ManagementStrategy where ManagementStrategy_DriSName='" + dts.Rows[i][1].ToString() + "' and ManagementStrategy_ControlInfo_ID in(select ControlInfo_ID from ControlInfo where ControlInfo_Name='排队') and ManagementStrategy_State='启动' ").ToString()); if (kk == 0) { cartypeid += dts.Rows[i][0].ToString() + ","; } } } cartypeid = cartypeid.TrimEnd(','); //读取LED配置项 string sql = "select * from PositionLED where PositionLED_State='启动' and PositionLED_Position_ID=" + SystemClass.PositionID + ""; pled = PositionLEDDAL.GetLED(sql); //加载时将窗体显示位置修改到指定位置 int X = Convert.ToInt32(pled.PositionLED_X); int Y = Convert.ToInt32(pled.PositionLED_Y); this.Location = new Point(X, Y); fontsize = Convert.ToInt32(pled.PositionLED_FontSize); //判断当前门岗是否有LED的配置信息 if (pled.PositionLED_ID <= 0) { lbltishi.Visible = true; lblleixingting.Visible = false; lblleixingzhi.Visible = false; lblChePaiting.Visible = false; lblpaiduihaoting.Visible = false; lblMenGangting.Visible = false; lblTongDaoting.Visible = false; lbltishi.Text = "当前登录门岗\r\n暂无LED显示配置信息,\r\n请先配置对应门岗显示信息!!!"; return; } else { try { //读取配置的高宽(高度与宽度是反的) int weight = Convert.ToInt32(pled.PositionLED_ScreenWeight); int heifht = Convert.ToInt32(pled.PositionLED_ScreenHeight); this.Size = new Size(weight, heifht); //读取配置的字体颜色 string s = pled.PositionLED_Color; int cd = s.Length - 8; yanse = s.Substring(7, cd); if (pled.PositionLED_Type == 1) { timer1.Enabled = true; BindCountting(); BindTypeting(); Bindting(); } else if (pled.PositionLED_Type == 2) { lblhuanyingyu.Visible = true; lblleixingting.Visible = false; lblleixingzhi.Visible = false; lblChePaiting.Visible = false; lblpaiduihaoting.Visible = false; lblMenGangting.Visible = false; lblTongDaoting.Visible = false; lblhuanyingyu.Text = pled.PositionLED_Remark.ToString(); return; } } catch { //将类型的循环标识加1 typecountting = typecountting + 1; if (typecountting >= typeting) { typecountting = 0; } BindTypeting(); Bindting(); } } } catch { } }
/// <summary> /// 加载 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LEDPreviewForm_Load(object sender, EventArgs e) { //读取LED配置项 string sql = "select * from PositionLED where PositionLED_State='启动' and PositionLED_Position_ID=" + SystemClass.PositionID + ""; pLED = PositionLEDDAL.GetLED(sql); //加载时将窗体显示位置修改到指定位置 int X = Convert.ToInt32(pLED.PositionLED_X); int Y = Convert.ToInt32(pLED.PositionLED_Y); this.Location = new Point(X, Y); //判断当前门岗是否有LED的配置信息 if (pLED.PositionLED_ID <= 0) { lbltishi.Visible = true; lbltishi.Text = "当前登录门岗\r\n暂无LED显示配置信息,\r\n请先配置对应门岗显示信息"; return; } else { DataTable dts = LinQBaseDao.Query("select CarType_ID from CarType where CarType_State='启动'").Tables[0]; if (dts.Rows.Count > 0) { for (int i = 0; i < dts.Rows.Count; i++) { // and ManagementStrategy_State='启动' int kk = Convert.ToInt32(LinQBaseDao.GetSingle("select count(0) from ManagementStrategy where ManagementStrategy_CarType_ID=" + dts.Rows[i][0].ToString() + " and ManagementStrategy_ControlInfo_ID in(select ControlInfo_ID from ControlInfo where ControlInfo_Name='排队')").ToString()); if (kk == 0) { cartypeid += dts.Rows[i][0].ToString() + ","; } } } cartypeid = cartypeid.TrimEnd(','); //读取配置的高宽(高度与宽度是反的) int weight = Convert.ToInt32(pLED.PositionLED_ScreenWeight); int heifht = Convert.ToInt32(pLED.PositionLED_ScreenHeight); this.Size = new Size(weight, heifht); //读取配置的字体颜色 string s = pLED.PositionLED_Color; int cd = s.Length - 8; yanse = s.Substring(7, cd); if (pLED.PositionLED_Type == 1)//1为显示排队信息 { try { BindCount(); if (type == 0) { lbltishi.Visible = true; lbltishi.Text = "一级防火单位,严禁将烟火带入厂区,否则引发事故将移送公安机关处理!!!"; } else { BindType(); timer1.Enabled = false; //将刷类型的闹钟关闭 lbltishi.Visible = false; //将提示语的LBL关闭 TimerLED.Enabled = true; //只有在显示排队信息时才将闹钟打开 } } catch { count = count + 1; if (count == type) { count = 0; } BindType(); } } else if (pLED.PositionLED_Type == 2)//2为显示欢迎语 { lblhuanyingyu.Visible = true; lblhuanyingyu.Text = pLED.PositionLED_Remark; } } }
/// <summary> /// 加载显示内容 /// </summary> private void BindType() { try { //绑定车辆类型 string carType_Name = ""; string carType_Id = ""; string cattype_value = ""; if (dataset.Tables[0].Rows.Count > 0) { carType_Name = dataset.Tables[0].Rows[count]["CarType_Name"].ToString(); carType_Id = dataset.Tables[0].Rows[count]["CarType_ID"].ToString(); cattype_value = dataset.Tables[0].Rows[count]["CarType_Value"].ToString(); } else { return; } //绑定车辆通道 DataSet datasettongdao = PositionLEDDAL.GetCarType(" select Driveway_Name from Driveway where Driveway_Position_ID=" + SystemClass.PositionID + " and Driveway_Value in( select top(1) SortNumberInfo_DrivewayValue from SortNumberInfo where SortNumberInfo_CarTypeValue='" + cattype_value + "' and (SortNumberInfo_DrivewayValue != '' and SortNumberInfo_DrivewayValue is not null) order by SortNumberInfo_ID desc)"); string tongDao = ""; int tongdaocount = datasettongdao.Tables[0].Rows.Count; if (tongdaocount > 0) { if (tongdaocount > 1) { for (int i = 0; i < tongdaocount; i++) { DataTable dttdcou = LinQBaseDao.Query("select count(*) from View_LEDShow_zj where 通道名称='" + datasettongdao.Tables[0].Rows[i]["Driveway_Name"].ToString() + "' and 通行状态='排队中' and 车辆类型='" + carType_Name + "' and 排队号 !=''").Tables[0]; if (dttdcou.Rows.Count > 0) { tongDao = datasettongdao.Tables[0].Rows[i]["Driveway_Name"].ToString(); } } } else { tongDao = datasettongdao.Tables[0].Rows[0]["Driveway_Name"].ToString(); } if (tongDao == "") { tongDao = datasettongdao.Tables[0].Rows[0]["Driveway_Name"].ToString(); } //在通道有的情况下才绑定类型与通道号,否则就跳出方法 lbltongdao.Text = tongDao; LblCarType.Text = carType_Name; } else { return; } //绑定通行中的车辆信息 string str = pLED.PositionLED_Content.Insert(pLED.PositionLED_Content.IndexOf("from"), ",SortNumberInfo_ID "); string carSql = str + " where 车辆类型='" + carType_Name + "' and 通行状态='待通行' and 通道类型='进' and SortNumberInfo_State='启动' and 通道名称='" + tongDao + "' and SortNumberInfo_PositionValue= '" + SystemClass.PosistionValue + "' and 排队号<>'' order by SortNumberInfo_ID"; DataSet dscartx = PositionLEDDAL.GetCarType(carSql); int n = dscartx.Tables[0].Rows.Count; int dscartxCount = int.Parse(pLED.PositionLED_Count.ToString());//设置显示数据条数 //如果查询出了存在正在通行的车辆,就绑定一个通行中的车辆 if (dscartx.Tables[0].Rows.Count > 0) { label1.ForeColor = Color.Green; label6.ForeColor = Color.Green; label11.ForeColor = Color.Green; label1.Text = "待通行"; label6.Text = dscartx.Tables[0].Rows[0][0].ToString(); label11.Text = dscartx.Tables[0].Rows[0][1].ToString(); dscartxCount = dscartxCount - 1; } //绑定待通行车辆 carSql = str + " where 车辆类型='" + carType_Name + "' and 通行状态='排队中' and 通道类型='进' and SortNumberInfo_State='启动' and 通道名称='" + tongDao + "' and SortNumberInfo_PositionValue = '" + SystemClass.PosistionValue + "' and 排队号<>'' order by SortNumberInfo_ID"; DataSet dscar = PositionLEDDAL.GetCarType(carSql); int m = dscar.Tables[0].Rows.Count; #region 跟据显示的条数进行启用或者是禁用LABEL //此处是绑定待通行的车辆 if (dscar.Tables[0].Rows.Count > 0) { if (label1.Text == "")//如果没有通行中的车辆,就绑定5个全为待通行 { //循环修改颜色 foreach (Control item in this.Controls) { if (item is Label && item.Name != "LblCarType" && item.Name != "lbltongdao") { item.ForeColor = Color.FromName(yanse); } } if (dscar.Tables[0].Rows.Count == 1 && (dscartxCount == 1 || dscartxCount >= 1)) { label1.Text = "排队中"; label6.Text = dscar.Tables[0].Rows[0][0].ToString(); label11.Text = dscar.Tables[0].Rows[0][1].ToString(); } else if (dscar.Tables[0].Rows.Count == 2 && (dscartxCount == 2 || dscartxCount >= 2)) { label1.Text = "排队中"; label6.Text = dscar.Tables[0].Rows[0][0].ToString(); label11.Text = dscar.Tables[0].Rows[0][1].ToString(); label7.Text = dscar.Tables[0].Rows[1][0].ToString(); label12.Text = dscar.Tables[0].Rows[1][1].ToString(); } else if (dscar.Tables[0].Rows.Count == 3 && (dscartxCount == 3 || dscartxCount >= 3)) { label1.Text = "排队中"; label6.Text = dscar.Tables[0].Rows[0][0].ToString(); label11.Text = dscar.Tables[0].Rows[0][1].ToString(); label7.Text = dscar.Tables[0].Rows[1][0].ToString(); label12.Text = dscar.Tables[0].Rows[1][1].ToString(); label8.Text = dscar.Tables[0].Rows[2][0].ToString(); label13.Text = dscar.Tables[0].Rows[2][1].ToString(); } else if (dscar.Tables[0].Rows.Count == 4 && (dscartxCount == 4 || dscartxCount >= 4)) { label1.Text = "排队中"; label6.Text = dscar.Tables[0].Rows[0][0].ToString(); label11.Text = dscar.Tables[0].Rows[0][1].ToString(); label7.Text = dscar.Tables[0].Rows[1][0].ToString(); label12.Text = dscar.Tables[0].Rows[1][1].ToString(); label8.Text = dscar.Tables[0].Rows[2][0].ToString(); label13.Text = dscar.Tables[0].Rows[2][1].ToString(); label9.Text = dscar.Tables[0].Rows[3][0].ToString(); label14.Text = dscar.Tables[0].Rows[3][1].ToString(); } else if (dscar.Tables[0].Rows.Count >= 5 && dscartxCount == 5) { label1.Text = "排队中"; label6.Text = dscar.Tables[0].Rows[0][0].ToString(); label11.Text = dscar.Tables[0].Rows[0][1].ToString(); label7.Text = dscar.Tables[0].Rows[1][0].ToString(); label12.Text = dscar.Tables[0].Rows[1][1].ToString(); label8.Text = dscar.Tables[0].Rows[2][0].ToString(); label13.Text = dscar.Tables[0].Rows[2][1].ToString(); label9.Text = dscar.Tables[0].Rows[3][0].ToString(); label14.Text = dscar.Tables[0].Rows[3][1].ToString(); label10.Text = dscar.Tables[0].Rows[4][0].ToString(); label15.Text = dscar.Tables[0].Rows[4][1].ToString(); } } else { //循环修改颜色 foreach (Control item in this.Controls) { if (item is Label && item.Name != "LblCarType" && item.Name != "lbltongdao" && item.Name != "label7" && item.Name != "label12" && item.Name != "label1" && item.Name != "label6" && item.Name != "label11") { item.ForeColor = Color.FromName(yanse); } } //有通行中的车辆已绑定则绑定待通行 if (dscar.Tables[0].Rows.Count == 1 && (dscartxCount == 1 || dscartxCount >= 1)) { label2.Text = "排队中"; label7.Text = dscar.Tables[0].Rows[0][0].ToString(); label12.Text = dscar.Tables[0].Rows[0][1].ToString(); } if (dscar.Tables[0].Rows.Count == 2 && (dscartxCount == 2 || dscartxCount >= 2)) { label2.Text = "排队中"; label7.Text = dscar.Tables[0].Rows[0][0].ToString(); label12.Text = dscar.Tables[0].Rows[0][1].ToString(); label8.Text = dscar.Tables[0].Rows[1][0].ToString(); label13.Text = dscar.Tables[0].Rows[1][1].ToString(); } else if (dscar.Tables[0].Rows.Count == 3 && (dscartxCount == 3 || dscartxCount >= 3)) { label2.Text = "排队中"; label7.Text = dscar.Tables[0].Rows[0][0].ToString(); label12.Text = dscar.Tables[0].Rows[0][1].ToString(); label8.Text = dscar.Tables[0].Rows[1][0].ToString(); label13.Text = dscar.Tables[0].Rows[1][1].ToString(); label9.Text = dscar.Tables[0].Rows[2][0].ToString(); label14.Text = dscar.Tables[0].Rows[2][1].ToString(); } else if (dscar.Tables[0].Rows.Count >= 4 && dscartxCount >= 4) { label2.Text = "排队中"; label7.Text = dscar.Tables[0].Rows[0][0].ToString(); label12.Text = dscar.Tables[0].Rows[0][1].ToString(); label8.Text = dscar.Tables[0].Rows[1][0].ToString(); label13.Text = dscar.Tables[0].Rows[1][1].ToString(); label9.Text = dscar.Tables[0].Rows[2][0].ToString(); label14.Text = dscar.Tables[0].Rows[2][1].ToString(); label10.Text = dscar.Tables[0].Rows[3][0].ToString(); label15.Text = dscar.Tables[0].Rows[3][1].ToString(); } } } #endregion //控制类型与通道的循环变量 count = count + 1; if (count == type) { count = 0; } } catch { CommonalityEntity.WriteTextLog("LEDPreviewForm BindType()"); } }