示例#1
0
        private void btnOK_Click(object sender, System.EventArgs e)
        {
            int   grAddr, xgAddr;
            float area;

            //, cpn;

            // check gprs staion name
            //
            if (StationName == string.Empty)
            {
                MsgBox.Show("站名不能为空!");
                return;
            }

            // check gr address
            //
            try
            {
                grAddr = GrAddress;
            }
            catch
            {
                MsgBox.Show("供热控制器地址错误!");
                return;
            }
            // check xg address
            //
            try
            {
                xgAddr = XgAddress;
            }
            catch
            {
                MsgBox.Show("巡更控制器地址错误!");
                return;
            }

            //// check commport
            //
//            try
//            {
//                cpn = CommPort;
//            }
//            catch
//            {
//                MsgBox.Show("串口号错误!");
//                return ;
//            }

            // check ip address
            //
            try
            {
                if (IpAddress.Length == 0)
                {
                    MsgBox.Show("IP地址不能为空!");
                    return;
                }
                System.Net.IPAddress.Parse(IpAddress);
            }
            catch
            {
                MsgBox.Show("IP地址错误");
                return;
            }

            try
            {
                if (ServerIpAddress.Length == 0)
                {
                    MsgBox.Show("服务器IP地址不能为空!");
                    return;
                }
                System.Net.IPAddress.Parse(ServerIpAddress);
            }
            catch
            {
                MsgBox.Show("服务器IP地址错误");
                return;
            }

            try
            {
                area = this.Area;
            }
            catch
            {
                MsgBox.Show("供热面积错误");
                return;
            }



            // check station name not use
            //
            bool nameExist = XGDB.CheckGprsStationNameExist(StationName.Trim(),
                                                            EditId, XGConfig.Default.ClientAorB);

            if (nameExist)
            {
                MsgBox.Show("站名已经存在!");
                return;
            }

            // check commport not use
            //
//            bool cpExist = XGDB.CheckGprsStationCommPortExist( CommPort, EditId, XGConfig.Default.ClientAorB );
//            if ( cpExist )
//            {
//                MsgBox.Show( "串口号已经存在!" );
//                return ;
//            }



            this.DialogResult = DialogResult.OK;
            Close();
        }