Exemplo n.º 1
0
 private void ToolbarItem_Activated_1(object sender, EventArgs e)
 {
     control.ShowLoading("Actualizando...");
     getPersonalInfo();
     getExpedient();
     getVital();
 }
Exemplo n.º 2
0
 private async void Searchlist_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     if (e.Item == null)
     {
         return;
     }
     else
     {
         var list   = (ListView)sender;
         var tapped = (list.SelectedItem as Pacientes);
         if (origen.Text == "quotes")
         {
             await Navigation.PushAsync(new addQuotes(tapped.nombres, tapped.apellidos, tapped.idpaciente));
         }
         else if (origen.Text == "consults")
         {
             await Navigation.PushAsync(new AddConsult(tapped.nombres, tapped.apellidos, tapped.idpaciente));
         }
         else if (origen.Text == "lists")
         {
             control.ShowLoading("Registrando");
             Lista_Item_Espera empleados = new Lista_Item_Espera
             {
                 nombre     = tapped.nombres,
                 apellido   = tapped.apellidos,
                 idpaciente = tapped.idpaciente,
                 idlista    = ids
             };
             Functions create = new Functions();
             await create.Insert(empleados, "/Api/item_espera/create.php");
         }
     }
 }
Exemplo n.º 3
0
        public MainPage()
        {
            MaterialControls control = new MaterialControls();

            control.ShowLoading("Obteniendo datos...");
            InitializeComponent();
        }
        private async void getQuotes()
        {
            try
            {
                control.ShowLoading("Obteniendo lista");

                string url = baseurl + "/Api/pending_quotes/read.php?idempleado=5";

                HttpClient          client  = new HttpClient();
                HttpResponseMessage connect = await client.GetAsync(url);

                if (connect.StatusCode == HttpStatusCode.OK)
                {
                    var response = await client.GetStringAsync(url);

                    var quotes = JsonConvert.DeserializeObject <List <Pending> >(response);
                    mylist.ItemsSource = quotes;
                }
                else
                {
                    mylist.IsVisible  = false;
                    message.IsVisible = true;
                }
            }
            catch (HttpRequestException e)
            {
                await DisplayAlert("error", "" + e, "Ok");
            }
        }
Exemplo n.º 5
0
        private void TapGestureRecognizer_Tapped(object sender, EventArgs e)
        {
            MaterialControls control = new MaterialControls();

            control.ShowLoading("Cerrando sesion...");
            var sessionDeleted = CrossSecureStorage.Current.DeleteKey("SessionActive");

            if (sessionDeleted == true)
            {
                var idDeleted     = CrossSecureStorage.Current.DeleteKey("iduser");
                var PermisDeleted = CrossSecureStorage.Current.DeleteKey("permisos");
                var nameDeleted   = CrossSecureStorage.Current.DeleteKey("user");
                if (idDeleted == true && PermisDeleted == true && nameDeleted == true)
                {
                    Navigation.PushAsync(new Login());
                }
                else
                {
                    control.ShowSnackBar("Algunos datos no se borraron con exito");
                    Navigation.PushAsync(new Login());
                }
            }
            else
            {
                control.ShowAlert("Ocurrio un error al cerrar sesion. Reinicie la app e intentelo de nuevo", "Error", "ok");
            }
        }
Exemplo n.º 6
0
        public Waiting_Item_List(int id)
        {
            ids = id;
            control.ShowLoading("Obteniendo lista de espera");
            InitializeComponent();
            baseurl = get.BaseUrl;
            bool result = get.TestConnection();

            if (result == true)
            {
                getLists(ids);
            }
            else
            {
                control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok");
            }
        }
