internal static CategoryService FromJObject(JObject jObject)
 {
     CategoryService category = new CategoryService();
     category.Categoria = jObject["Categoria"].ToString();
     category.idCategoria = jObject["idCategoria"].ToString();
     return category;
 }
Exemple #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            //**Colocamos los parametros con los cuales ya cuenta la tarea
            this.cmpTitulo.Text = this.task.Titulo;
            this.cmpDescripcion.Text = this.task.Descripcion;
            this.cmpSolicitante.Text = this.task.nombreSolicitante;
            this.cmpTelCasa.Text = this.task.telCasaSolicitante;
            this.cmpTelCel.Text = this.task.telCelularSolicitante;
            this.cmpCorreo.Text = this.task.correoSolicitante;
            this.lblCategoria.Text = this.task.idCategoria;
            this.lblResponsable.Text = this.task.idResponsable;
            this.lblPrioridad.Text = this.task.idPrioridad;
            this.lblFechaCont.Text = this.task.fechaContacto;
            this.lblFechaCompr.Text = this.task.fechaCompromiso;
            //******************************************

            //Se esconde el booton para ir a la vista anterior
            this.NavigationItem.HidesBackButton = true;

            //se crea el boton para regresar a la vista anterior, verificando que la tarea haya sido dada de alta
            UIBarButtonItem regresar = new UIBarButtonItem();
            regresar.Style = UIBarButtonItemStyle.Plain;
            regresar.Target = this;
            regresar.Title = "Lista de tareas";
            regresar.Clicked += (sender, e) => {
                if(this.listo == false){
                    UIAlertView alert = new UIAlertView(){
                        Title = "¿Salir?" , Message = "Si sales se perderá la edicion de la tarea"
                    };
                    alert.AddButton("Aceptar");
                    alert.AddButton("Cancelar");
                    alert.Clicked += (s, o) => {
                        if(o.ButtonIndex==0){
                            NavigationController.PopViewControllerAnimated(true);
                        }
                    };
                    alert.Show();
                }else{
                    NavigationController.PopViewControllerAnimated(true);
                }
            };

            //posionamiento del boton
            this.NavigationItem.LeftBarButtonItem = regresar;

            //Declaramos el datamodel para los responsables
            pickerDataModelResponsibles = new PickerDataModelResponsibles ();
            //Declaramos el datamodel para las categorias
            pickerDataModelCategories = new PickerDataModelCategories ();
            //Declaramos el datamodel para el picker de prioridades
            pickerDataModel = new PickerDataModel ();
            //Declaramos el datamodel para el picker de buisqueda de personas
            pickerDataModelPeople = new PickerDataModelPeople ();
            //Declaramos el actionsheet donde se mostrara el picker
            actionSheetPicker = new ActionSheetPicker(this.View);

            this.btnResponsable.TouchUpInside += (sender, e) => {
                try{
                    responsibleService = new ResponsibleService();
                    pickerDataModelResponsibles.Items = responsibleService.All();
                    actionSheetPicker.Picker.Source = pickerDataModelResponsibles;
                    actionSheetPicker.Show();
                }catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnCategoria.TouchUpInside += (sender, e) => {
                try{
                categoryService = new CategoryService();
                pickerDataModelCategories.Items = categoryService.All();//llenamos el picker view con la respuesta del servicio de categorias
                actionSheetPicker.Picker.Source = pickerDataModelCategories;
                actionSheetPicker.Show();
                }catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnPrioridad.TouchUpInside += (sender, e) => {
                try{
                prioritiesService = new PrioritiesService();
                pickerDataModel.Items = prioritiesService.All();//llenamos el pickerview con la lista de prioridades
                actionSheetPicker.Picker.Source = pickerDataModel;
                actionSheetPicker.Show();
                } catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnFechaCont.TouchUpInside += (sender, e) => {
                actionSheetDatePicker.Show();
            };

            this.btnFechaCompr.TouchUpInside += (sender, e) => {
                actionSheetDatePicker1.Show();
            };

            //Establecemos las propiedades del primer datepicker
            actionSheetDatePicker = new ActionSheetDatePicker (this.View);
            actionSheetDatePicker.Picker.Mode = UIDatePickerMode.Date;
            //actionSheetDatePicker.Picker.TimeZone = NSTimeZone.LocalTimeZone;
            //actionSheetDatePicker.Picker.MinimumDate = DateTime.Today.AddDays (-7);
            //actionSheetDatePicker.Picker.MaximumDate = DateTime.Today.AddDays (7);

            //Establecemos las propiedades del segundo datepicker
            actionSheetDatePicker1 = new ActionSheetDatePicker (this.View);
            actionSheetDatePicker1.Picker.Mode = UIDatePickerMode.Date;
            //actionSheetDatePicker1.Picker.MinimumDate = DateTime.Today.AddDays (-7);
            //actionSheetDatePicker1.Picker.MaximumDate = DateTime.Today.AddDays (7);

            actionSheetDatePicker.Picker.ValueChanged += (s, e) => {
                DateTime fecha1 = (s as UIDatePicker).Date;
                String fecha2 = String.Format("{0:yyyy-MM-dd}",fecha1);
                this.lblFechaCont.Text = fecha2;
            };

            actionSheetDatePicker1.Picker.ValueChanged += (s, e) => {
                DateTime fecha1 = (s as UIDatePicker).Date;
                String fecha2 = String.Format("{0:yyyy-MM-dd}",fecha1);
                this.lblFechaCompr.Text = fecha2;
            };

            String categoria=task.idCategoria;
            pickerDataModelCategories.ValueChanged += (sender, e) => {
                categoria = pickerDataModelCategories.SelectedItem.Categoria;
                this.lblCategoria.Text = pickerDataModelCategories.SelectedItem.ToString();
            };

            String prioridad = task.idPrioridad;
            pickerDataModel.ValueChanged += (sender, e) => {
                prioridad = pickerDataModel.SelectedItem.Prioridad;
                this.lblPrioridad.Text = pickerDataModel.SelectedItem.ToString();
            };

            String responsable = task.idResponsable;
            pickerDataModelResponsibles.ValueChanged += (sender, e) => {
                responsable = pickerDataModelResponsibles.SelectedItem.Username;
                this.lblResponsable.Text = pickerDataModelResponsibles.SelectedItem.ToString();
            };

            String idPadron =task.idSolicitante;
            pickerDataModelPeople.ValueChanged += (sender, e) => {
                idPadron = pickerDataModelPeople.SelectedItem.idPadron;
                this.cmpSolicitante.Text = pickerDataModelPeople.SelectedItem.ToString();
            };

            this.btnBuscar.TouchUpInside += (sender, e) => {
                try{
                    peopleService = new PeopleService();
                    peopleService.FindPeople(this.cmpNombre.Text, this.cmpPaterno.Text, this.cmpMaterno.Text);

                    pickerDataModelPeople.Items = peopleService.All();
                    if(pickerDataModelPeople.Items.Count == 0){
                        UIAlertView alert = new UIAlertView(){
                            Title = "Persona no encontrada", Message = "No se encontraron resultados, intentelo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }else{
                        actionSheetPicker = new ActionSheetPicker(this.View);
                        actionSheetPicker.Picker.Source = pickerDataModelPeople;
                        actionSheetPicker.Show();
                    }
                }catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.cmpSolicitante.Enabled = false;

            //Se crea el boton para enviar la informacion al servidor
            this.btnGuardar.TouchUpInside += (sender, e) => {
                try{
                    editTaskService = new EditTaskService();
                    String respuesta = editTaskService.SetData(cmpTitulo.Text,task.idTarea,cmpDescripcion.Text,categoria,responsable,prioridad,lblFechaCont.Text,lblFechaCompr.Text,idPadron,MainView.user
                                                              ,cmpTelCasa.Text,cmpTelCel.Text,cmpCorreo.Text);
                    if (respuesta.Equals("0")){
                        UIAlertView alert = new UIAlertView(){
                            Title = "ERROR", Message = "Error del Servidor, intentelo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }else if(respuesta.Equals("1")){
                        UIAlertView alert = new UIAlertView(){
                            Title = "Correcto", Message = "La tarea ha sido guardada correctamente"
                        };
                        alert.AddButton("Aceptar");
                        alert.Clicked += (s, o) => {
                            if(o.ButtonIndex==0){
                                NavigationController.PopViewControllerAnimated(true);
                            }
                        };
                        alert.Show();
                    }
                }catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "Error del Servidor, intentelo de nuevo o verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            //Se le da un borde al campo de descripcion
            this.cmpDescripcion.Layer.BorderWidth = 1.0f;
            this.cmpDescripcion.Layer.BorderColor = UIColor.Gray.CGColor;
            this.cmpDescripcion.Layer.ShadowColor = UIColor.Black.CGColor;
            this.cmpDescripcion.Layer.CornerRadius = 8;
        }
Exemple #3
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            //Ocultamos el campo de observaciones, ya que por lo visto no se almacena en ningun lado, esperamos respuesta
            this.cmpObservaciones.Hidden = true;
            this.lblObservaciones.Hidden = true;

            //Ocultamos los labels donde se muestran las coordenadas del dispositivo
            this.lblLatitud.Hidden  = true;
            this.lblLongitud.Hidden = true;

            //Declarar el Location Manager
            iPhoneLocationManager = new CLLocationManager();
            iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;

            //Obtener la posicion del dispositivo
            //El metodo es diferente en iOS 6 se verifica la version del S.O.
            if (UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
            {
                iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
                    UpdateLocation(e.Locations [e.Locations.Length - 1]);
                };
            }
            else
            {
                iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
                    UpdateLocation(e.NewLocation);
                };
            }

            iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => {
            };


            //Actualizar la ubicacion
            if (CLLocationManager.LocationServicesEnabled)
            {
                iPhoneLocationManager.StartUpdatingLocation();
            }
            if (CLLocationManager.HeadingAvailable)
            {
                iPhoneLocationManager.StartUpdatingHeading();
            }

            //Se esconde el booton para ir a la vista anterior
            this.NavigationItem.HidesBackButton = true;


            //se crea el boton para regresar a la vista anterior, verificando que la tarea haya sido dada de alta
            UIBarButtonItem regresar = new UIBarButtonItem();

            regresar.Style    = UIBarButtonItemStyle.Plain;
            regresar.Target   = this;
            regresar.Title    = "Lista de tareas";
            regresar.Clicked += (sender, e) => {
                if (this.listo == false)
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "¿Salir?", Message = "Si sales se perderá el registro de la tarea"
                    };
                    alert.AddButton("Aceptar");
                    alert.AddButton("Cancelar");
                    alert.Clicked += (s, o) => {
                        if (o.ButtonIndex == 0)
                        {
                            NavigationController.PopViewControllerAnimated(true);
                        }
                    };
                    alert.Show();
                }
                else
                {
                    NavigationController.PopViewControllerAnimated(true);
                }
            };

            //posionamiento del boton
            this.NavigationItem.LeftBarButtonItem = regresar;

            //Se establece un borde para el textarea de la descripcion
            this.cmpDescripcion.Layer.BorderWidth  = 1.0f;
            this.cmpDescripcion.Layer.BorderColor  = UIColor.Gray.CGColor;
            this.cmpDescripcion.Layer.ShadowColor  = UIColor.Black.CGColor;
            this.cmpDescripcion.Layer.CornerRadius = 8;

            //Declaramos el datamodel para los responsables
            pickerDataModelResponsibles = new PickerDataModelResponsibles();
            //Declaramos el datamodel para las categorias
            pickerDataModelCategories = new PickerDataModelCategories();
            //Declaramos el datamodel para el picker de prioridades
            pickerDataModel = new PickerDataModel();
            //Declaramos el datamodel para el picker de buisqueda de personas
            pickerDataModelPeople = new PickerDataModelPeople();
            //Declaramos el actionsheet donde se mostrara el picker
            actionSheetPicker = new ActionSheetPicker(this.View);

            this.btnResponsable.TouchUpInside += (sender, e) => {
                try{
                    responsibleService = new ResponsibleService();
                    pickerDataModelResponsibles.Items = responsibleService.All();
                    actionSheetPicker.Picker.Source   = pickerDataModelResponsibles;
                    actionSheetPicker.Show();
                }catch (System.Net.WebException) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch (System.Exception) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnCategoria.TouchUpInside += (sender, e) => {
                try{
                    categoryService = new CategoryService();
                    pickerDataModelCategories.Items = categoryService.All();                    //llenamos el picker view con la respuesta del servicio de categorias
                    actionSheetPicker.Picker.Source = pickerDataModelCategories;
                    actionSheetPicker.Show();
                }catch (System.Net.WebException) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch (System.Exception) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnPrioridad.TouchUpInside += (sender, e) => {
                try{
                    prioritiesService               = new PrioritiesService();
                    pickerDataModel.Items           = prioritiesService.All();          //llenamos el pickerview con la lista de prioridades
                    actionSheetPicker.Picker.Source = pickerDataModel;
                    actionSheetPicker.Show();
                } catch (System.Net.WebException) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch (System.Exception) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnFechaCont.TouchUpInside += (sender, e) => {
                actionSheetDatePicker.Show();
            };

            this.btnFechaCompr.TouchUpInside += (sender, e) => {
                actionSheetDatePicker1.Show();
            };

            //Establecemos las propiedades del primer datepicker
            actionSheetDatePicker                 = new ActionSheetDatePicker(this.View);
            actionSheetDatePicker.Picker.Mode     = UIDatePickerMode.Date;
            actionSheetDatePicker.Picker.TimeZone = NSTimeZone.LocalTimeZone;
            //actionSheetDatePicker.Picker.MinimumDate = DateTime.Today.AddDays (-7);
            //actionSheetDatePicker.Picker.MaximumDate = DateTime.Today.AddDays (7);

            //Establecemos las propiedades del segundo datepicker
            actionSheetDatePicker1                 = new ActionSheetDatePicker(this.View);
            actionSheetDatePicker1.Picker.Mode     = UIDatePickerMode.Date;
            actionSheetDatePicker1.Picker.TimeZone = NSTimeZone.LocalTimeZone;
            //actionSheetDatePicker1.Picker.MinimumDate = DateTime.Today.AddDays (-7);
            //actionSheetDatePicker1.Picker.MaximumDate = DateTime.Today.AddDays (7);

            actionSheetDatePicker.Picker.ValueChanged += (s, e) => {
                DateTime fecha1 = (s as UIDatePicker).Date;
                //DateTime fecha3 = fecha1.AddDays(-1);
                String fecha2 = String.Format("{0:yyyy-MM-dd}", fecha1);
                this.lblFechaCont.Text = fecha2;
            };

            actionSheetDatePicker1.Picker.ValueChanged += (s, e) => {
                DateTime fecha1 = (s as UIDatePicker).Date;
                //DateTime fecha3 = fecha1.AddDays(-1);
                String fecha2 = String.Format("{0:yyyy-MM-dd}", fecha1);
                this.lblFechaCompr.Text = fecha2;
            };

            String categoria = "";

            pickerDataModelCategories.ValueChanged += (sender, e) => {
                categoria = pickerDataModelCategories.SelectedItem.idCategoria;
                this.lblCategoria.Text = pickerDataModelCategories.SelectedItem.ToString();
            };

            String prioridad = "";

            pickerDataModel.ValueChanged += (sender, e) => {
                prioridad = pickerDataModel.SelectedItem.idPrioridad;
                this.lblPrioridad.Text = pickerDataModel.SelectedItem.ToString();
            };

            String responsable = "";

            pickerDataModelResponsibles.ValueChanged += (sender, e) => {
                responsable = pickerDataModelResponsibles.SelectedItem.UserID;
                this.lblResponsable.Text = pickerDataModelResponsibles.SelectedItem.ToString();
            };

            String idPadron = "";

            pickerDataModelPeople.ValueChanged += (sender, e) => {
                idPadron = pickerDataModelPeople.SelectedItem.idPadron;
                this.cmpSolicitante.Text = pickerDataModelPeople.SelectedItem.ToString();
            };

            this.btnBuscar.TouchUpInside += (sender, e) => {
                try{
                    peopleService = new PeopleService();
                    peopleService.FindPeople(this.cmpNombre.Text, this.cmpPaterno.Text, this.cmpMaterno.Text);

                    pickerDataModelPeople.Items = peopleService.All();
                    if (pickerDataModelPeople.Items.Count == 0)
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Persona no encontrada", Message = "No se encontraron resultados, intentelo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                    else
                    {
                        actionSheetPicker = new ActionSheetPicker(this.View);
                        actionSheetPicker.Picker.Source = pickerDataModelPeople;
                        actionSheetPicker.Show();
                    }
                } catch (System.Net.WebException) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch (System.Exception) {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.cmpSolicitante.Enabled = false;

            //Se crea el boton para enviar la informacion al servidor
            this.btnGuardar.TouchUpInside += (sender, e) => {
                try{
                    newTaskService = new NewTaskService();
                    String respuesta = newTaskService.SetData(cmpTitulo.Text, cmpDescripcion.Text, categoria, responsable, prioridad, lblFechaCont.Text, lblFechaCompr.Text, idPadron, MainView.user
                                                              , cmpTelCasa.Text, cmpTelCel.Text, cmpCorreo.Text, lblLatitud.Text, lblLongitud.Text);
                    if (respuesta.Equals("0"))
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "ERROR", Message = "Error del Servidor, intentelo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }
                    else if (respuesta.Equals("1"))
                    {
                        UIAlertView alert = new UIAlertView()
                        {
                            Title = "Correcto", Message = "La tarea ha sido guardada correctamente"
                        };
                        alert.AddButton("Aceptar");
                        alert.Clicked += (s, o) => {
                            if (o.ButtonIndex == 0)
                            {
                                NavigationController.PopViewControllerAnimated(true);
                            }
                        };
                        alert.Show();
                    }
                }catch (System.Net.WebException ex) {
                    Console.WriteLine(ex.ToString());
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "ERROR", Message = "Error del Servidor, intentelo de nuevo, o verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            //Se establece un borde para el textarea de las observaciones
            this.cmpObservaciones.Layer.BorderWidth  = 1.0f;
            this.cmpObservaciones.Layer.BorderColor  = UIColor.Gray.CGColor;
            this.cmpObservaciones.Layer.ShadowColor  = UIColor.Black.CGColor;
            this.cmpObservaciones.Layer.CornerRadius = 8;
        }
Exemple #4
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear (animated);

            //Ocultamos el campo de observaciones, ya que por lo visto no se almacena en ningun lado, esperamos respuesta
            this.cmpObservaciones.Hidden = true;
            this.lblObservaciones.Hidden = true;

            //Ocultamos los labels donde se muestran las coordenadas del dispositivo
            this.lblLatitud.Hidden = true;
            this.lblLongitud.Hidden = true;

            //Declarar el Location Manager
            iPhoneLocationManager = new CLLocationManager ();
            iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;

            //Obtener la posicion del dispositivo
            //El metodo es diferente en iOS 6 se verifica la version del S.O.
            if (UIDevice.CurrentDevice.CheckSystemVersion (6, 0)) {
                iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
                    UpdateLocation (e.Locations [e.Locations.Length - 1]);
                };
            }else{
                iPhoneLocationManager.UpdatedLocation += (object sender, CLLocationUpdatedEventArgs e) => {
                    UpdateLocation (e.NewLocation);
                };
            }

            iPhoneLocationManager.UpdatedHeading += (object sender, CLHeadingUpdatedEventArgs e) => {

            };

            //Actualizar la ubicacion
            if (CLLocationManager.LocationServicesEnabled)
                iPhoneLocationManager.StartUpdatingLocation ();
            if (CLLocationManager.HeadingAvailable)
                iPhoneLocationManager.StartUpdatingHeading ();

            //Se esconde el booton para ir a la vista anterior
            this.NavigationItem.HidesBackButton = true;

            //se crea el boton para regresar a la vista anterior, verificando que la tarea haya sido dada de alta
            UIBarButtonItem regresar = new UIBarButtonItem();
            regresar.Style = UIBarButtonItemStyle.Plain;
            regresar.Target = this;
            regresar.Title = "Lista de tareas";
            regresar.Clicked += (sender, e) => {
                if(this.listo == false){
                    UIAlertView alert = new UIAlertView(){
                        Title = "¿Salir?" , Message = "Si sales se perderá el registro de la tarea"
                    };
                    alert.AddButton("Aceptar");
                    alert.AddButton("Cancelar");
                    alert.Clicked += (s, o) => {
                        if(o.ButtonIndex==0){
                            NavigationController.PopViewControllerAnimated(true);
                        }
                    };
                    alert.Show();
                }else{
                    NavigationController.PopViewControllerAnimated(true);
                }
            };

            //posionamiento del boton
            this.NavigationItem.LeftBarButtonItem = regresar;

            //Se establece un borde para el textarea de la descripcion
            this.cmpDescripcion.Layer.BorderWidth = 1.0f;
            this.cmpDescripcion.Layer.BorderColor = UIColor.Gray.CGColor;
            this.cmpDescripcion.Layer.ShadowColor = UIColor.Black.CGColor;
            this.cmpDescripcion.Layer.CornerRadius = 8;

            //Declaramos el datamodel para los responsables
            pickerDataModelResponsibles = new PickerDataModelResponsibles ();
            //Declaramos el datamodel para las categorias
            pickerDataModelCategories = new PickerDataModelCategories ();
            //Declaramos el datamodel para el picker de prioridades
            pickerDataModel = new PickerDataModel ();
            //Declaramos el datamodel para el picker de buisqueda de personas
            pickerDataModelPeople = new PickerDataModelPeople ();
            //Declaramos el actionsheet donde se mostrara el picker
            actionSheetPicker = new ActionSheetPicker(this.View);

            this.btnResponsable.TouchUpInside += (sender, e) => {
                try{
                    responsibleService = new ResponsibleService();
                    pickerDataModelResponsibles.Items = responsibleService.All();
                    actionSheetPicker.Picker.Source = pickerDataModelResponsibles;
                    actionSheetPicker.Show();
                }catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnCategoria.TouchUpInside += (sender, e) => {
                try{
                    categoryService = new CategoryService();
                    pickerDataModelCategories.Items = categoryService.All();//llenamos el picker view con la respuesta del servicio de categorias
                    actionSheetPicker.Picker.Source = pickerDataModelCategories;
                    actionSheetPicker.Show();
                }catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnPrioridad.TouchUpInside += (sender, e) => {
                try{
                    prioritiesService = new PrioritiesService();
                    pickerDataModel.Items = prioritiesService.All();//llenamos el pickerview con la lista de prioridades
                    actionSheetPicker.Picker.Source = pickerDataModel;
                    actionSheetPicker.Show();
                } catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.btnFechaCont.TouchUpInside += (sender, e) => {
                actionSheetDatePicker.Show();
            };

            this.btnFechaCompr.TouchUpInside += (sender, e) => {
                actionSheetDatePicker1.Show();
            };

            //Establecemos las propiedades del primer datepicker
            actionSheetDatePicker = new ActionSheetDatePicker (this.View);
            actionSheetDatePicker.Picker.Mode = UIDatePickerMode.Date;
            actionSheetDatePicker.Picker.TimeZone = NSTimeZone.LocalTimeZone;
            //actionSheetDatePicker.Picker.MinimumDate = DateTime.Today.AddDays (-7);
            //actionSheetDatePicker.Picker.MaximumDate = DateTime.Today.AddDays (7);

            //Establecemos las propiedades del segundo datepicker
            actionSheetDatePicker1 = new ActionSheetDatePicker (this.View);
            actionSheetDatePicker1.Picker.Mode = UIDatePickerMode.Date;
            actionSheetDatePicker1.Picker.TimeZone = NSTimeZone.LocalTimeZone;
            //actionSheetDatePicker1.Picker.MinimumDate = DateTime.Today.AddDays (-7);
            //actionSheetDatePicker1.Picker.MaximumDate = DateTime.Today.AddDays (7);

            actionSheetDatePicker.Picker.ValueChanged += (s, e) => {
                DateTime fecha1 = (s as UIDatePicker).Date;
                //DateTime fecha3 = fecha1.AddDays(-1);
                String fecha2 = String.Format("{0:yyyy-MM-dd}",fecha1);
                this.lblFechaCont.Text = fecha2;
            };

            actionSheetDatePicker1.Picker.ValueChanged += (s, e) => {
                DateTime fecha1 = (s as UIDatePicker).Date;
                //DateTime fecha3 = fecha1.AddDays(-1);
                String fecha2 = String.Format("{0:yyyy-MM-dd}",fecha1);
                this.lblFechaCompr.Text = fecha2;
            };

            String categoria="";
            pickerDataModelCategories.ValueChanged += (sender, e) => {
                categoria = pickerDataModelCategories.SelectedItem.idCategoria;
                this.lblCategoria.Text = pickerDataModelCategories.SelectedItem.ToString();
            };

            String prioridad = "";
            pickerDataModel.ValueChanged += (sender, e) => {
                prioridad = pickerDataModel.SelectedItem.idPrioridad;
                this.lblPrioridad.Text = pickerDataModel.SelectedItem.ToString();
            };

            String responsable = "";
            pickerDataModelResponsibles.ValueChanged += (sender, e) => {
                responsable = pickerDataModelResponsibles.SelectedItem.UserID;
                this.lblResponsable.Text = pickerDataModelResponsibles.SelectedItem.ToString();
            };

            String idPadron ="";
            pickerDataModelPeople.ValueChanged += (sender, e) => {
                idPadron = pickerDataModelPeople.SelectedItem.idPadron;
                this.cmpSolicitante.Text = pickerDataModelPeople.SelectedItem.ToString();
            };

            this.btnBuscar.TouchUpInside += (sender, e) => {
                try{
                    peopleService = new PeopleService();
                    peopleService.FindPeople(this.cmpNombre.Text, this.cmpPaterno.Text, this.cmpMaterno.Text);

                    pickerDataModelPeople.Items = peopleService.All();
                    if(pickerDataModelPeople.Items.Count == 0){
                        UIAlertView alert = new UIAlertView(){
                            Title = "Persona no encontrada", Message = "No se encontraron resultados, intentelo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }else {
                        actionSheetPicker = new ActionSheetPicker(this.View);
                        actionSheetPicker.Picker.Source = pickerDataModelPeople;
                        actionSheetPicker.Show();
                    }
                } catch(System.Net.WebException){
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "No se pueden cargar los datos, verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                } catch(System.Exception){
                    UIAlertView alert = new UIAlertView(){
                        Title = "Lo sentimos", Message = "Ocurrio un problema de ejecucion, intentelo de nuevo"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            this.cmpSolicitante.Enabled = false;

            //Se crea el boton para enviar la informacion al servidor
            this.btnGuardar.TouchUpInside += (sender, e) => {
                try{
                    newTaskService = new NewTaskService();
                    String respuesta = newTaskService.SetData(cmpTitulo.Text, cmpDescripcion.Text,categoria,responsable,prioridad,lblFechaCont.Text,lblFechaCompr.Text,idPadron,MainView.user
                                           ,cmpTelCasa.Text,cmpTelCel.Text,cmpCorreo.Text,lblLatitud.Text,lblLongitud.Text);
                    if (respuesta.Equals("0")){
                        UIAlertView alert = new UIAlertView(){
                            Title = "ERROR", Message = "Error del Servidor, intentelo de nuevo"
                        };
                        alert.AddButton("Aceptar");
                        alert.Show();
                    }else if(respuesta.Equals("1")){
                        UIAlertView alert = new UIAlertView(){
                            Title = "Correcto", Message = "La tarea ha sido guardada correctamente"
                        };
                        alert.AddButton("Aceptar");
                        alert.Clicked += (s, o) => {
                            if(o.ButtonIndex==0){
                                NavigationController.PopViewControllerAnimated(true);
                            }
                        };
                        alert.Show();
                    }
                }catch(System.Net.WebException ex){
                    Console.WriteLine(ex.ToString());
                    UIAlertView alert = new UIAlertView(){
                        Title = "ERROR", Message = "Error del Servidor, intentelo de nuevo, o verifique su conexión a internet"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            //Se establece un borde para el textarea de las observaciones
            this.cmpObservaciones.Layer.BorderWidth = 1.0f;
            this.cmpObservaciones.Layer.BorderColor = UIColor.Gray.CGColor;
            this.cmpObservaciones.Layer.ShadowColor = UIColor.Black.CGColor;
            this.cmpObservaciones.Layer.CornerRadius = 8;
        }