Пример #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 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("信息输入不完整,请重新输入!");
            }
        }