Exemplo n.º 7
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            MaterialControls control = new MaterialControls();

            control.ShowLoading("Iniciando sesion...");
            BaseUrl get        = new BaseUrl();
            string  url        = get.url;
            var     usuario    = user.Text;
            var     contraseña = password.Text;

            if (string.IsNullOrEmpty(usuario) || string.IsNullOrEmpty(contraseña))
            {
                message.IsVisible = true;
            }
            else
            {
                CheckUrlConnection test = new CheckUrlConnection();
                bool inf = test.TestConnection();
                if (inf == true)
                {
                    Usuario users = new Usuario()
                    {
                        user_Name     = usuario,
                        user_Password = contraseña
                    };

                    HttpClient client = new HttpClient();

                    string controlador = "/Api/usuario/auth_users.php";
                    client.BaseAddress = new Uri(url);

                    string json    = JsonConvert.SerializeObject(users);
                    var    content = new StringContent(json, Encoding.UTF8, "application/json");

                    var response = await client.PostAsync(controlador, content);


                    if (response.IsSuccessStatusCode)
                    {
                        var res = await response.Content.ReadAsStringAsync();

                        var result = res.ToString().Replace('"', ' ').Trim();
                        App.Current.Properties["name"]       = result;
                        App.Current.Properties["IsLoggedIn"] = true;
                        iml.ShowMainPage();
                    }
                    else
                    {
                        control.ShowAlert("Los datos estan incorrectos", "Error", "Ok");
                    }
                }
                else
                {
                    control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok");
                }
            }
        }
Exemplo n.º 8
0
        public Home()
        {
            control.ShowLoading("Obteniendo datos...");
            InitializeComponent();
            baseurl = get.BaseUrl;
            bool result = get.TestConnection();

            if (result == true)
            {
                getQuotes();
            }
            else
            {
                control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok");
            }
        }
Exemplo n.º 9
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            try
            {
                control.ShowLoading("Registrando");


                Usuario citas = new Usuario
                {
                    user_Name     = username.Text,
                    user_Password = pass.Text,
                    email         = "*****@*****.**",
                    user_type     = 2
                };



                HttpClient client      = new HttpClient();
                BaseUrl    get         = new BaseUrl();
                string     url         = get.url;
                string     controlador = "/Api/usuario/create_user.php";
                client.BaseAddress = new Uri(url);

                string json    = JsonConvert.SerializeObject(citas);
                var    content = new StringContent(json, Encoding.UTF8, "application/json");

                var response = await client.PostAsync(controlador, content);

                if (response.IsSuccessStatusCode)
                {
                    control.ShowAlert("Registrado", "Exito", "Ok");
                    username.Text = "";
                    pass.Text     = "";
                    ids           = 0;
                }
                else
                {
                    control.ShowAlert("Ocurrio un error al registrar", "Error", "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Ocurrio un error " + ex, "Error", "Ok");
            }
        }
Exemplo n.º 10
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            try
            {
                MaterialControls control = new MaterialControls();
                control.ShowLoading("Registrando...");
                string     date      = DateTime.Today.ToString("yy/MM/dd");
                string     hour      = DateTime.Now.ToString("hh:mm");
                VitalSigns consultas = new VitalSigns
                {
                    altura        = float.Parse(alt.Text),
                    peso          = float.Parse(pes.Text),
                    fecha         = date,
                    temperatura   = float.Parse(temp.Text),
                    frec_Cardiaca = float.Parse(frec.Text),
                    presion       = float.Parse(pres.Text),
                    pulso         = float.Parse(pul.Text),
                    idpaciente    = Convert.ToInt32(id_paciente.Text)
                };



                HttpClient client      = new HttpClient();
                string     controlador = "/Api/perfil_paciente/create.php";
                client.BaseAddress = new Uri(baseurl);

                string json    = JsonConvert.SerializeObject(consultas);
                var    content = new StringContent(json, Encoding.UTF8, "application/json");

                var response = await client.PostAsync(controlador, content);

                if (response.IsSuccessStatusCode)
                {
                    control.ShowAlert("Registrado", "Exito", "Ok");
                }
                else
                {
                    control.ShowAlert("Ocurrio un error al registrar", "Error", "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Ocurrio un error" + ex, "Error", "Ok");
            }
        }
Exemplo n.º 11
0
        void OnClick(object sender, EventArgs e)
        {
            ToolbarItem tbi = (ToolbarItem)sender;

            if (tbi.Text == "Cerrar Sesion")
            {
                MaterialControls control = new MaterialControls();
                control.ShowLoading("Cerrando sesion...");
            }
            else if (tbi.Text == "Acerca de")
            {
                Navigation.PushModalAsync(new Info());
            }
            else if (tbi.Text == "Perfil")
            {
                Navigation.PushAsync(new Account());
            }
        }
