Пример #1
0
        private void changGuiCheck_Load(object sender, EventArgs e)
        {
            string str = Application.StartupPath;//项目路径

            this.button1.BackgroundImage = Image.FromFile(@str + "/images/check.png");
            this.button2.BackgroundImage = Image.FromFile(@str + "/images/close.png");
            this.checkBox1.Checked       = false;

            this.tabControl1.TabPages[0].Controls.Clear();
            this.tabControl1.TabPages[1].Controls.Clear();
            //让默认的日期时间减一天
            this.dateTimePicker1.Value = this.dateTimePicker2.Value.AddDays(-1);
            //查询所有测点或主机编号信息
            service.changGuicheckService cgs = new service.changGuicheckService();
            DataTable dta = cgs.checkcedianAll(null).Tables[0];
            int       t   = dta.Rows.Count;

            if (t > 0)
            {
                CheckBox[] checkBox = new CheckBox[t];
                int        p        = 10;
                for (int i = 0; i < t; i++)
                {
                    checkBox[i]          = new CheckBox();
                    checkBox[i].AutoSize = true;
                    checkBox[i].Text     = dta.Rows[i]["terminalname"].ToString();
                    checkBox[i].Tag      = dta.Rows[i]["measureCode"] + "_" + dta.Rows[i]["meterNo"] + "-" + dta.Rows[i]["measureNo"];
                    checkBox[i].Location = new Point(10, p);
                    this.tabControl1.TabPages[0].Controls.Add(checkBox[i]);
                    p += 20;
                }
                checkBox[0].Checked = true;
            }

            service.manageHostService mhs = new service.manageHostService();
            DataTable dt1 = mhs.queryManageHost();
            int       t1  = dt1.Rows.Count;

            if (t1 > 0)
            {
                CheckBox[] checkBox = new CheckBox[t1];
                int        p1       = 10;
                for (int i = 0; i < t1; i++)
                {
                    checkBox[i]          = new CheckBox();
                    checkBox[i].AutoSize = true;
                    checkBox[i].Text     = dt1.Rows[i]["hostName"].ToString();
                    //checkBox[i].Tag = dt1.Rows[i]["measureCode"].ToString() + "_" + dt1.Rows[i]["storeType"];
                    checkBox[i].Tag      = dt1.Rows[i]["measureCode"].ToString() + "_" + dt1.Rows[i]["measureNo"];
                    checkBox[i].Location = new Point(10, p1);
                    checkBox[i].Click   += new EventHandler(Clickchecked);
                    this.tabControl1.TabPages[1].Controls.Add(checkBox[i]);
                    p1 += 20;
                }
                checkBox[0].Checked = true;
            }

            getFromXml();
        }
Пример #2
0
        private void querymanageHose()
        {
            DataTable dt = mhs.queryManageHost();

            if (dt != null && dt.Rows.Count > 0)
            {
                this.dataGridView1.DataSource                  = dt;
                this.dataGridView1.Columns[0].Visible          = false;
                this.dataGridView1.Columns[1].HeaderCell.Value = "管理主机名称";
                this.dataGridView1.Columns[2].Visible          = false;
                this.dataGridView1.Columns[3].HeaderCell.Value = "通信协议";
                this.dataGridView1.Columns[4].Visible          = false;

                this.dataGridView1.Columns[5].Visible = false;
                this.dataGridView1.Columns[6].Visible = false;

                this.dataGridView1.Columns[7].HeaderCell.Value  = "测点数量";
                this.dataGridView1.Columns[8].HeaderCell.Value  = "存储类型";
                this.dataGridView1.Columns[9].HeaderCell.Value  = "管理主机编号";
                this.dataGridView1.Columns[10].Visible          = false;
                this.dataGridView1.Columns[11].Visible          = false;
                this.dataGridView1.Columns[12].Visible          = false;
                this.dataGridView1.Columns[13].HeaderCell.Value = "所属库房";

                this.dataGridView1.Columns[14].Visible = false;
                this.dataGridView1.Columns[15].Visible = false;
                this.dataGridView1.Columns[16].Visible = false;

                this.dataGridView1.Columns[1].Width = 200;
                this.dataGridView1.Columns[3].Width = 200;
                this.dataGridView1.Columns[7].Width = 80;
                this.dataGridView1.Columns[9].Width = 200;
                this.dataGridView1.RowsDefaultCellStyle.ForeColor = Color.Black;
                //for (int count = 0; (count <= (this.dataGridView1.Rows.Count - 2)); count++)
                //{
                //    this.dataGridView1.Rows[count].HeaderCell.Value = String.Format("{0}", count + 1);
                //}
                this.dataGridView1.AllowUserToAddRows = false;
            }
            else
            {
                this.dataGridView1.DataSource = null;
            }
        }
