示例#1
0
        }     //end btnsubmit click

        private bool ValidateTextBoxes()
        {
            return(StringValidator.IsNotEmptySpaceOrNull(txtName.Text) &&
                   StringValidator.IsNotEmptySpaceOrNull(txtState.Text) &&
                   IntValidator.IsInteger(txtPop.Text) &&
                   StringValidator.IsDecimal(txtMedHI.Text) &&
                   StringValidator.IsDecimal(txtPercOwn.Text) &&
                   StringValidator.IsDecimal(txtRent.Text) &&
                   IntValidator.IsInteger(txtMaleMedAge.Text) &&
                   IntValidator.IsInteger(txtFemaleMedAge.Text) &&
                   StringValidator.IsDecimal(txtUnemploymentRate.Text) &&
                   StringValidator.IsDecimal(txtBurgRate.Text) &&
                   StringValidator.IsDecimal(txtVehTheftRate.Text));
        }
示例#2
0
        }     //end btn search

        protected void btnSearch1_Click(object sender, EventArgs e)
        {
            if (!StringValidator.IsNotEmptySpaceOrNull(txtSearchState.Text))
            {
                lblWarning.Visible = false;
                string      cityName = txtSearchName.Text;
                WebRequest  request  = WebRequest.Create(webApiUrl + "CityByName" + "?cityName=" + cityName);
                WebResponse response = request.GetResponse();

                // Read the data from the Web Response, which requires working with streams.
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                // Deserialize a JSON string that contains an array of JSON objects into an Array of Team objects.
                JavaScriptSerializer js       = new JavaScriptSerializer();
                List <City>          CityList = js.Deserialize <List <City> >(data);
                if (CityList != null)
                {
                    container.InnerHtml = "";
                    container.InnerHtml = CityGUI.DisplayCities(CityList);
                }
                else
                {
                    lblWarning.Visible = true;
                    lblWarning.Text    = "No Records Found";
                }
            }//end if
            else if (StringValidator.IsNotEmptySpaceOrNull(txtSearchState.Text) &&
                     StringValidator.IsNotEmptySpaceOrNull(txtSearchName.Text))
            {
                lblWarning.Visible = false;
                string      cityState = txtSearchState.Text;
                string      cityName  = txtSearchName.Text;
                WebRequest  request   = WebRequest.Create(webApiUrl + "CityByNameAndState" + "?cityName=" + cityName + "&cityState=" + cityState);
                WebResponse response  = request.GetResponse();

                // Read the data from the Web Response, which requires working with streams.
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                // Deserialize a JSON string that contains an array of JSON objects into an Array of Team objects.
                JavaScriptSerializer js       = new JavaScriptSerializer();
                List <City>          CityList = js.Deserialize <List <City> >(data);
                if (CityList != null)
                {
                    container.InnerHtml = "";
                    container.InnerHtml = CityGUI.DisplayCities(CityList);
                }
                else
                {
                    lblWarning.Visible = true;
                    lblWarning.Text    = "No Records Found";
                }
            }//end else if
            else
            {
                lblWarning.Visible = false;
                string      cityState = txtSearchState.Text;
                WebRequest  request   = WebRequest.Create(webApiUrl + "CityByState" + "?cityState=" + cityState);
                WebResponse response  = request.GetResponse();

                // Read the data from the Web Response, which requires working with streams.
                Stream       theDataStream = response.GetResponseStream();
                StreamReader reader        = new StreamReader(theDataStream);
                String       data          = reader.ReadToEnd();

                reader.Close();
                response.Close();

                // Deserialize a JSON string that contains an array of JSON objects into an Array of Team objects.
                JavaScriptSerializer js       = new JavaScriptSerializer();
                List <City>          CityList = js.Deserialize <List <City> >(data);
                if (CityList != null)
                {
                    if (CityList.Count > 0)
                    {
                        container.InnerHtml = "";
                        container.InnerHtml = CityGUI.DisplayCities(CityList);
                    }//end if
                    else
                    {
                        lblWarning.Visible = true;
                        lblWarning.Text    = "No Records Found";
                    }//end else
                }
                else
                {
                    lblWarning.Visible = true;
                    lblWarning.Text    = "No Records Found";
                }
            }//end else if
        }