private void button4_Click(object sender, EventArgs e)
        {
            DialogResult rr = MessageBox.Show("确定要删除测点(仪表)数据吗?", "确定要删除提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
            int          tt = (int)rr;

            if (tt == 1)
            {
                string code  = this.dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
                string meter = this.dataGridView1.SelectedRows[0].Cells[2].Value.ToString();

                if (code != null && !"".Equals(code) && meter != null && !"".Equals(meter))
                {
                    bean.deviceInformation di = new bean.deviceInformation();
                    di.measureCode = code;
                    di.meterNo     = meter;
                    service.deviceInformationService dis = new service.deviceInformationService();
                    bool bl = dis.deletetDeviceInformation(di);
                    if (bl)
                    { //删除仪表数据的同时修改管理主机的仪表数量
                        service.manageHostService mhs = new service.manageHostService();
                        bean.manageHose           mh  = new bean.manageHose();
                        mh.measureCode = di.measureCode;
                        mhs.updateManageHostCdNum(mh);
                        //刷新仪表页面
                        checkPointInfo();
                        MessageBox.Show("删除成功!");
                        //刷新首页
                        if (this.RefreshEvent != null)
                        {
                            RefreshEvent(1, null);
                        }
                    }
                }
            }
        }
Beispiel #2
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();
        }
Beispiel #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";                 //操作时获取的值
        }
Beispiel #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);
        }
Beispiel #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("信息填写不完整,请重新填写!");
            }
        }
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            string cdname = this.textBox1.Text;
            string cdnum  = this.textBox2.Text;
            string mcode  = this.comboBox1.SelectedValue.ToString();
            string type   = this.comboBox3.SelectedValue.ToString();
            string t1     = this.numericUpDown1.Value.ToString();
            string t2     = this.numericUpDown2.Value.ToString();
            string h1     = this.numericUpDown3.Value.ToString();
            string h2     = this.numericUpDown4.Value.ToString();

            if (cdname != null && !"".Equals(cdname) && cdnum != null && !"".Equals(cdnum) && mcode != null && !"".Equals(mcode))
            {
                if (float.Parse(t1) > float.Parse(t2))
                {
                    if (cdnum.Length == 2)
                    {
                        bean.deviceInformation di = new bean.deviceInformation();
                        di.h_high       = float.Parse(h1);
                        di.h_low        = float.Parse(h2);
                        di.t_high       = float.Parse(t1);
                        di.t_low        = float.Parse(t2);
                        di.terminalname = cdname;
                        di.measureCode  = mcode;
                        di.meterNo      = cdnum;
                        di.housecode    = type;


                        bool bl = dis.queryDeviceBycode(di);
                        if (bl)
                        {
                            bool isok = dis.insertDeviceInformation(di);
                            if (isok)
                            {//测点添加成功的同时   要修改管理主机表中的测点个数
                                bean.manageHose bm = new bean.manageHose();
                                bm.measureCode = di.measureCode;
                                service.manageHostService mh = new service.manageHostService();
                                mh.updateManageHostCdNum(bm);

                                this.DialogResult = DialogResult.OK;
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show("测点编号已存在,请重新输入!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("请填写格式正确的测点编号!");
                    }
                }
                else
                {
                    MessageBox.Show("温度上限应大于温度下限,请重新输入!");
                }
            }
            else
            {
                MessageBox.Show("信息输入不完整,请重新输入!");
            }
        }