Пример #3
0
        private void measurePointInsert_Load(object sender, EventArgs e)
        {
            string str = Application.StartupPath;//项目路径

            this.button1.BackgroundImage = Image.FromFile(@str + "/images/save.png");
            this.button2.BackgroundImage = Image.FromFile(@str + "/images/cancel.png");
            service.manageHostService mh = new service.manageHostService();
            DataTable dt1 = mh.queryManageHost();

            if (dt1.Rows.Count > 0)
            {
                this.comboBox1.DataSource    = dt1;           //绑定数据源
                this.comboBox1.DisplayMember = "hostName";    //显示给用户的数据集表项
                this.comboBox1.ValueMember   = "measureCode"; //操作时获取的值
            }
            service.houseTypeService hts = new service.houseTypeService();
            this.comboBox3.DataSource    = hts.queryhouseType(); //绑定数据源
            this.comboBox3.DisplayMember = "name";               //显示给用户的数据集表项
            this.comboBox3.ValueMember   = "id";                 //操作时获取的值
        }
Пример #4
0
        private void graphCheck_Load(object sender, EventArgs e)
        { //悬停工具提示事件
            chart1.GetToolTipText += new EventHandler <ToolTipEventArgs>(chart1_GetToolTipText);

            this.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.chart_MouseWheel);
            string str = Application.StartupPath;//项目路径

            this.button1.BackgroundImage = Image.FromFile(@str + "/images/check.png");
            //让默认的日期时间减一天
            this.dateTimePicker1.Value = this.dateTimePicker2.Value.AddDays(-1);
            //查询主机编号信息
            service.manageHostService mhs = new service.manageHostService();
            DataTable dt1 = mhs.queryManageHost();

            this.comboBox3.DataSource    = dt1;           //绑定数据源
            this.comboBox3.DisplayMember = "hostName";    //显示给用户的数据集表项
            this.comboBox3.ValueMember   = "measureCode"; //操作时获取的值
            this.comboBox3.Text          = "--请选择--";
            this.comboBox1.Text          = "--请选择--";

            //图表显示
            if (chart1.Titles != null)
            {
                chart1.Titles.Clear();
            }
            if (chart1.Series != null)
            {
                chart1.Series.Clear();
            }
            //第一线条
            series1                     = new Series();
            series1.Name                = "温度";
            series1.ChartType           = SeriesChartType.Line;
            series1.IsValueShownAsLabel = false; //是否显示值
            series1.BorderWidth         = 1;     //线条宽度
            series1.IsVisibleInLegend   = true;  //是否显示数据说明
            //series1.Color = Color.YellowGreen;

            series2                     = new Series();
            series2.Name                = "湿度";
            series2.ChartType           = SeriesChartType.Line;
            series2.IsValueShownAsLabel = false; //是否显示值
            series2.BorderWidth         = 1;     //线条宽度
            series2.IsVisibleInLegend   = true;  //是否显示数据说明
            //series2.Color = Color.CadetBlue;

            //曲线图的标题
            chart1.Titles.Add("温湿度数据曲线图");
            chart1.Titles[0].ForeColor = Color.Green;
            //chart1.Legends.First().Enabled = false;
            chart1.Legends[0].Enabled  = true;                                //是否显示图例
            chart1.BackColor           = Color.FromArgb(243, 223, 193);
            chart1.BackColor           = ColorTranslator.FromHtml("#D3DFF0"); //用网页颜色
            chart1.BackGradientStyle   = GradientStyle.TopBottom;             //渐变背景,从上到下
            chart1.BorderlineDashStyle = ChartDashStyle.Solid;                //外框线为实线
            chart1.BorderlineWidth     = 2;
            chart1.ChartAreas[0].AxisX.IsMarginVisible     = false;           //不显示X轴的margin
            chart1.ChartAreas[0].AxisX.Title               = "采集时间";
            chart1.ChartAreas[0].AxisY.Maximum             = 100;             //设置Y轴最大值
            chart1.ChartAreas[0].AxisY.Minimum             = -100;            //设置Y轴最大值
            chart1.ChartAreas[0].AxisY.Title               = "温湿度";
            chart1.ChartAreas[0].AxisY.TextOrientation     = TextOrientation.Stacked;
            chart1.ChartAreas[0].BackColor                 = Color.Transparent;//数据区域的背景,默认为白色
            chart1.ChartAreas[0].BackGradientStyle         = GradientStyle.TopBottom;
            chart1.ChartAreas[0].BorderDashStyle           = ChartDashStyle.Solid;
            chart1.ChartAreas[0].AxisX.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64); //数据区域,纵向的线条颜色
            chart1.ChartAreas[0].AxisY.MajorGrid.LineColor = Color.FromArgb(64, 64, 64, 64); //数据区域,横向线条的颜色
            chart1.ChartAreas[0].AxisX.Interval            = 0;                              //设置为0表示由控件自动分配
            chart1.ChartAreas[0].AxisX.IntervalAutoMode    = IntervalAutoMode.VariableCount;
            chart1.ChartAreas[0].AxisX.IntervalType        = DateTimeIntervalType.Auto;
            //chart1.ChartAreas[0].AxisX.LabelStyle.IsStaggered = true;
            chart1.ChartAreas[0].CursorX.IsUserEnabled          = true;
            chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true;
            chart1.ChartAreas[0].AxisX.ScaleView.Zoomable       = true;

            //chart1.ChartAreas[0].AxisX.ScaleView.Zoom(2, 3);
            //将滚动内嵌到坐标轴中
            chart1.ChartAreas[0].AxisX.ScrollBar.IsPositionedInside = true;
            // 设置滚动条的大小
            chart1.ChartAreas[0].AxisX.ScrollBar.Size = 20;
            // 设置滚动条的按钮的风格
            chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
            // 设置自动放大与缩小的最小量
            chart1.ChartAreas[0].AxisX.ScaleView.SmallScrollSize    = double.NaN;
            chart1.ChartAreas[0].AxisX.ScaleView.SmallScrollMinSize = 2;
            //显示背景间隔带,效果如下图:
            chart1.ChartAreas[0].AxisY.IsInterlaced    = true;
            chart1.ChartAreas[0].AxisY.InterlacedColor = System.Drawing.Color.FromArgb(239, 242, 245);
        }
