Exemple #1
0
        private async void Listo_Click(object sender, RoutedEventArgs e)
        {
            int id = 0;// crear campos para id

            if (!String.IsNullOrEmpty(diagnostico.Text))
            {
                Loading.Visibility = Visibility.Visible;
                SantaTeclaService service = new SantaTeclaService();

                Pacientes pac = await service.GetPacienteById(id);

                pac.Historial.Antecendentes = diagnostico.Text;

                if (await service.PutPaciente(id, pac))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Paciente actualizado con éxito", "Todo bien", MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Ha ocurrido un error", "Oups", MessageBoxButton.OK,
                                                      MessageBoxImage.Error);
                }
                Loading.Visibility = Visibility.Collapsed;
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Hay un cuadro vacio", "Algo ha pasado", MessageBoxButton.OK,
                                                  MessageBoxImage.Error);
            }
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(info.Text))
            {
                Loading.Visibility = Visibility.Visible;
                id = int.Parse(Id.Text);
                SantaTeclaService service = new SantaTeclaService();

                Pacientes pac = await service.GetPacienteById(id);

                pac.Historial.Antecendentes = info.Text;

                if (await service.PutPaciente(id, pac))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("El paciente ha sido actualizado con éxito", "Éxito", MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Ha ocurrido un error", "Error", MessageBoxButton.OK,
                                                      MessageBoxImage.Error);
                }
                Loading.Visibility = Visibility.Collapsed;
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Algun cuadro esta vacio", "Un error vacio", MessageBoxButton.OK,
                                                  MessageBoxImage.Error);
            }
        }
Exemple #3
0
        public async Task <int> AccessAsync(string user, string password)
        {
            SantaTeclaService service  = new SantaTeclaService();
            string            personal = await service.AuthUser(user, password);

            if (personal != null)
            {
                switch (personal)
                {
                case "doctor":
                    return(10);

                case "dietetica":
                    return(4);

                case "enfermero":
                    return(7);

                case "recepcion":
                    return(1);

                case "cocina":
                    return(4);

                case "farmacia":
                    return(12);

                case "administracion":
                    return(14);
                }
            }

            return(0);
        }
        private async void Agregar_Click(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(referencia.Text))
            {
                int id = int.Parse(referencia.Text);
                Loading.Visibility = Visibility.Visible;
                SantaTeclaService service = new SantaTeclaService();
                var medicamento           = await service.GetMedicamentosByNameOrId(id);

                medicamento.Cantidad = int.Parse(cantidad.Text);
                if (await service.PutMedicamento(id, medicamento))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Se ha agregado", "Todo bien", MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Error al agregar", "Un error ha surgido", MessageBoxButton.OK,
                                                      MessageBoxImage.Error);
                }
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Falto referencia", "Suele ocurrir", MessageBoxButton.OK,
                                                  MessageBoxImage.Stop);
            }

            Loading.Visibility = Visibility.Collapsed;
        }
        private async Task GetData()
        {
            SantaTeclaService sevice = new SantaTeclaService();

            if (_quien == 0)
            {
                ListPacientes.ItemsSource = await sevice.GetPacientes();
            }
            else
            {
                ListPacientes.ItemsSource = await sevice.GetPersonal();
            }
            Ok.Click += (sender, args) =>
            {
                if (ListPacientes.SelectedItem != null)
                {
                    OnItemSelected?.Invoke(this, new ItemSelectedEventArgs
                    {
                        Objecto = ListPacientes.SelectedItem
                    });
                    this.Close();
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Selecciones una opcion", "Informacion de ayuda", MessageBoxButton.OK,
                                                      MessageBoxImage.Stop);
                }
            };
        }
        private async Task DeleteById(int id)
        {
            SantaTeclaService service = new SantaTeclaService();

            if (Personal.IsChecked == true)
            {
                if (await service.DeletePersonal(int.Parse(IdToDelete.Text)))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Paciente eliminado con éxito", "Listo", MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Error al eliminar", "Un error ha surgido", MessageBoxButton.OK,
                                                      MessageBoxImage.Error);
                }
                Loading.Visibility = Visibility.Collapsed;
            }
            else
            {
                if (await service.DeletePaciente(int.Parse(IdToDelete.Text)))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Empleado eliminado", "Buenas noticias", MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Error al eliminar", "Houston tenemos un problema", MessageBoxButton.OK,
                                                      MessageBoxImage.Error);
                }
                Loading.Visibility = Visibility.Collapsed;
            }
        }