Exemplo n.º 12
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            try
            {
                MaterialControls control = new MaterialControls();

                control.ShowLoading("Registrando");
                string  date      = fech.Date.ToString("yy/MM/dd");
                string  hora      = Convert.ToString(hour.Time);
                Pending pacientes = new Pending();

                pacientes.fecha      = date;
                pacientes.hora       = hora;
                pacientes.idpaciente = Convert.ToInt32(id);
                pacientes.idempleado = ids;
                pacientes.tipo       = 2;

                HttpClient client = new HttpClient();

                string controlador = "/Api/pending_quotes/create.php";
                client.BaseAddress = new Uri(baseurl);

                string json    = JsonConvert.SerializeObject(pacientes);
                var    content = new StringContent(json, Encoding.UTF8, "application/json");

                var response = await client.PostAsync(controlador, content);

                if (response.IsSuccessStatusCode)
                {
                    control.ShowAlert("Enviado!!", "Exito", "Ok");
                }
                else
                {
                    control.ShowAlert("Ocurrio un error al registrar!!", "Error", "Ok");
                }
            }
            catch (Exception ex)
            {
                await DisplayAlert("Ocurrio un error", "Error: " + ex, "Ok");
            }
        }
Exemplo n.º 13
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            MaterialControls control = new MaterialControls();

            control.ShowLoading("Verificando...");
            BaseUrl get     = new BaseUrl();
            string  baseurl = get.url;
            var     id      = dui.Text;


            CheckUrlConnection test = new CheckUrlConnection();
            bool inf = test.TestConnection();

            if (inf == true)
            {
                ;
                string url = baseurl + "/Api/paciente/verify.php?dui=" + id;

                HttpClient          client  = new HttpClient();
                HttpResponseMessage connect = await client.GetAsync(url);

                if (connect.StatusCode == HttpStatusCode.OK)
                {
                    var response = await client.GetStringAsync(url);

                    var lista = JsonConvert.DeserializeObject <Pacientes>(response);

                    var idpaciente = lista.idpaciente;
                    await Navigation.PushAsync(new Register(idpaciente));
                }
                else
                {
                    control.ShowAlert("Lo sentimos usted no esta registrado", "Error", "ok");
                }
            }
            else
            {
                control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok");
            }
        }
Exemplo n.º 14
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            control.ShowLoading("Iniciando sesion...");
            var usuario    = user.Text;
            var contraseña = password.Text;

            if (string.IsNullOrEmpty(usuario) || string.IsNullOrEmpty(contraseña))
            {
                //message.IsVisible = true;
            }
            else
            {
                bool inf = get.TestConnection();
                if (inf == true)
                {
                    Usuario users = new Usuario()
                    {
                        user_Name     = usuario,
                        user_Password = contraseña
                    };

                    HttpClient client = new HttpClient();

                    string controlador = "/Api/usuario/auth_admin.php";
                    client.BaseAddress = new Uri(baseurl);

                    string json     = JsonConvert.SerializeObject(users);
                    var    content  = new StringContent(json, Encoding.UTF8, "application/json");
                    var    response = await client.PostAsync(controlador, content);

                    if (response.IsSuccessStatusCode)
                    {
                        var res = await response.Content.ReadAsStringAsync();

                        var result          = JsonConvert.DeserializeObject <Usuario>(res);
                        var iduser          = Convert.ToString(result.iduser);
                        var permisos        = Convert.ToString(result.valor);
                        var userName        = Convert.ToString(result.user_Name);
                        var idespecialidad  = Convert.ToString(result.idespecialidad);
                        var sessionCreated  = CrossSecureStorage.Current.SetValue("SessionActive", "true");
                        var idCreated       = CrossSecureStorage.Current.SetValue("iduser", iduser);
                        var permisosCreated = CrossSecureStorage.Current.SetValue("permisos", permisos);
                        var userCreated     = CrossSecureStorage.Current.SetValue("user", userName);
                        var idespcreated    = CrossSecureStorage.Current.SetValue("idespecialidad", idespecialidad);
                        var sessionToken    = CrossSecureStorage.Current.GetValue("SessionActive");
                        if (sessionToken == "true" && sessionCreated == true && idCreated == true && permisosCreated == true && userCreated == true && idespcreated == true)
                        {
                            await Navigation.PushAsync(new MainPage());
                        }
                        else
                        {
                            control.ShowAlert("Hubo un error al crear la sesion", "Error", "Ok");
                        }
                    }
                    else
                    {
                        control.ShowAlert("Los datos estan incorrectos", "Error", "Ok");
                    }
                }
                else
                {
                    control.ShowAlert("No se pudo conectar con el servidor", "Error", "Ok");
                }
            }
        }