Пример #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            string name = this.textBox1.Text;

            //验证主机名称是否重复
            service.manageHostService mhs = new service.manageHostService();
            DataTable dt = mhs.queryManageHost();

            DataRow[] drr = dt.Select("hostName = '" + name + "'");
            if (drr.Length > 0)
            {
                MessageBox.Show("主机名称已存在,请重新输入!");
                return;
            }
            string cdnum  = this.numericUpDown1.Value.ToString();
            string cktype = this.comboBox3.SelectedItem.ToString();
            string txxy   = this.comboBox2.SelectedItem.ToString();
            string kflx   = this.comboBox1.SelectedValue.ToString();
            /////////////////////////设置主机信息
            int    RecordM  = int.Parse(this.numericUpDown7.Value.ToString());
            int    WarningM = int.Parse(this.numericUpDown6.Value.ToString());
            string PhoneNo  = this.textBox5.Text.ToString();
            int    State    = 1;

            if (PhoneNo == "" || PhoneNo.Length != 11)
            {
                MessageBox.Show("请输入正确的手机号码!"); return;
            }
            ////////////////////////////////

            if (name != null && !"".Equals(name) && cdnum != null && cktype != null && txxy != null && kflx != null)
            {
                mh = new bean.manageHose();

                bool istrue = false;
                mh.hostName          = name;
                mh.CommunicationType = txxy;
                mh.portNumber        = cdnum;
                mh.storeType         = cktype;
                mh.houseType         = kflx;
                /////////////////////////设置主机信息
                mh.RecordM  = RecordM;
                mh.WarningM = WarningM;
                mh.PhoneNo  = PhoneNo;
                mh.State    = State;
                ////////////////////////////////
                if (this.radioButton1.Checked)
                {
                    mh.hostAddress = this.numericUpDown2.Value.ToString();
                    mh.serialPort  = this.comboBox5.Text;
                    mh.tcp_ip_Port = "";
                    mh.networkType = "COM";
                }
                else if (this.radioButton2.Checked)
                {
                    mh.hostAddress = this.numericUpDown5.Value.ToString();
                    mh.serialPort  = "";
                    mh.tcp_ip_Port = this.textBox3.Text + ":" + this.numericUpDown3.Value.ToString();
                    mh.networkType = "TCP";
                }
                else if (this.radioButton4.Checked)
                {
                    mh.hostAddress = "";
                    mh.serialPort  = "";
                    mh.tcp_ip_Port = "";
                    mh.networkType = "YUN";
                }
                else
                {
                    MessageBox.Show("请选择通讯方式");
                    return;
                }

                if (this.textBox2.Text != null && !"".Equals(this.textBox2.Text))
                {
                    mh.measureCode = this.textBox2.Text;
                    //验证主机主机编号是否重复
                    DataRow[] drr0 = dt.Select("measureCode = '" + mh.measureCode + "'");
                    if (drr0.Length > 0)
                    {
                        MessageBox.Show("主机编号已存在,请重新输入!");
                        return;
                    }
                    //添加主机
                    istrue = mhs.addManageHost(mh);
                }
                else
                {
                    MessageBox.Show("管理主机编号为空,请输入...");
                }
                if (istrue)
                {
                    service.deviceInformationService ds = new service.deviceInformationService();
                    bool isfalse = ds.addDeviceInformation(mh);
                    if (isfalse)
                    {
                        this.DialogResult = DialogResult.OK;
                    }
                }
            }
            else
            {
                MessageBox.Show("信息填写不完整,请重新填写!");
            }
        }