Beispiel #1
0
        private bool VerifyData()
        {
            bool valid = true;

            string deviceAddress   = this.tbDeviceAddress.Text.Trim();
            string registAddress   = this.tbRegistAddress.Text.Trim();
            string valueOfResToSet = this.tbValueOfResToSet.Text.Trim();

            if (string.IsNullOrWhiteSpace(deviceAddress) ||
                string.IsNullOrWhiteSpace(registAddress) ||
                string.IsNullOrWhiteSpace(valueOfResToSet)
                )
            {
                MessageBox.Show("请填完信息");
                return(false);
            }

            if (!NumericString.IsNumeric(deviceAddress) ||
                !NumericString.IsNumeric(registAddress) ||
                !NumericString.IsNumeric(valueOfResToSet))
            {
                MessageBox.Show("只能输入数字");
                return(false);
            }

            return(valid);
        }
Beispiel #2
0
        //public IRequestInfo GetRequestInfo()
        //{
        //    RequestInfo requestInfo = new RequestInfo();

        //    if (VerifyData())
        //    {
        //        try
        //        {
        //            requestInfo.DeviceAddress = Convert.ToByte(this.tbDeviceAddress.Text);
        //            requestInfo.FunctionNum = this.functionNum;
        //            requestInfo.TheByte3and4 = Convert.ToUInt16(this.tbBeginingResAddress.Text);
        //            requestInfo.TheByte5and6 = Convert.ToUInt16(this.tbNumOfResToRead.Text);
        //        }
        //        catch (Exception)
        //        {
        //            MessageBox.Show("设备地址[0-255] \n寄存器地址[0-65535] \n数量[0-65535]");
        //            return requestInfo = null;
        //        }
        //    }

        //    return requestInfo;
        //}

        #endregion

        private bool VerifyData()
        {
            bool valid = true;

            if (string.IsNullOrWhiteSpace(this.tbDeviceAddress.Text) ||
                string.IsNullOrWhiteSpace(tbBeginingResAddress.Text) ||
                string.IsNullOrWhiteSpace(tbNumOfResToRead.Text)
                )
            {
                MessageBox.Show("请填完信息");
                return(false);
            }

            if (!NumericString.IsNumeric(this.tbDeviceAddress.Text.Trim()) ||
                !NumericString.IsNumeric(this.tbBeginingResAddress.Text.Trim()) ||
                !NumericString.IsNumeric(this.tbNumOfResToRead.Text.Trim()))
            {
                MessageBox.Show("只能输入数字");
                return(false);
            }

            return(valid);
        }