示例#1
0
        private void button_Add4_Click(object sender, EventArgs e)
        {
            string Msg = "";

            Service.Model.YY_RTU_WRES model = Validate4(out Msg);
            if (Msg == "")
            {
                bool b1 = PublicBD.db.DelRTU_WRES("where STCD='" + comboBox_STCD.SelectedValue.ToString() + "' and CODE=1");
                bool b2 = PublicBD.db.AddRTU_WRES(model);
                if (b1 && b2)
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("第四中心站信息配置成功!", "[提示]", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    DevComponents.DotNetBar.MessageBoxEx.Show("第四中心站信息配置失败!", "[提示]", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                DevComponents.DotNetBar.MessageBoxEx.Show("第一中心站\n" + Msg, "[提示]", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#2
0
        private Service.Model.YY_RTU_WRES  Validate1(out string Msg)
        {
            Msg = "";
            Service.Model.YY_RTU_WRES model = new Service.Model.YY_RTU_WRES();

            if (comboBox_STCD.SelectedValue == null)
            {
                Msg += "请选择测站!" + "\n";
            }
            else
            {
                model.STCD = comboBox_STCD.SelectedValue.ToString();
            }

            model.COM_M = comboBox_COM_M1.SelectedIndex; //------------
            model.CODE  = 1;
            int adr = 0;

            if (!int.TryParse(textBox_ADR_ZX1.Text.Trim(), out adr))//----
            {
                Msg += "中心站地址输入有误!" + "\n";
            }
            else
            {
                if (adr < 1 || adr > 255)
                {
                    Msg += "中心站地址输入有误!" + "\n";
                }
                else
                {
                    model.ADR_ZX = adr;
                }
            }

            if (comboBox_COM_M1.SelectedIndex == 2 || comboBox_COM_M1.SelectedIndex == 7) //-----------
            {
                System.Net.IPAddress address;
                if (!System.Net.IPAddress.TryParse(textBox_ADR_M1.Text.Trim(), out address))//-----------
                {
                    //失败
                    Msg += "主信道地址输入有误!" + "\n";
                }
                else
                {
                    model.ADR_M = textBox_ADR_M1.Text.Trim(); //--------------
                }


                int port = 0;
                if (!int.TryParse(textBox_PORT_M1.Text.Trim(), out port))//---------------
                {
                    Msg += "主信道端口输入有误!" + "\n";
                }
                else
                {
                    if (port < 0 || port > 65535)
                    {
                        Msg += "主信道端口输入有误!" + "\n";
                    }
                    else
                    {
                        model.PORT_M = port;
                    }
                }
            }
            if (comboBox_COM_B1.SelectedIndex != -1)         //------------
            {
                model.COM_B = comboBox_COM_B1.SelectedIndex; //-----------
            }
            if (comboBox_COM_B1.SelectedIndex == 2)          //-------------
            {
                System.Net.IPAddress address;
                if (!System.Net.IPAddress.TryParse(textBox_ADR_B1.Text.Trim(), out address))//-----------
                {
                    //失败
                    Msg += "备用信道地址输入有误!" + "\n";
                }
                else
                {
                    model.ADR_B = textBox_ADR_B1.Text.Trim();//---------------
                }


                int port = 0;
                if (!int.TryParse(textBox_PORT_B1.Text.Trim(), out port))//---------------
                {
                    Msg += "备用信道端口输入有误!" + "\n";
                }
                else
                {
                    if (port < 0 || port > 65535)
                    {
                        Msg += "备用信道端口输入有误!" + "\n";
                    }
                    else
                    {
                        model.PORT_B = port;
                    }
                }
            }

            if (comboBox_COM_M1.SelectedIndex == 1 || comboBox_COM_B1.SelectedIndex == 1) //------------------
            {
                if (!IsPhone(textBox_PhoneNum1.Text.Trim()))                              //---------------
                {
                    Msg += "手机号输入有误!" + "\n";
                }
                else
                {
                    model.PhoneNum = textBox_PhoneNum1.Text.Trim(); //----------
                }
            }


            if (comboBox_COM_M1.SelectedIndex == 3 || comboBox_COM_M1.SelectedIndex == 4 || comboBox_COM_B1.SelectedIndex == 3 || comboBox_COM_B1.SelectedIndex == 4) //-----------
            {
                int port = 0;
                if (!int.TryParse(textBox_SatelliteNum1.Text.Trim(), out port))//---------------
                {
                    Msg += "卫星号码输入有误!" + "\n";
                }
                else
                {
                    model.SatelliteNum = textBox_SatelliteNum1.Text.Trim();//------------------
                }
            }

            #region IPV4+短信/卫星  ---黑龙江
            if (comboBox_COM_M1.SelectedIndex == 7)
            {
                if (textBox_PhoneNum1.Text.Trim() == "" && textBox_SatelliteNum1.Text.Trim() == "")
                {
                    Msg += "手机号码或卫星号码至少输入一个!" + "\n";
                }

                if (textBox_PhoneNum1.Text.Trim() != "" && !IsPhone(textBox_PhoneNum1.Text.Trim())) //---------------
                {
                    Msg += "手机号输入有误!" + "\n";
                }
                else
                {
                    model.PhoneNum = textBox_PhoneNum1.Text.Trim(); //----------
                }

                int port = 0;
                if (textBox_SatelliteNum1.Text.Trim() != "" && !int.TryParse(textBox_SatelliteNum1.Text.Trim(), out port))//---------------
                {
                    Msg += "卫星号码输入有误!" + "\n";
                }
                else
                {
                    model.SatelliteNum = textBox_SatelliteNum1.Text.Trim();//------------------
                }
            }
            #endregion

            return(model);
        }