private bool CheckInputInfo(ConnStrHelper connStr) { try { if (connStr.Host == null || connStr.Host == "") { MessageBox.Show("服务器IP不可为空"); return(false); } if (connStr.Port == null || connStr.Port == "") { MessageBox.Show("端口号不可为空"); return(false); } if (int.Parse(connStr.Port) <= 0 || int.Parse(connStr.Port) > 65535) { MessageBox.Show("端口号不在正确范围内"); return(false); } if (connStr.ServiceName == null || connStr.ServiceName == "") { MessageBox.Show("服务器名不可为空"); return(false); } if (connStr.UserID == null || connStr.UserID == "") { MessageBox.Show("用户名不可为空"); return(false); } if (connStr.Password == null || connStr.Password == "") { MessageBox.Show("密码不可为空"); return(false); } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(true); }
private string GetconnStr(string type) { ConnStrHelper connStr = new ConnStrHelper(); connStr.Protocal = cboProtocalType.SelectedItem.ToString(); connStr.Host = txtSeverIP.Text; connStr.Port = txtSeverPort.Text; connStr.ServiceName = txtSeverName.Text; connStr.UserID = txtUserID.Text; connStr.Password = txtPassWord.Text; if (CheckInputInfo(connStr))//校验 { if (type == "Entity") { return(connStr.GetEntityConnStr()); } if (type == "Config") { return(connStr.GetConnStr()); } } return(null); }