示例#1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            cboBuses.DataSource = null;
            lblMessage.Text = String.Empty;
            try
            {
                int distance = 300;
                //if (!getDistance(ref distance))
                //{
                //    throw new Exception("Distância inserida em formato incorreto. Favor utilizar apenas números inteiros acima de zero.");
                //}

                Teste_OnibusContext context = new Teste_OnibusContext();
                DBLandmark DBlandmark = new DBLandmark(context);

                //consulta as coordenadas do ponto de referencia
                IEnumerable<Coordinates> landmarkResult = DBlandmark.SelectLike(processString(txtKeyword.Text));

                if (landmarkResult.Count() > 1)
                {
                    Methods.DisplayMessage(lblMessage, "More then one place has this name. Plese be more specific.", Color.Red); //Especificar melhor a busca
                }
                else if (landmarkResult.Count() == 0)
                {
                    Methods.DisplayMessage(lblMessage, "No local was found with this description", Color.Red);
                    //fillRecommendedBuses(kml, getCoordinatesReference(txtKeyword.Text)); //pesquisa no Google Maps
                }
                else
                {
                    //txtResultPontoReferencia.Text = landmarkResult.ElementAt(0).LandmarkKnownAs.Known_As_Description;

                    fillRecommendedBuses(landmarkResult.ElementAt(0).Landmark.Landmark_Coordinates, context, (STATION)cboStation.SelectedItem, distance); //ja está cadastrado no Banco de Dados
                    Methods.DisplayMessage(lblMessage, "See your recommended buses!", Color.Green);
                }
            }
            catch (Exception ex)
            {
                Methods.DisplayMessage(lblMessage, ex.Message, Color.Red);
            }
        }
示例#2
0
 private void btnClearStationReferences_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to delete all the Landmarks?", "Confirmation", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             using (context = new Teste_OnibusContext())
             {
                 DBLandmark db = new DBLandmark(context);
                 db.DeleteAll();
                 Methods.DisplayMessage(lblMessage, "All records deleted successfully!", Color.Green);
             }
         }
         catch (Exception ex)
         {
             Methods.DisplayMessage(lblMessage, "It was not possible to delete the records!", Color.Red);
         }
     }
 }