Exemple #7
0
        private async Task GetDataPer()
        {
            SantaTeclaService sev = new SantaTeclaService();
            var personal          = await sev.GetPersonalById(StaticHelper.SelectedId);

            string info =
                $"Informacion del personal: Nombre: {personal.Nombre} \n{personal.Apellidos} \npuesto: {personal.Puesto}\nUsuario: {personal.Login.User}";

            infoText.Text      = info;
            Loading.Visibility = Visibility.Collapsed;
        }
Exemple #8
0
        private async Task GetDataPac()
        {
            SantaTeclaService sev = new SantaTeclaService();
            var paciente          = await sev.GetPacienteById(StaticHelper.SelectedId);

            string info =
                $"Informacion del paciente: {paciente.Nombre} de {paciente.Edad} años\nANTECEDENTES\n{paciente.Historial.Antecendentes}\nCONTRADICCIONES\n{paciente.Historial.Contradicciones}\nNo. Cama: {paciente.Internado.IdCama}  No.Edificio: {paciente.Internado.IdEdificio}";

            infoText.Text      = info;
            Loading.Visibility = Visibility.Collapsed;
        }
Exemple #9
0
        private async static void Comprobar()
        {
            SantaTeclaService service = new SantaTeclaService();
            var respuesta             = Console.ReadLine();

            if (respuesta == "2")
            {
                var test = await service.AuthUser("farmacia", "098");

                if (test != null)
                {
                    System.Console.WriteLine($"Logue");
                }
            }
        }
