示例#1
0
        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);
                        }
                    }
                }
            }
        }
示例#2
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("信息填写不完整,请重新填写!");
            }
        }
示例#3
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("信息输入不完整,请重新输入!");
            }
        }