Ejemplo n.º 1
0
        //public int AddHistoria(Pacientes pac)
        //{
        //    int estado = 0;
        //    try
        //    {
        //        if (!VerificarUsuario(pac.Cedula))
        //        {
        //            string queryPac = $"INSERT INTO PACIENTES VALUES " +
        //                $"( " +
        //                $" '{pac.Cedula}', '{pac.Nombres}', '{pac.Direccion}', '{pac.Telefono}', '{pac.FechaNacimiento.ToShortDateString()}', " +
        //                $" '{pac.Edad}', '{pac.Profesion}', '{pac.EstadoCivil}', '{pac.NumHijos}' " +
        //                $")";

        //            string queryHistoria = $"INSERT INTO HISTORIACLINICA VALUES " +
        //                $"( NULL, " +
        //                $" '{pac.HistPac.FechaRegistro}', '{pac.HistPac.DescEnfermedad}', '{pac.HistPac.OtraEnfermedad}', '{pac.HistPac.Peso}', " +
        //                $" '{pac.HistPac.Talla}', '{pac.HistPac.Altura}', '{pac.HistPac.MasaMuscular}', '{pac.HistPac.Silueta}', '{pac.HistPac.CostumbreAlimenticias}', " +
        //                $" '{pac.HistPac.ModoVida}', '{pac.HistPac.SiFuma}', '{pac.HistPac.SiAlcohol}', '{pac.HistPac.CalidadSueño}', '{pac.HistPac.DeportesPracticados}', '{pac.Cedula}' " +
        //                $")";


        //            using (var command = new MySqlCommand(queryPac, DBHelper.Conection()))
        //            {
        //                var x = command.ExecuteNonQuery();
        //                if (x > 0)
        //                {
        //                    using (var command1 = new MySqlCommand(queryHistoria, DBHelper.Conection()))
        //                    {
        //                        var y = command1.ExecuteNonQuery();
        //                        if (y > 0)
        //                        {
        //                            estado = 1;
        //                        }
        //                        else { estado = -1; }
        //                    }
        //                }
        //                else { estado = -1; }
        //            }
        //        }
        //        else { estado = 2; }
        //    }
        //    catch (System.Exception)
        //    {
        //        estado = -1;
        //    }
        //    finally { DBHelper.CloseMySql(); }
        //    return estado;
        //}


        public int AddHistoria(Pacientes pac)
        {
            int estado = 0;

            try
            {
                if (!VerificarUsuario(pac.Cedula))
                {
                    string queryPac      = "spAgregarPaciente";
                    string queryHistoria = "spGuardarHistoriaCl";

                    using (var command = new MySqlCommand(queryPac, DBHelper.Conection()))
                    {
                        command.CommandType = System.Data.CommandType.StoredProcedure;

                        //Paciente
                        command.Parameters.AddWithValue("pacedula", pac.Cedula);
                        command.Parameters.AddWithValue("panombre", pac.Nombres);
                        command.Parameters.AddWithValue("padireccion", pac.Direccion);
                        command.Parameters.AddWithValue("patelefono", pac.Telefono);
                        command.Parameters.AddWithValue("pafechana", pac.FechaNacimiento.ToShortDateString());
                        command.Parameters.AddWithValue("paedad", pac.Edad);
                        command.Parameters.AddWithValue("paprofesion", pac.Profesion);
                        command.Parameters.AddWithValue("paestadocivil", pac.EstadoCivil);
                        command.Parameters.AddWithValue("panumhijos", pac.NumHijos);

                        var x = command.ExecuteNonQuery();
                        if (x > 0)
                        {
                            using (var command1 = new MySqlCommand(queryHistoria, DBHelper.Conection()))
                            {
                                //HistoriaClinica
                                command1.CommandType = System.Data.CommandType.StoredProcedure;
                                command1.Parameters.AddWithValue("hfechare", pac.HistPac.FechaRegistro);
                                command1.Parameters.AddWithValue("hdescenfermedad", pac.HistPac.DescEnfermedad);
                                command1.Parameters.AddWithValue("hotraenfermedad", pac.HistPac.OtraEnfermedad);
                                command1.Parameters.AddWithValue("hpeso", pac.HistPac.Peso);
                                command1.Parameters.AddWithValue("htalla", pac.HistPac.Talla);
                                command1.Parameters.AddWithValue("haltura", pac.HistPac.Altura);
                                command1.Parameters.AddWithValue("hmasa", pac.HistPac.MasaMuscular);
                                command1.Parameters.AddWithValue("hsilueta", pac.HistPac.Silueta);
                                command1.Parameters.AddWithValue("hconstumbre", pac.HistPac.CostumbreAlimenticias);
                                command1.Parameters.AddWithValue("hmodovida", pac.HistPac.ModoVida);
                                command1.Parameters.AddWithValue("hfuma", pac.HistPac.SiFuma);
                                command1.Parameters.AddWithValue("halcohol", pac.HistPac.SiAlcohol);
                                command1.Parameters.AddWithValue("hsueño", pac.HistPac.CalidadSueño);
                                command1.Parameters.AddWithValue("hdeportes", pac.HistPac.DeportesPracticados);
                                command1.Parameters.AddWithValue("pacedula", pac.Cedula);
                                var y = command1.ExecuteNonQuery();
                                if (y > 0)
                                {
                                    estado = 1;
                                }
                                else
                                {
                                    estado = -1;
                                }
                            }
                        }
                        else
                        {
                            estado = -1;
                        }
                    }
                }
                else
                {
                    estado = 2;
                }
            }
            catch (System.Exception)
            {
                estado = -1;
            }
            finally { DBHelper.CloseMySql(); }
            return(estado);
        }
Ejemplo n.º 2
0
 public int AddHistoria(Pacientes pac)
 {
     return(new PacienteProtocol().AddHistoria(pac));
 }