Exemple #10
0
        private async void Generar_ClickAsync(object sender, RoutedEventArgs e)
        {
            int id;

            if (!String.IsNullOrEmpty(IdPaciente.Text))
            {
                id = StaticHelper.SelectedId = int.Parse(IdPaciente.Text);
                SantaTeclaService service = new SantaTeclaService();

                Pacientes pac = await service.GetPacienteById(int.Parse(IdPaciente.Text));

                if (Alergia.IsChecked == true)
                {
                    pac.Historial.Contradicciones += "\nAlergico";
                }
                if (comida.IsChecked == true)
                {
                    pac.Historial.Antecendentes += "\ndieta si restricciones";
                }
                if (OperaCompl.IsChecked == true)
                {
                    pac.Historial.Antecendentes += "\nHistorial de Operacion Complicada";
                }
                if (OperaNorm.IsChecked == true)
                {
                    pac.Historial.Antecendentes += "\nHistorial de Operacion Normal";
                }
                Loading.Visibility = Visibility.Visible;
                if (await service.PutPaciente(id, pac))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Se ha agregado al historial", "Un caso de éxito", MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                    Loading.Visibility = Visibility.Collapsed;
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Error al guardar", "Upssss", MessageBoxButton.OK,
                                                      MessageBoxImage.Error);
                }
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Falta ID", "Oye te falto algo...", MessageBoxButton.OK,
                                                  MessageBoxImage.Information);
            }
        }
        private async void Consultar_Click(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(referencia.Text))
            {
                int id = int.Parse(referencia.Text);
                Loading.Visibility = Visibility.Visible;
                SantaTeclaService service = new SantaTeclaService();
                var medicamento           = await service.GetMedicamentosByNameOrId(id);

                Xceed.Wpf.Toolkit.MessageBox.Show($"Cantidad disponible: {medicamento.Cantidad}", "Informacion solicitada", MessageBoxButton.OK,
                                                  MessageBoxImage.Information);
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Falto referencia", "Upssss", MessageBoxButton.OK,
                                                  MessageBoxImage.Stop);
            }
            Loading.Visibility = Visibility.Collapsed;
        }
        private async void Aceptar_Click(object sender, RoutedEventArgs e)
        {
            SantaTeclaService service = new SantaTeclaService();

            Loading.Visibility = Visibility.Visible;
            Personal personal = new Personal
            {
                Nombre    = nombre.Text,
                Apellidos = apellido.Text,
                Puesto    = puesto.SelectionBoxItem as string,
                Login     = new Models.Login {
                    User = usuario.Text, Password = contra.Text
                }
            };

            var lista = await service.GetPersonal();

            var objTemp = lista.FirstOrDefault(persona => persona.Login.User == usuario.Text);

            if (objTemp == null)
            {
                if (await service.PostPersonal(personal))
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("Personal agregado con éxito", "Todo salio bien", MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                }
                else
                {
                    Xceed.Wpf.Toolkit.MessageBox.Show("El usuario no ha sido agregado", "Error", MessageBoxButton.OK,
                                                      MessageBoxImage.Error);
                }
                //MessageBox.Show("El usuario no ha sido registrado", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("El usuario ya existe", "Advertencia", MessageBoxButton.OK,
                                                  MessageBoxImage.Warning);
            }
            Loading.Visibility = Visibility.Collapsed;
        }
        private async void Cerrar_Click(object sender, RoutedEventArgs e)
        {
            Loading.Visibility = Visibility.Visible;
            SantaTeclaService ser = new SantaTeclaService();
            var paciente          = await ser.GetPacienteById(StaticHelper.SelectedId);

            paciente.Historial.Contradicciones += "\n" + contradicciones.Text;
            if (await ser.PutPaciente(StaticHelper.SelectedId, paciente))
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Guardado con éxito", "Whooou", MessageBoxButton.OK,
                                                  MessageBoxImage.Information);
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("No se ha podido guardar", "Que mal (Error)", MessageBoxButton.OK,
                                                  MessageBoxImage.Error);
            }
            LoginPage login = new LoginPage();

            login.Show();
            this.Close();
        }
        private async void Agregar_Click(object sender, RoutedEventArgs e)
        {
            if (!String.IsNullOrEmpty(nombre.Text) || !String.IsNullOrEmpty(direccion.Text))
            {
                Loading.Visibility = Visibility.Visible;
                SantaTeclaService serv = new SantaTeclaService();
                var pac = new Pacientes();
                if (refAct == 1)
                {
                    id  = int.Parse(IdToSearch.Text);
                    pac = await serv.GetPacienteById(id);

                    pac.Nombre                   = nombre.Text;
                    pac.Edad                     = int.Parse(edad.Text);
                    pac.Direccion                = direccion.Text;
                    pac.FormaDePago              = _pay;
                    pac.Historial.Antecendentes += "\n" + historial.Text;
                    pac.Sexo                     = sexMasc.IsChecked.Value ? "masculino" : "femenino";
                    if (await serv.BedCheck(int.Parse(Edificio.Text), int.Parse(Cama.Text), id))
                    {
                        pac.Internado.IdCama     = int.Parse(Cama.Text);
                        pac.Internado.IdEdificio = int.Parse(Edificio.Text);
                        if (await serv.PutPaciente(id, pac))
                        {
                            Xceed.Wpf.Toolkit.MessageBox.Show("Paciente actualizado con éxito", "Nueva version", MessageBoxButton.OK,
                                                              MessageBoxImage.Information);
                        }
                        else
                        {
                            Xceed.Wpf.Toolkit.MessageBox.Show("Error verifica los campos", "Puede que haya algo mal", MessageBoxButton.OK,
                                                              MessageBoxImage.Error);
                        }
                    }
                    else
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show("Esta cama aun no esta disponible", "Aun no", MessageBoxButton.OK,
                                                          MessageBoxImage.Stop);
                    }
                }
                else
                {
                    pac.Nombre      = nombre.Text;
                    pac.Edad        = int.Parse(edad.Text);
                    pac.Direccion   = direccion.Text;
                    pac.FormaDePago = _pay;
                    pac.Historial   = new Historial()
                    {
                        Antecendentes = historial.Text
                    };

                    pac.Sexo  = sexMasc.IsChecked.Value ? "masculino" : "femenino";
                    pac.Citas = new Citas()
                    {
                        Fecha      = DateTime.Now.ToString(),
                        IdPersonal = 0,
                        NoCita     = 0
                    };

                    if (await serv.BedCheck(int.Parse(Edificio.Text), int.Parse(Cama.Text), id))
                    {
                        pac.Internado = new Internado()
                        {
                            IdCama      = int.Parse(Cama.Text),
                            IdEdificio  = int.Parse(Cama.Text),
                            IdInternado = 0
                        };
                        if (await serv.PostPaciente(pac))
                        {
                            Xceed.Wpf.Toolkit.MessageBox.Show("Paciente agregado", "Genial", MessageBoxButton.OK,
                                                              MessageBoxImage.Information);
                            nombre.Text    = "";
                            edad.Text      = "";
                            direccion.Text = "";
                            historial.Text = "";
                        }
                        else
                        {
                            Xceed.Wpf.Toolkit.MessageBox.Show("Error", "Aqui tenemos un error", MessageBoxButton.OK,
                                                              MessageBoxImage.Error);
                        }
                    }
                    else
                    {
                        Xceed.Wpf.Toolkit.MessageBox.Show("La cama ingresada no esta disponible", "Algo salio mal", MessageBoxButton.OK,
                                                          MessageBoxImage.Error);
                    }
                }

                Loading.Visibility = Visibility.Collapsed;
            }
            else
            {
                Xceed.Wpf.Toolkit.MessageBox.Show("Informacion faltante", "Un error aparecio", MessageBoxButton.OK,
                                                  MessageBoxImage.Error);
            }
        }