public void loadStationHead(string addList, Size size, StationMakeupVspanel smv, int headDisplayType) { DataSet ds = stationBLL.GetRTStationHeadInfo(addList, headDisplayType); DataTable dt = ds.Tables[0]; DataRow[] dr = dt.Select("StationAddress=" + smv.StationAddress.ToString()); int rows = dr.GetLength(0) / 2; for (int i = 0, j = 1; i < dr.GetLength(0); i += 2, j++) { PanelStationHeadInfo pshi = null; // 如果存在修改信息 if (smv.Controls.Count == rows + 1) { pshi = (PanelStationHeadInfo)smv.Controls[j]; pshi.MouseHover += new EventHandler(pshi_MouseHover); this.loadStationHeadInfo(pshi, size, dr[i], dr[i + 1], headDisplayType, addList); }// 接收器控件少于得到的接收器信息数添加接收器控件 else if (smv.Controls.Count < rows + 1) { pshi = new PanelStationHeadInfo(); pshi.MouseHover += new EventHandler(pshi_MouseHover); pshi.MouseClick += new MouseEventHandler(pshi_MouseClick); //加载 MouseClick 事件 smv.Controls.Add(this.loadStationHeadInfo(pshi, size, dr[i], dr[i + 1], headDisplayType, addList)); } } dt.Dispose(); ds.Dispose(); }
// 添加接收器 private void loadStationHead(string addList) { DataSet ds = stationBLL.GetRTStationHeadInfo(addList, headDisplayType); if (ds != null && ds.Tables.Count > 0) { DataTable dt = ds.Tables[0]; foreach (Control ctl in vspStationInfo.Controls) { if (ctl.Controls.Count > 1) { StationMakeupVspanel smv = (StationMakeupVspanel)ctl; DataRow[] dr = dt.Select("StationAddress=" + smv.StationAddress.ToString()); PanelStationHeadInfo pshi = null; if (smv.Controls.Count == dr.GetLength(0) / 2 + 1) { for (int i = 0, j = 1; i < dr.GetLength(0); i += 2, j++) { pshi = (PanelStationHeadInfo)smv.Controls[j]; loadStationHeadInfo(pshi, size, dr[i], dr[i + 1], headDisplayType, smv.StationAddress.ToString()); } } else { // 清空 for (int i = smv.Controls.Count - 1; i > 0; i--) { smv.Controls[i].Dispose(); } // 重新加载 for (int j = 0; j < dr.GetLength(0); j += 2) { pshi = new PanelStationHeadInfo(); pshi.MouseClick += new MouseEventHandler(pshi_MouseClick); //添加接收器后,在主界面中加载接收器时,加载点击事件 smv.Controls.Add(loadStationHeadInfo(pshi, size, dr[j], dr[j + 1], headDisplayType, smv.StationAddress.ToString())); } } } } dt.Dispose(); ds.Dispose(); } }
// 加载分站下的接收器信息 public PanelStationHeadInfo loadStationHeadInfo(PanelStationHeadInfo pshi, Size size, DataRow dr1, DataRow dr2, int headDisplayType, string strStaAddress) { pshi.Cursor = System.Windows.Forms.Cursors.Hand; pshi.Height = size.Height; pshi.Width = size.Width; pshi.SetBackGroundGradineMode = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal; if (dr1["StationHeadState"].ToString() == "-1000") { pshi.Enabled = false; SetLabelInfo(pshi.ValueStationHeadAddress, dr1["StationHeadAddress"].ToString() + "号 故障"); pshi.ValueStationHeadAddress.FieldColor = Color.Red; } else { pshi.Enabled = true; pshi.ValueStationHeadAddress.FieldColor = Color.Black; SetLabelInfo(pshi.ValueStationHeadAddress, dr1["StationHeadAddress"].ToString() + "号"); } string displayStr = "共 " + Convert.ToString(int.Parse(dr1["SumCard"].ToString()) + int.Parse(dr2["SumCard"].ToString())); string typeString = ""; switch (headDisplayType) { case 0: displayStr = displayStr + " 人"; typeString = " 人"; break; case 1: displayStr = displayStr + " 个"; typeString = " 个"; break; case 2: displayStr = displayStr + " 个"; typeString = " 个"; break; default: displayStr.ToString(); break; } string tempAntennaStr = dr1["HeadAntennaName"].ToString().Length == 0 ? "天线1" : dr1["HeadAntennaName"].ToString(); string AntennaAContent = tempAntennaStr + showAntennaString + ":"; tempAntennaStr = dr2["HeadAntennaName"].ToString().Length == 0 ? "天线2" : dr2["HeadAntennaName"].ToString(); string AntennaBContent = tempAntennaStr + showAntennaString + ":"; pshi.OldFA = AntennaAContent; pshi.OldFB = AntennaBContent; SetLabelInfo(pshi.ValueEnterTotalPerson, displayStr); SetLabelInfo(pshi.ValueStationHeadPlace, dr1["StationHeadPlace"].ToString()); SetLabelInfo(pshi.FieldAntennaA, AntennaAContent, new PointF(4, 80)); SetLabelInfo(pshi.FieldAntennaB, AntennaBContent, new PointF(4, 95)); //SetLabelInfo(pshi.ValueAntennaA, dr1["SumCard"].ToString() + typeString, new PointF(65, 80)); //SetLabelInfo(pshi.ValueAntennaB, dr2["SumCard"].ToString() + typeString, new PointF(65, 95)); SetLabelInfo(pshi.ValueAntennaA, dr1["SumCard"].ToString() + typeString, new PointF(pshi.Width - 48, 80)); SetLabelInfo(pshi.ValueAntennaB, dr2["SumCard"].ToString() + typeString, new PointF(pshi.Width - 48, 95)); pshi.StationAddress = strStaAddress; //记录该控件所加载的分站地址 pshi.StationHeadAddress = dr1["StationHeadAddress"].ToString(); //记录该控件所加载的接收器地址 return pshi; }
/// <summary> /// 加载接收器列表信息 /// </summary> /// <param name="pIndex"></param> /// <param name="loadType">加载类型1是翻页</param> private void loadStationHeadList(int pIndex, int loadType) { DataSet ds = stationBLL.GetRTDisplayStationHeadInfo(pIndex - 1, ppageSum, headDisplayType); if (pIndex < 1) { MessageBox.Show("您输入的页数超出范围,请正确输入页数"); return; } if (ds.Tables != null && ds.Tables.Count > 0) { // 重新设置页数 int sumPage = int.Parse(ds.Tables[1].Rows[0][0].ToString()); sumPage = sumPage % ppageSum != 0 ? sumPage / ppageSum + 1 : sumPage / ppageSum; //if (ds.Tables[0].Rows.Count <= 0) if (!cpUp.Enabled) { cpUp.Enabled = true; cpUp.SetCaptionPanelStyle = CaptionPanelStyleEnum.windowsStyle; } if (!cpDown.Enabled) { cpDown.Enabled = true; cpDown.SetCaptionPanelStyle = CaptionPanelStyleEnum.windowsStyle; } if (pIndex == 1) { // 只有一页时 if (sumPage <= 1) { //vspStationInfo.Controls.Clear(); pageControlsVisible(false); } else { pageControlsVisible(true); cpUp.Enabled = false; cpUp.SetCaptionPanelStyle = CaptionPanelStyleEnum.UnEnableWindowsStyle; } } else if (pIndex == sumPage) { cpDown.Enabled = false; // 最后一页 cpDown.SetCaptionPanelStyle = CaptionPanelStyleEnum.UnEnableWindowsStyle; } else if (pIndex > sumPage || pIndex < 1) { // 大于最后一页 MessageBox.Show("您输入的页数超出范围,请正确输入页数"); return; } txtPage.CaptionTitle = pIndex.ToString(); lblSumPage.CaptionTitle = "/" + sumPage + "页"; DataTable dt = ds.Tables[0]; if (ds.Tables[0].Rows.Count > 0) { PanelStationHeadInfo pshi = null; if (vspStationInfo.Controls.Count == ds.Tables[0].Rows.Count) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { pshi = (PanelStationHeadInfo)vspStationInfo.Controls[i]; pshi.MouseHover += new EventHandler(pshi_MouseHover); loadDisplayStationHeadInfo(pshi, size, ds.Tables[0].Rows[i], headDisplayType); } } else { // 清空 for (int i = vspStationInfo.Controls.Count - 1; i >= 0; i--) { vspStationInfo.Controls[i].Dispose(); } // 重新加载 for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { pshi = new PanelStationHeadInfo(); pshi.MouseHover += new EventHandler(pshi_MouseHover); pshi.MouseClick += new MouseEventHandler(pshi_MouseClick); vspStationInfo.Controls.Add(loadDisplayStationHeadInfo(pshi, size, ds.Tables[0].Rows[j], headDisplayType)); } } } dt.Dispose(); } else { pageControlsVisible(false); } ds.Dispose(); }
/// 添加接收器 private void addPanelStationHeadInfo(StationMakeupVspanel smv,DataRow drStationHead) { shAddStationTitle.CaptionTitle = "添加" + KJ128NDataBase.HardwareName.Value(KJ128NDataBase.CorpsName.StaHead) + "信息"; PanelStationHeadInfo pshi_one = new PanelStationHeadInfo(); pshi_one.MouseHover += pshi_one_MouseHover; pshi_one.ValueEnterTotalPerson.FieldName = ""; pshi_one.Height = 84; pshi_one.Width = 120; pshi_one.SetBackGroundGradineMode = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal; pshi_one.ContextMenuStrip = cmsStationHand; pshi_one.MouseDown += new MouseEventHandler(pshi_one_MouseDown); pshi_one.Click += new EventHandler(pshi_one_Click); //tag保存接收器唯一表示列 pshi_one.Tag = drStationHead["StationHeadID"].ToString(); LabelInfo stationHeadAddress = pshi_one.ValueStationHeadAddress; // 赋值接收器地址号 stationHeadAddress.FieldName = drStationHead["StationHeadAddress"].ToString(); pshi_one.ValueStationHeadAddress = stationHeadAddress; //赋值接收器安装位置 LabelInfo l = new LabelInfo("进入总人数", new PointF(4, 60)); l.FieldName = "安装位置:" + drStationHead["StationHeadPlace"].ToString(); pshi_one.ValueStationHeadPlace = l; smv.Controls.Add(pshi_one); //vspAddNewStation.Visible = false; }