// 分站信息显示 private void AddStationInfo(int pIndex, int loadType) { DataSet ds = stationBLL.GetRTStationInfo(pIndex - 1, ppageSum, displayType); 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()); try { sumPage = sumPage % ppageSum != 0 ? sumPage / ppageSum + 1 : sumPage / ppageSum; } catch { ppageSum = 20; sumPage = sumPage % ppageSum != 0 ? sumPage / ppageSum + 1 : sumPage / ppageSum; // 弹出错误消息,让用户重新填写某个配置 MessageBox.Show("主界面显示设置配置有误,请检查配置后重新配置!"); } //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) { // 大于最后一页 AddStationInfo(sumPage, 1); return; } //cpSumCount.CaptionTitle = "共" + ds.Tables[1].Rows[0][0].ToString() + "条/本页" + ds.Tables[0].Rows.Count.ToString() + "条"; cpSumCount.CaptionTitle = "共" + ds.Tables[1].Rows[0][0].ToString() + "条"; txtPage.CaptionTitle = pIndex.ToString(); lblSumPage.CaptionTitle = "/" + sumPage + "页"; if (displayFun == 1) { if (loadType == 1) { if (vspStationInfo.Controls.Count > 1) { vspStationInfo.Controls.Clear(); } } PanelStationInfo psi = null; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (vspStationInfo.Controls.Count > i) { if (vspStationInfo.Controls[i] != null) { psi = (PanelStationInfo)vspStationInfo.Controls[i]; psi = loadDisplayStationInfo(psi, ds.Tables[0].Rows[i], displayType); vspStationInfo.Anchor = ((AnchorStyles.Left) | (AnchorStyles.Right) | (AnchorStyles.Top)); } } else { psi = new PanelStationInfo(); vspStationInfo.Anchor = ((AnchorStyles.Left) | (AnchorStyles.Right) | (AnchorStyles.Top)); psi = loadDisplayStationInfo(psi, ds.Tables[0].Rows[i], displayType); vspStationInfo.Controls.Add(psi); } } } else if (displayFun == 3) { StationMakeupVspanel smvpSingleStation = null; if (vspStationInfo.Controls.Count != ds.Tables[0].Rows.Count) { vspStationInfo.Controls.Clear(); } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (vspStationInfo.Controls.Count > i) { if (vspStationInfo.Controls[i] != null) { smvpSingleStation = (StationMakeupVspanel)vspStationInfo.Controls[i]; smvpSingleStation = loadStationInfo(smvpSingleStation, ds.Tables[0].Rows[i], displayType); vspStationInfo.Anchor = ((AnchorStyles.Left) | (AnchorStyles.Right) | (AnchorStyles.Top)); } } else { smvpSingleStation = new StationMakeupVspanel(); smvpSingleStation.ShiftButtonMouseClick += new EventHandler(smvpSingleStation_ShiftButtonMouseClick); vspStationInfo.Anchor = ((AnchorStyles.Left) | (AnchorStyles.Right) | (AnchorStyles.Top)); smvpSingleStation = loadStationInfo(smvpSingleStation, ds.Tables[0].Rows[i], displayType); vspStationInfo.Controls.Add(smvpSingleStation); } } } } else { pageControlsVisible(false); } }
public PanelStationInfo loadDisplayStationInfo(PanelStationInfo pshi, DataRow dr, int headDisplayType) { pshi.Cursor = System.Windows.Forms.Cursors.Hand; pshi.Height = 120; pshi.Width = 125; pshi.SetBackGroundGradineMode = System.Drawing.Drawing2D.LinearGradientMode.BackwardDiagonal; SetLabelInfo(pshi.FieldStationAddress, "传输分站编号:"); if (dr["StationState"].ToString() == "-1000") { pshi.Enabled = false; pshi.ValueStationAddress.FieldColor = Color.Red; SetLabelInfo(pshi.ValueStationAddress, dr["StationAddress"].ToString() + "号 故障"); } else { pshi.Enabled = true; pshi.ValueStationAddress.FieldColor = Color.Black; SetLabelInfo(pshi.ValueStationAddress, dr["StationAddress"].ToString() + "号"); } string displayStr = "共 " + Convert.ToString(int.Parse(dr["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; } SetLabelInfo(pshi.ValueEnterTotalPerson, displayStr); SetLabelInfo(pshi.ValueStationHeadPlace, "安装位置:" + dr["StationPlace"].ToString()); pshi.MouseClick += new MouseEventHandler(pshi_Sta_MouseClick); return pshi; }