Exemplo n.º 15
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(nombre.Text) &&
                String.IsNullOrWhiteSpace(codigo.Text) &&
                String.IsNullOrWhiteSpace(cant.Text) &&
                String.IsNullOrWhiteSpace(price.Text)
                )
            {
                var alertDialogConfiguration = new MaterialAlertDialogConfiguration
                {
                    BackgroundColor  = Color.FromHex("#c62828"),
                    TitleTextColor   = Color.White,
                    MessageTextColor = Color.FromHex("#DEFFFFFF"),
                    TintColor        = Color.White,
                    CornerRadius     = 8,
                    ScrimColor       = Color.FromHex("#232F34").MultiplyAlpha(0.32),
                    ButtonAllCaps    = false
                };

                await MaterialDialog.Instance.AlertAsync(message : "Llene los campos",
                                                         title : "Alerta",
                                                         acknowledgementText : "Ok",
                                                         configuration : alertDialogConfiguration);
            }
            else if (String.IsNullOrWhiteSpace(nombre.Text))
            {
                control.ShowAlert("Campo Nombre medicamento es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(price.Text))
            {
                control.ShowAlert("Campo Precio es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(cant.Text))
            {
                control.ShowAlert("Campo cantidad es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(codigo.Text))
            {
                control.ShowAlert("Campo codigo es obligatorio!!", "Error", "Ok");
            }
            else
            {
                try
                {
                    MaterialControls control = new MaterialControls();
                    control.ShowLoading("Registrando");
                    string       date  = fecha.Date.ToString("dd/MM/yy");
                    Medicamentos citas = new Medicamentos
                    {
                        nom_Medicamento = nombre.Text,
                        cod_Medicamento = codigo.Text,
                        cantidad        = Convert.ToInt32(cant.Text),
                        precio_U        = float.Parse(price.Text),
                        fecha_V         = date
                    };

                    HttpClient client      = new HttpClient();
                    string     controlador = "/Api/medicamentos/create.php";
                    client.BaseAddress = new Uri(baseurl);

                    string json    = JsonConvert.SerializeObject(citas);
                    var    content = new StringContent(json, Encoding.UTF8, "application/json");

                    var response = await client.PostAsync(controlador, content);

                    if (response.IsSuccessStatusCode)
                    {
                        control.ShowAlert("Registrado!!", "Exito", "Ok");
                    }
                    else
                    {
                        control.ShowAlert("Ocurrio un error al registrar!!", "Error", "Ok");
                    }
                } catch (Exception ex) {
                    await DisplayAlert("Ocurrio un error " + ex, "Error", "Ok");
                }
            }
        }
Exemplo n.º 16
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(title.Text) && String.IsNullOrWhiteSpace(description.Text))
            {
                var alertDialogConfiguration = new MaterialAlertDialogConfiguration
                {
                    BackgroundColor  = Color.FromHex("#c62828"),
                    TitleTextColor   = Color.White,
                    MessageTextColor = Color.FromHex("#DEFFFFFF"),
                    TintColor        = Color.White,
                    CornerRadius     = 8,
                    ScrimColor       = Color.FromHex("#232F34").MultiplyAlpha(0.32),
                    ButtonAllCaps    = false
                };

                await MaterialDialog.Instance.AlertAsync(message : "Llene los campos",
                                                         title : "Alerta",
                                                         acknowledgementText : "Ok",
                                                         configuration : alertDialogConfiguration);
            }
            else if (String.IsNullOrWhiteSpace(description.Text))
            {
                control.ShowAlert("Campo Descripcion es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(title.Text))
            {
                control.ShowAlert("Campo Titulo es obligatorio!!", "Error", "Ok");
            }
            else
            {
                try
                {
                    control.ShowLoading("Publicando..");
                    Models.Tips citas = new Models.Tips
                    {
                        titulo      = title.Text,
                        descripcion = description.Text
                    };



                    HttpClient client      = new HttpClient();
                    string     controlador = "/Api/tips/create.php";
                    client.BaseAddress = new Uri(baseurl);

                    string json    = JsonConvert.SerializeObject(citas);
                    var    content = new StringContent(json, Encoding.UTF8, "application/json");

                    var response = await client.PostAsync(controlador, content);

                    if (response.IsSuccessStatusCode)
                    {
                        control.ShowAlert("Publicado!!", "Exito", "Ok");
                    }
                    else
                    {
                        control.ShowAlert("Ocurrio un error al publicar!!", "Error", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Ocurrio un error " + ex, "Error", "Ok");
                }
            }
        }
Exemplo n.º 17
0
        private async void Mylist_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            try
            {
                if (e != null)
                {
                    MaterialControls control = new MaterialControls();
                    var config = new MaterialInputDialogConfiguration()
                    {
                        InputType             = MaterialTextFieldInputType.Numeric,
                        CornerRadius          = 8,
                        BackgroundColor       = Color.FromHex("#2c3e50"),
                        InputTextColor        = Color.White,
                        InputPlaceholderColor = Color.White.MultiplyAlpha(0.6),
                        TintColor             = Color.White,
                        TitleTextColor        = Color.White,
                        MessageTextColor      = Color.FromHex("#DEFFFFFF")
                    };

                    var res = await MaterialDialog.Instance.InputAsync(title : "Aceptar cita",
                                                                       message : "Para aceptar la cita ingrese el numero de consultorio",
                                                                       inputPlaceholder : "Consultorio",
                                                                       confirmingText : "Aceptar",
                                                                       configuration : config);

                    if (res != "")
                    {
                        control.ShowLoading("Aceptando cita");
                        var list      = (ListView)sender;
                        var selection = list.SelectedItem as Pending;


                        string              url4     = baseurl + "/Api/empleado/read_one.php?idempleado=" + CrossSecureStorage.Current.GetValue("iduser");
                        HttpClient          client3  = new HttpClient();
                        HttpResponseMessage connect3 = await client3.GetAsync(url4);

                        if (connect3.StatusCode == HttpStatusCode.OK)
                        {
                            var response3 = await client3.GetStringAsync(url4);

                            var personal = JsonConvert.DeserializeObject <Empleados>(response3);
                            var nombres  = personal.nombres;

                            string url = baseurl + "/Api/pending_quotes/delete.php?idpending=" + selection.idpending;

                            HttpClient          client  = new HttpClient();
                            HttpResponseMessage connect = await client.GetAsync(url);

                            if (connect.StatusCode == HttpStatusCode.OK)
                            {
                                Citas citas = new Citas
                                {
                                    fecha_Cita        = selection.fecha,
                                    hora_Cita         = selection.hora,
                                    nombre_Paciente   = selection.nombre,
                                    apellido_Paciente = selection.apellido,
                                    num_Consultorio   = Convert.ToInt32(res),
                                    idpaciente        = selection.idpaciente,
                                    idempleado        = Convert.ToInt32(CrossSecureStorage.Current.GetValue("iduser"))
                                };



                                HttpClient cliente     = new HttpClient();
                                string     controlador = "/Api/citas/create.php";
                                cliente.BaseAddress = new Uri(baseurl);

                                string json    = JsonConvert.SerializeObject(citas);
                                var    content = new StringContent(json, Encoding.UTF8, "application/json");

                                var result = await cliente.PostAsync(controlador, content);

                                if (result.IsSuccessStatusCode)
                                {
                                    control.ShowAlert("Registrado!!", "Exito", "Ok");
                                }
                                else
                                {
                                    control.ShowAlert("Ocurrio un error al registrar", "Error", "Ok");
                                }
                            }
                            else
                            {
                                control.ShowAlert("Ocurrio un error al eliminar", "Error", "Ok");
                            }
                        }
                        else
                        {
                            control.ShowSnackBar("Se cancelo");
                        }
                        getQuotes();
                    }
                }
            }
            catch (Exception ex)
            {
                await  DisplayAlert("Error", "Error: " + ex, "ok");
            }
        }
Exemplo n.º 18
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(nombre.Text) || String.IsNullOrWhiteSpace(number.Text))
            {
                var alertDialogConfiguration = new MaterialAlertDialogConfiguration
                {
                    BackgroundColor  = Color.FromHex("#c62828"),
                    TitleTextColor   = Color.White,
                    MessageTextColor = Color.FromHex("#DEFFFFFF"),
                    TintColor        = Color.White,
                    CornerRadius     = 8,
                    ScrimColor       = Color.FromHex("#232F34").MultiplyAlpha(0.32),
                    ButtonAllCaps    = false
                };

                await MaterialDialog.Instance.AlertAsync(message : "Llene los campos",
                                                         title : "Alerta",
                                                         acknowledgementText : "Ok",
                                                         configuration : alertDialogConfiguration);
            }
            else if (TextValidator.Ok == false || NumeroValidator.Ok == false)
            {
                var alertDialogConfiguration = new MaterialAlertDialogConfiguration
                {
                    BackgroundColor  = Color.FromHex("#c62828"),
                    TitleTextColor   = Color.White,
                    MessageTextColor = Color.FromHex("#DEFFFFFF"),
                    TintColor        = Color.White,
                    CornerRadius     = 8,
                    ScrimColor       = Color.FromHex("#232F34").MultiplyAlpha(0.32),
                    ButtonAllCaps    = false
                };
                await MaterialDialog.Instance.AlertAsync(message : "Al paracer algunos campos estan incorrectos",
                                                         title : "Alerta",
                                                         acknowledgementText : "Ok", configuration : alertDialogConfiguration);
            }
            else
            {
                try
                {
                    control.ShowLoading("Registrando");
                    Lista_Espera empleados = new Lista_Espera
                    {
                        nombre          = nombre.Text,
                        num_Consultorio = Convert.ToInt32(number.Text)
                    };



                    HttpClient client      = new HttpClient();
                    string     controlador = "/Api/lista_espera/create.php";
                    client.BaseAddress = new Uri(baseurl);

                    string json    = JsonConvert.SerializeObject(empleados);
                    var    content = new StringContent(json, Encoding.UTF8, "application/json");

                    var response = await client.PostAsync(controlador, content);

                    if (response.IsSuccessStatusCode)
                    {
                        control.ShowAlert("Agregado!!", "Exito", "Ok");
                    }
                    else
                    {
                        control.ShowAlert("Ocurrio un error al agregar!!", "Error", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Ocurrio un error", "Error " + ex, "Ok");
                }
            }
        }
Exemplo n.º 19
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(p_nombre.Text) &&
                String.IsNullOrWhiteSpace(p_apellido.Text) &&
                String.IsNullOrWhiteSpace(Convert.ToString(p_sexo.SelectedItem)) &&
                String.IsNullOrWhiteSpace(Convert.ToString(p_estado.SelectedItem)) &&
                String.IsNullOrWhiteSpace(p_correo.Text) &&
                String.IsNullOrWhiteSpace(p_departamento.Text) &&
                String.IsNullOrWhiteSpace(p_direccion.Text) &&
                String.IsNullOrWhiteSpace(p_telefono.Text) &&
                String.IsNullOrWhiteSpace(p_dui.Text) &&
                String.IsNullOrWhiteSpace(p_municipio.Text))

            {
                var alertDialogConfiguration = new MaterialAlertDialogConfiguration
                {
                    BackgroundColor  = Color.FromHex("#c62828"),
                    TitleTextColor   = Color.White,
                    MessageTextColor = Color.FromHex("#DEFFFFFF"),
                    TintColor        = Color.White,
                    CornerRadius     = 8,
                    ScrimColor       = Color.FromHex("#232F34").MultiplyAlpha(0.32),
                    ButtonAllCaps    = false
                };

                await MaterialDialog.Instance.AlertAsync(message : "Llene todos los campos",
                                                         title : "Alerta",
                                                         acknowledgementText : "Ok",
                                                         configuration : alertDialogConfiguration);
            }
            else if (String.IsNullOrWhiteSpace(p_nombre.Text))
            {
                control.ShowAlert("Campo Nombre es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(p_apellido.Text))
            {
                control.ShowAlert("Campo Apellido es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(Convert.ToString(p_sexo.SelectedItem)))
            {
                control.ShowAlert("Seleccione un sexo", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(Convert.ToString(p_estado.SelectedItem)))
            {
                control.ShowAlert("Seleccione un estado", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(p_dui.Text))
            {
                control.ShowAlert("Campo Dui es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(p_telefono.Text))
            {
                control.ShowAlert("Campo telefono es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(p_correo.Text))
            {
                control.ShowAlert("Campo correo es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(p_departamento.Text))
            {
                control.ShowAlert("Campo departamento es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(p_municipio.Text))
            {
                control.ShowAlert("Campo Municipio es obligatorio!!", "Error", "Ok");
            }
            else if (String.IsNullOrWhiteSpace(p_direccion.Text))
            {
                control.ShowAlert("Campo Direccion es obligatorio!!", "Error", "Ok");
            }
            else if (TextValidator.Ok == false || ValidateEmail.Ok == false || NumeroValidator.Ok == false)
            {
                var alertDialogConfiguration = new MaterialAlertDialogConfiguration
                {
                    BackgroundColor  = Color.FromHex("#c62828"),
                    TitleTextColor   = Color.White,
                    MessageTextColor = Color.FromHex("#DEFFFFFF"),
                    TintColor        = Color.White,
                    CornerRadius     = 8,
                    ScrimColor       = Color.FromHex("#232F34").MultiplyAlpha(0.32),
                    ButtonAllCaps    = false
                };



                await MaterialDialog.Instance.AlertAsync(message : "Al paracer algunos campos estan incorrectos",
                                                         title : "Alerta",
                                                         acknowledgementText : "Ok",
                                                         configuration : alertDialogConfiguration);
            }
            else
            {
                try
                {
                    MaterialControls control = new MaterialControls();
                    control.ShowLoading("Registrando");
                    string    fecha     = p_nac.Date.ToString("yy/MM/dd");
                    Pacientes pacientes = new Pacientes
                    {
                        idpaciente   = ids,
                        nombres      = p_nombre.Text,
                        apellidos    = p_apellido.Text,
                        fecha_Nac    = fecha,
                        sexo         = Convert.ToString(p_sexo.SelectedItem),
                        estado_Civil = Convert.ToString(p_estado.SelectedItem),
                        dui          = p_dui.Text,
                        telefono     = p_telefono.Text,
                        email        = p_correo.Text,
                        departamento = p_departamento.Text,
                        municipio    = p_municipio.Text,
                        direccion    = p_direccion.Text
                    };



                    HttpClient client      = new HttpClient();
                    string     controlador = "/Api/paciente/update.php";
                    client.BaseAddress = new Uri(baseurl);

                    string json    = JsonConvert.SerializeObject(pacientes);
                    var    content = new StringContent(json, Encoding.UTF8, "application/json");

                    var response = await client.PutAsync(controlador, content);

                    if (response.IsSuccessStatusCode)
                    {
                        control.ShowAlert("Actualizado", "Exito", "Ok");
                    }
                    else
                    {
                        control.ShowAlert("Ocurrio un error al actualizar", "Error", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Ocurrio un error " + ex, "Error", "Ok");
                }
            }
        }
Exemplo n.º 20
0
 private void ImageButton_Clicked(object sender, EventArgs e)
 {
     control.ShowLoading("Cerrando sesion...");
     App.Current.Logout();
 }