コード例 #1
0
ファイル: DataOrden.cs プロジェクト: game8149/MinLab
        public bool EliminarOrdenFromBD(Orden orden)
        {
            SqlConnection conexion = new SqlConnection();
            SqlCommand    comando  = new SqlCommand();

            try
            {
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                comando.Connection        = conexion;
                comando.CommandText       = ProcDel.DEL_ORDENCAB;
                comando.CommandType       = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@idOrden", orden.IdData);
                comando.Connection.Open();

                comando.ExecuteNonQuery();
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }

            return(true);
        }
コード例 #2
0
        public Cuenta GetCuentaByDni(string dni)
        {
            Cuenta        cuenta   = null;
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_CUENTA;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@dni", dni);

            comando.Connection.Open();
            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                cuenta                 = new Cuenta();
                cuenta.IdData          = Convert.ToInt32(resultado["id"]);
                cuenta.Nombre          = resultado["nombre"].ToString();
                cuenta.PrimerApellido  = resultado["primerApellido"].ToString();
                cuenta.SegundoApellido = resultado["segundoApellido"].ToString();
                cuenta.Especialidad    = resultado["especialidad"].ToString();
                cuenta.CodigoPro       = resultado["codigo"].ToString();
                cuenta.Dni             = dni;
                cuenta.Clave           = resultado["clave"].ToString();
                cuenta.Nivel           = (SesionNivel)Convert.ToInt32((resultado["nivel"].ToString()));
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(cuenta);
        }
コード例 #3
0
        public static bool ExistenExamenes(OrdenDetalle ordenDetalle)
        {
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_EXAMENCAB_EXISTE;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idOrdenDetalle", ordenDetalle.IdData);

            comando.Connection.Open();
            SqlDataReader resultado = comando.ExecuteReader();
            int           count     = 0;

            while (resultado.Read())
            {
                count = Convert.ToInt32(resultado["num"]);
            }

            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(count > 0);
        }
コード例 #4
0
        public Dictionary <int, Sector> GetSectorAll(int idDistrito)
        {
            Sector sector = null;
            Dictionary <int, Sector> temp     = new Dictionary <int, Sector>();
            SqlConnection            conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_SECTOR_BYDISTRITO;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("idDistrito", idDistrito);

            comando.Connection.Open();
            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                sector            = new Sector();
                sector.IdData     = Convert.ToInt32(resultado["id"]);
                sector.Nombre     = resultado["nombre"].ToString();
                sector.IdDistrito = Convert.ToInt32(resultado["idDistrito"]);


                temp.Add(sector.IdData, sector);
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(temp);
        }
コード例 #5
0
ファイル: DataOrden.cs プロジェクト: game8149/MinLab
        public Dictionary <int, int> GetReporteCantidadFromDB(int cobertura, int año, int mes)
        {
            Dictionary <int, int> detalles = new Dictionary <int, int>();
            SqlConnection         conexion = new SqlConnection();
            SqlCommand            comando  = new SqlCommand();

            try
            {
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                comando.Connection        = conexion;
                comando.CommandText       = ProcGet.GET_REPORTE_CANTIDADMES;
                comando.Parameters.AddWithValue("@cobertura", cobertura);
                comando.Parameters.AddWithValue("@ano", año);
                comando.Parameters.AddWithValue("@mes", mes);
                comando.CommandType = CommandType.StoredProcedure;
                comando.Connection.Open();
                SqlDataReader resultado = comando.ExecuteReader();
                while (resultado.Read())
                {
                    detalles.Add(Convert.ToInt32(resultado["idPaquete"]), Convert.ToInt32(resultado["cantidad"]));
                }

                resultado.Close();
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }
            return(detalles);
        }
コード例 #6
0
ファイル: FormConfigServer.cs プロジェクト: game8149/MinLab
        public FormConfigServer()
        {
            InitializeComponent();
            this.FormClosing += FormConfigServer_FormClosing;

            CampConexion.Text = ConfiguracionDataAccess.GetInstance().CadenaConexion;
        }
コード例 #7
0
        public string GetSeguridad(Cuenta cuenta)
        {
            string        codigo   = null;
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_SEGURIDAD;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idCuenta", cuenta.IdData);

            comando.Connection.Open();
            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                codigo = resultado["code"].ToString();
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(codigo);
        }
コード例 #8
0
ファイル: DataAnalisis.cs プロジェクト: game8149/MinLab
        public static List <int> GetCodPruebaByPaquete(int idData)
        {
            List <int>    cods     = new List <int>();
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            try
            {
                comando.Connection  = conexion;
                comando.CommandText = ProcGet.GET_PLANTILLA_COD_BYPAQUETE;
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@idPaquete", idData);

                comando.Connection.Open();
                SqlDataReader resultado = comando.ExecuteReader();
                while (resultado.Read())
                {
                    cods.Add(Convert.ToInt32(resultado["id"]));
                }
                resultado.Close();
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }
            return(cods);
        }
コード例 #9
0
ファイル: DataAnalisis.cs プロジェクト: game8149/MinLab
        public static void UpdTarifarioVigente(Tarifario tar)
        {
            SqlConnection conexion = new SqlConnection();

            SqlCommand comando = new SqlCommand();

            try
            {
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                comando.Connection        = conexion;

                comando.CommandText = ProcUpd.UPD_TARIFARIOCAB_VIGENTE;
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@ID", tar.IdData);
                comando.Connection.Open();
                comando.ExecuteNonQuery();
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }
        }
コード例 #10
0
ファイル: DataAnalisis.cs プロジェクト: game8149/MinLab
        public static bool GetCheckTarifarioByAño(int ano)
        {
            bool          count    = false;
            SqlConnection conexion = new SqlConnection();

            SqlCommand comando = new SqlCommand();

            try
            {
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                comando.Connection        = conexion;
                comando.CommandText       = ProcGet.GET_TARIFARIOCAB_CHECK_BYYEAR;
                comando.CommandType       = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@YEAR", ano);
                comando.Connection.Open();
                SqlDataReader resultado = comando.ExecuteReader();
                while (resultado.Read())
                {
                    count = Convert.ToBoolean(resultado["count"]);
                }
                resultado.Close();
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }
            return(count);
        }
コード例 #11
0
        public static int AddPaciente(Paciente paciente)
        {
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();


            comando.Connection  = conexion;
            comando.CommandText = ProcAdd.ADD_PACIENTE;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@hc", paciente.Historia);
            comando.Parameters.AddWithValue("@nombre", paciente.Nombre);
            comando.Parameters.AddWithValue("@apellidoP", paciente.PrimerApellido);
            comando.Parameters.AddWithValue("@apellidoM", paciente.SegundoApellido);
            comando.Parameters.AddWithValue("@direccion", paciente.Direccion);
            comando.Parameters.AddWithValue("@sexo", paciente.Sexo);
            comando.Parameters.AddWithValue("@fechaNac", paciente.FechaNacimiento);
            comando.Parameters.AddWithValue("@dni", paciente.Dni);
            comando.Parameters.AddWithValue("@idDistrito", paciente.IdDistrito);
            comando.Parameters.AddWithValue("@idSector", paciente.IdSector);
            comando.Parameters.Add("@id", SqlDbType.Int).Direction = ParameterDirection.Output;

            comando.Connection.Open();
            comando.ExecuteNonQuery();
            int idPaciente = Convert.ToInt32(comando.Parameters["@id"].Value);

            conexion.Close();
            comando.Dispose();
            return(idPaciente);
        }
コード例 #12
0
        public Dictionary <int, Medico> GetAllMedico()
        {
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando            = new SqlCommand();
            Dictionary <int, Medico> temp = new Dictionary <int, Medico>();
            Medico tempMed;

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_MEDICO_ALL;
            comando.CommandType = CommandType.StoredProcedure;

            comando.Connection.Open();
            SqlDataReader d = comando.ExecuteReader();

            while (d.Read())
            {
                tempMed                 = new Medico();
                tempMed.IdData          = Convert.ToInt32(d["id"]);
                tempMed.Nombre          = d["nombre"].ToString();
                tempMed.PrimerApellido  = d["primerApellido"].ToString();
                tempMed.SegundoApellido = d["segundoApellido"].ToString();
                tempMed.Colegiatura     = d["colegiatura"].ToString().Trim();
                tempMed.Especialidad    = d["especialidad"].ToString();
                tempMed.Habil           = Convert.ToBoolean(d["habil"]);
                temp.Add(tempMed.IdData, tempMed);
            }

            conexion.Close();
            comando.Dispose();
            return(temp);
        }
コード例 #13
0
        public static Dictionary <int, ExamenDetalle> GetExamenDetalleByExamen(Examen examen)
        {
            Dictionary <int, ExamenDetalle> examenDetalles            = new Dictionary <int, ExamenDetalle>();
            Dictionary <int, ExamenDetalle> examenDetallesIndexByItem = new Dictionary <int, ExamenDetalle>();
            ExamenDetalle detalle  = null;
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_EXAMENDET_BYEXAMENCAB;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idExamen", examen.IdData);

            comando.Connection.Open();
            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                detalle        = new ExamenDetalle();
                detalle.IdData = Convert.ToInt32(resultado["id"]);
                detalle.IdItem = Convert.ToInt32(resultado["idItem"]);
                detalle.Campo  = resultado["respuesta"].ToString();
                examenDetalles.Add(detalle.IdItem, detalle);
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(examenDetalles);
        }
コード例 #14
0
        public static bool ActualizarPaciente(Paciente paciente)
        {
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcUpd.UPD_PACIENTE;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@id", paciente.IdData);
            comando.Parameters.AddWithValue("@hc", paciente.Historia);
            comando.Parameters.AddWithValue("@nombre", paciente.Nombre);
            comando.Parameters.AddWithValue("@apellidoP", paciente.PrimerApellido);
            comando.Parameters.AddWithValue("@apellidoM", paciente.SegundoApellido);
            comando.Parameters.AddWithValue("@direccion", paciente.Direccion);
            comando.Parameters.AddWithValue("@sexo", paciente.Sexo);
            comando.Parameters.AddWithValue("@fechaNac", paciente.FechaNacimiento);
            comando.Parameters.AddWithValue("@dni", paciente.Dni);
            comando.Parameters.AddWithValue("@idDistrito", paciente.IdDistrito);
            comando.Parameters.AddWithValue("@idSector", paciente.IdSector);

            comando.Connection.Open();
            comando.ExecuteNonQuery();
            conexion.Close();
            comando.Dispose();
            return(true);
        }
コード例 #15
0
        public Dictionary <int, Distrito> GetDistritoAll()
        {
            Distrito distrito = null;
            Dictionary <int, Distrito> temp = new Dictionary <int, Distrito>();
            SqlConnection conexion          = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_DISTRITO_ALL;
            comando.CommandType = CommandType.StoredProcedure;

            comando.Connection.Open();
            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                distrito          = new Distrito();
                distrito.IdData   = Convert.ToInt32(resultado["id"]);
                distrito.Nombre   = resultado["nombre"].ToString();
                distrito.Sectores = GetSectorAll(distrito.IdData);
                temp.Add(distrito.IdData, distrito);
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(temp);
        }
コード例 #16
0
        public bool CheckExistCuenta(string dni)
        {
            bool existe = false;

            try
            {
                SqlConnection conexion = new SqlConnection();
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                SqlCommand comando = new SqlCommand();

                comando.Connection  = conexion;
                comando.CommandText = ProcGet.GET_CUENTA_EXISTE;
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@dni", dni);

                comando.Connection.Open();
                SqlDataReader resultado = comando.ExecuteReader();
                while (resultado.Read())
                {
                    existe = (Convert.ToInt32(resultado["num"]) > 0);
                }
                resultado.Close();
                conexion.Close();
                comando.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            return(existe);
        }
コード例 #17
0
        public static Dictionary <int, PlantillaItemList> GetListItemByItem(int idData)
        {
            Dictionary <int, PlantillaItemList> opciones = new Dictionary <int, PlantillaItemList>();
            PlantillaItemList opcion   = null;
            SqlConnection     conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_LISTA_BYITEM;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idItem", idData);

            comando.Connection.Open();
            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                opcion        = new PlantillaItemList();
                opcion.IdData = Convert.ToInt32(resultado["id"]);
                opcion.Nombre = resultado["nombre"].ToString();
                opcion.Indice = Convert.ToInt32(resultado["indice"]);
                opciones.Add(opcion.IdData, opcion);
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(opciones);
        }
コード例 #18
0
        //SE OBTIENE UN DICTIONARY INDEXADA POR POSICION DE FILAS GRUPO
        public static Dictionary <int, PlantillaFila> GetPlantillaFilasGrupo(int idData)
        {
            Dictionary <int, PlantillaFila> detalles = new Dictionary <int, PlantillaFila>();
            PlantillaFilaGrupo fila;

            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_GRUPO_BYPLANTILLA;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idPlantilla", idData);
            comando.Connection.Open();

            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                fila        = new PlantillaFilaGrupo();
                fila.Tipo   = PlantillaFila.PlantillaFilaTipo.Agrupada;
                fila.Indice = Convert.ToInt32(resultado["indice"]);
                fila.IdData = Convert.ToInt32(resultado["id"]);
                fila.Nombre = resultado["nombre"].ToString();
                fila.Items  = GetItemByGrupo(((PlantillaFilaGrupo)fila).IdData);
                detalles.Add(fila.Indice, fila);
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();
            conexion.Dispose();

            return(detalles);
        }
コード例 #19
0
        public static Dictionary <int, PlantillaItem> GetAllItemsByPlantillaFromDB(int IdPlantilla)
        {
            PlantillaItem item = new PlantillaItem();
            Dictionary <int, PlantillaItem> items = new Dictionary <int, PlantillaItem>();
            SqlConnection conexion  = null;
            SqlCommand    comando   = null;
            SqlDataReader resultado = null;

            conexion = new SqlConnection();
            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_ITEM_ALL_BYPLANTILLA;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idPlantilla", IdPlantilla);

            comando.Connection.Open();
            resultado = comando.ExecuteReader();
            while (resultado.Read())
            {
                item.IdData   = Convert.ToInt32(resultado["id"]);
                item.TipoDato = (TipoDato)Convert.ToInt32(resultado["tipoDato"]);
                items.Add(item.IdData, item);
            }
            resultado.Close();
            comando.Connection.Close();
            comando.Dispose();
            return(items);
        }
コード例 #20
0
ファイル: DataConsultorio.cs プロジェクト: game8149/MinLab
        public static Dictionary <int, Consultorio> GetConsultorioAll()
        {
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();
            Dictionary <int, Consultorio> temp = new Dictionary <int, Consultorio>();
            Consultorio tempConsul;

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_CONSULTORIO_ALL;
            comando.CommandType = CommandType.StoredProcedure;

            comando.Connection.Open();
            SqlDataReader d = comando.ExecuteReader();

            while (d.Read())
            {
                tempConsul        = new Consultorio();
                tempConsul.IdData = Convert.ToInt32(d["id"]);
                tempConsul.Nombre = d["nombre"].ToString();
                temp.Add(tempConsul.IdData, tempConsul);
            }

            conexion.Close();
            comando.Dispose();
            return(temp);
        }
コード例 #21
0
        public Medico GetMedico(int ID)
        {
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();
            Medico     tempMed = null;

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_MEDICO;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@ID", ID);
            comando.Connection.Open();
            SqlDataReader d = comando.ExecuteReader();

            while (d.Read())
            {
                tempMed                 = new Medico();
                tempMed.IdData          = Convert.ToInt32(d["id"]);
                tempMed.Nombre          = d["nombre"].ToString();
                tempMed.PrimerApellido  = d["primerApellido"].ToString();
                tempMed.SegundoApellido = d["segundoApellido"].ToString();
                tempMed.Colegiatura     = d["colegiatura"].ToString().Trim();
                tempMed.Especialidad    = d["especialidad"].ToString();
                tempMed.Habil           = Convert.ToBoolean(d["habil"]);
            }

            conexion.Close();
            comando.Dispose();

            return(tempMed);
        }
コード例 #22
0
        //SE OBTIENE UN DICTIONARY INDEXADA POR POSICION DE FILAS SIMPLES
        public static Dictionary <int, PlantillaFila> GetPlantillaFilaSimple(int idData)
        {
            Dictionary <int, PlantillaFila> detalles = new Dictionary <int, PlantillaFila>();
            PlantillaFilaSimple             fila;
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            int indiceItem = 0, idPlantilla = idData;

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_ITEM_BYPLANTILLA;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@idPlantilla", idData);
            comando.Connection.Open();

            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                fila        = new PlantillaFilaSimple();
                fila.Indice = Convert.ToInt32(resultado["indice"]);
                fila.Tipo   = PlantillaFila.PlantillaFilaTipo.Simple;

                fila.Item             = new PlantillaItem();
                fila.Item.IdData      = Convert.ToInt32(resultado["id"]);
                fila.Item.Nombre      = resultado["nombre"].ToString();
                fila.Item.PorDefault  = resultado["porDefault"].ToString();
                fila.Item.TipoDato    = (TipoDato)Convert.ToInt32(resultado["idTipoItem"]);
                fila.Item.TipoCampo   = (TipoCampo)Convert.ToInt32(resultado["idTipoCampo"]);
                fila.Item.TieneUnidad = Convert.ToBoolean(resultado["tieneUnidad"]);
                fila.Item.Unidad      = resultado["unidad"].ToString();
                switch (fila.Item.TipoCampo)
                {
                case TipoCampo.Lista:
                    fila.Item.Opciones = GetListItemByItem(fila.Item.IdData);
                    break;
                }

                try
                {
                    indiceItem = fila.Indice;
                    detalles.Add(fila.Indice, fila);
                }
                catch (SqlException e)
                {
                    throw new Exception(e.Message);
                }
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(detalles);
        }
コード例 #23
0
        public static Plantilla GetPlantilla(string codigo)
        {
            Plantilla plantilla = null;

            SqlConnection conexion  = null;
            SqlCommand    comando   = null;
            SqlDataReader resultado = null;

            conexion = new SqlConnection();
            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText = ProcGet.GET_PLANTILLA;
            comando.CommandType = CommandType.StoredProcedure;
            comando.Parameters.AddWithValue("@codigo", codigo);

            comando.Connection.Open();
            resultado = comando.ExecuteReader();
            while (resultado.Read())
            {
                plantilla = new Plantilla();
                plantilla.IdDataPlantilla = Convert.ToInt32(resultado["id"]);
                plantilla.Codigo          = resultado["codigo"].ToString();
                plantilla.Nombre          = resultado["nombre"].ToString();

                plantilla.TieneItems  = Convert.ToBoolean(resultado["tieneItem"]);
                plantilla.TieneGrupos = Convert.ToBoolean(resultado["tieneGrupo"]);
                plantilla.Filas       = new Dictionary <int, PlantillaFila>();

                Dictionary <int, PlantillaFila> temp;
                if (plantilla.TieneGrupos)
                {
                    temp = GetPlantillaFilasGrupo(plantilla.IdDataPlantilla);
                    foreach (PlantillaFila detalle in temp.Values)
                    {
                        plantilla.Filas.Add(detalle.Indice, detalle);
                    }
                }

                if (plantilla.TieneItems)
                {
                    temp = GetPlantillaFilaSimple(plantilla.IdDataPlantilla);
                    foreach (PlantillaFila detalle in temp.Values)
                    {
                        plantilla.Filas.Add(detalle.Indice, detalle);
                    }
                }
                plantilla.IndexarByItem();
            }
            resultado.Close();
            comando.Connection.Close();
            comando.Dispose();
            return(plantilla);
        }
コード例 #24
0
ファイル: DataOrden.cs プロジェクト: game8149/MinLab
        //OPERACIONES ORDEN
        public int CrearOrdenToBD(Orden orden)
        {
            SqlConnection conexion = new SqlConnection();
            SqlCommand    comando  = new SqlCommand();

            try
            {
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                DataTable tabla = new DataTable();
                tabla.Columns.Add("idTemp", typeof(int));
                tabla.Columns.Add("idPaquete", typeof(int));
                tabla.Columns.Add("cobertura", typeof(int));
                foreach (OrdenDetalle k in orden.Detalle.Values)
                {
                    DataRow row = tabla.NewRow();
                    row[0] = 0;
                    row[1] = k.IdDataPaquete;
                    row[2] = k.Cobertura;
                    tabla.Rows.Add(row);
                }

                comando.Connection  = conexion;
                comando.CommandText = ProcAdd.ADD_ORDENCAB;
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@numero", orden.Boleta);
                comando.Parameters.AddWithValue("@fecha", orden.FechaRegistro);
                comando.Parameters.AddWithValue("@ultimaModificacion", orden.UltimaModificacion);
                comando.Parameters.AddWithValue("@estado", orden.Estado);
                comando.Parameters.AddWithValue("@idPaciente", orden.IdPaciente);
                comando.Parameters.AddWithValue("@gestante", orden.EnGestacion);
                comando.Parameters.AddWithValue("@idConsultorio", orden.IdConsultorio);
                comando.Parameters.AddWithValue("@idMedico", orden.IdMedico);
                comando.Parameters.Add("@id", SqlDbType.Int).Direction       = ParameterDirection.Output;
                comando.Parameters.AddWithValue("@detalle", tabla).SqlDbType = SqlDbType.Structured;

                comando.Connection.Open();
                comando.ExecuteNonQuery();
                orden.IdData = Convert.ToInt32(comando.Parameters["@id"].Value);
            }
            catch (SqlException e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
                throw new Exception(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }

            return(orden.IdData);
        }
コード例 #25
0
ファイル: DataOrden.cs プロジェクト: game8149/MinLab
        public List <int[]> GetReporteEdadFromDB(int cobertura, int año, int mes)
        {
            SqlConnection conexion = new SqlConnection();
            SqlCommand    comando  = new SqlCommand();
            List <int[]>  general  = new List <int[]>();

            try
            {
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                comando.Connection        = conexion;
                comando.CommandText       = ProcGet.GET_REPORTE_EDAD;
                comando.Parameters.AddWithValue("@cobertura", cobertura);
                comando.Parameters.AddWithValue("@ano", año);
                comando.Parameters.AddWithValue("@mes", mes);
                comando.CommandType = CommandType.StoredProcedure;
                comando.Connection.Open();
                SqlDataReader resultado = comando.ExecuteReader();
                while (resultado.Read())
                {
                    int[] row = new int[34];

                    int i = 0;
                    row[i] = Convert.ToInt32(resultado["idPaquete"]);
                    i++;
                    for (; i <= 20; i++)
                    {
                        row[i] = Convert.ToInt32(resultado["c" + (i - 1)]);
                    }
                    for (int k = 20; k < 76; k += 5, i++)
                    {
                        row[i] = Convert.ToInt32(resultado["c" + k]);
                    }
                    row[i] = Convert.ToInt32(resultado["c80"]);

                    general.Add(row);
                }

                resultado.Close();
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }
            return(general);
        }
コード例 #26
0
 private void btnSaveSitio_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txtSitio.Text.Trim() != "" && txtNombre.Text.Trim() != "")
         {
             if (txtSitio.Text.Trim().Length == 4)
             {
                 //Guardar
                 ConfigDA = new ConfiguracionDataAccess();
                 Feed2Service.tbl_ConfigSitio mdl = new Feed2Service.tbl_ConfigSitio();
                 mdl.vchClaveSitio   = txtSitio.Text.Trim().ToUpper();
                 mdl.vchnombreSitio  = txtNombre.Text.ToUpper();
                 mdl.bitActivo       = true;
                 mdl.datFechaSistema = DateTime.Now;
                 mdl.vchUserAdmin    = "ADMINISTRADOR";
                 bool               success  = false;
                 string             mensaje  = "";
                 int                id_sitio = 0;
                 ClienteF2CResponse response = new ClienteF2CResponse();
                 response = ConfigDA.setConfiguracion(mdl, ref mensaje, ref id_sitio);
                 if (response.valido)
                 {
                     MessageBox.Show("Cambios correctos.");
                     MainWindow main = new MainWindow();
                     main.Show();
                     main.txtSitio.Text = txtSitio.Text;
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("Existe un error al guardar la información: " + mensaje, "Error");
                 }
             }
             else
             {
                 MessageBox.Show("Se debe capturar 4 caracteres para la clave del Sitio. ");
             }
         }
         else
         {
             MessageBox.Show("Se requiere capturar la clave para el Sitio.");
         }
     }
     catch (Exception ebSS)
     {
         MessageBox.Show("Existe un error al iniciar el sitio: " + ebSS.Message);
     }
 }
コード例 #27
0
ファイル: DataOrden.cs プロジェクト: game8149/MinLab
        public Dictionary <int, Orden> GetAllOrdenByPacienteByFechaByEstado(Paciente pa, DateTime init, DateTime end, EstadoOrden estado)
        {
            Dictionary <int, Orden> ordenes  = new Dictionary <int, Orden>();
            SqlConnection           conexion = new SqlConnection();
            SqlCommand comando = new SqlCommand();
            Orden      orden   = null;

            try
            {
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                comando.Connection        = conexion;
                comando.CommandText       = ProcGet.GET_ORDENCAB_ALL_BYPACIENTE_BYFECHA_BYESTADO;

                comando.Parameters.AddWithValue("@idPaciente", pa.IdData);
                comando.Parameters.AddWithValue("@estado", estado);
                comando.Parameters.AddWithValue("@fechaInit", init);
                comando.Parameters.AddWithValue("@fechaEnd", end);
                comando.CommandType = CommandType.StoredProcedure;

                comando.Connection.Open();
                SqlDataReader resultado = comando.ExecuteReader();
                while (resultado.Read())
                {
                    orden                    = new Orden();
                    orden.Boleta             = resultado["numero"].ToString();
                    orden.FechaRegistro      = Convert.ToDateTime(resultado["fechaRegistro"]);
                    orden.IdPaciente         = Convert.ToInt32(resultado["idPaciente"]);;
                    orden.IdData             = Convert.ToInt32(resultado["id"]);
                    orden.Estado             = (EstadoOrden)Convert.ToInt32(resultado["estado"]);
                    orden.UltimaModificacion = Convert.ToDateTime(resultado["ultimaModificacion"]);
                    orden.EnGestacion        = Convert.ToBoolean(resultado["gestante"]);
                    orden.IdMedico           = Convert.ToInt32(resultado["idMedico"]);
                    orden.IdConsultorio      = Convert.ToInt32(resultado["idConsultorio"]);
                    orden.Detalle            = ObtenerOrdenDetalleByOrden(orden.IdData);
                    ordenes.Add(orden.IdData, orden);
                }
                resultado.Close();
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }
            return(ordenes);
        }
コード例 #28
0
ファイル: DataAnalisis.cs プロジェクト: game8149/MinLab
        public static void AddTarifario(Tarifario tar)
        {
            SqlConnection conexion = new SqlConnection();

            SqlCommand comando = new SqlCommand();

            try
            {
                DataTable detalleTemp = new DataTable();
                detalleTemp.Columns.Add("ID", typeof(int));
                detalleTemp.Columns.Add("PRECIO", typeof(double));
                detalleTemp.Columns.Add("IDPAQUETE", typeof(int));
                detalleTemp.Columns.Add("IDTARIFARIOCAB", typeof(int));


                foreach (TarifarioDetalle det in tar.Listado.Values)
                {
                    DataRow row = detalleTemp.NewRow();
                    row[0] = 0;
                    row[1] = det.Precio;
                    row[2] = det.IdPaquete;
                    row[3] = det.IdTarifarioCab;
                    detalleTemp.Rows.Add(row);
                }


                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                comando.Connection        = conexion;
                comando.CommandText       = ProcAdd.ADD_TARIFARIOCAB;
                comando.CommandType       = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("@vigente", tar.Vigente);
                comando.Parameters.AddWithValue("@ano", tar.Año);
                comando.Parameters.AddWithValue("@FECHAREG", tar.FechaRegistro);
                comando.Parameters.AddWithValue("@DETALLE", detalleTemp).SqlDbType = SqlDbType.Structured;
                MessageBox.Show("");
                comando.Connection.Open();
                comando.ExecuteNonQuery();
            }
            catch (SqlException e)
            {
                MessageBox.Show(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }
        }
コード例 #29
0
        public static Dictionary <int, Paciente> GetPacientesByFiltro(string dni, string historia, string nombre, string apellidoM, string apellidoP)
        {
            Dictionary <int, Paciente> diccionario = new Dictionary <int, Paciente>();
            //Por el momento no se pudo hacer en procedimiento almacenado...
            SqlConnection conexion = new SqlConnection();

            conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
            SqlCommand comando = new SqlCommand();

            comando.Connection  = conexion;
            comando.CommandText =
                "select id,hclinica,nombre,apellido2,apellido1,Paciente.direccion,Paciente.fechaNacimiento,dni,Paciente.sexo,Paciente.idDistrito,Paciente.idSector " +
                "from Paciente where " +
                "hclinica like '" + historia + "%' and " +
                "dni like '" + dni + "%' and " +
                "nombre like '" + nombre + "%' and " +
                "apellido2 like '" + apellidoM + "%' and " +
                "apellido1 like '" + apellidoP + "%'";

            comando.CommandType = CommandType.Text;

            comando.Connection.Open();
            SqlDataReader resultado = comando.ExecuteReader();

            while (resultado.Read())
            {
                Paciente paciente = new Paciente();
                paciente.IdData          = Convert.ToInt32(resultado["id"]);
                paciente.Nombre          = resultado["nombre"].ToString();
                paciente.SegundoApellido = resultado["apellido2"].ToString();
                paciente.PrimerApellido  = resultado["apellido1"].ToString();
                paciente.Direccion       = resultado["direccion"].ToString();
                paciente.Historia        = resultado["hclinica"].ToString();
                paciente.Dni             = resultado["dni"].ToString();
                paciente.Sexo            = (Sexo)Convert.ToInt32(resultado["sexo"]);
                paciente.FechaNacimiento = Convert.ToDateTime(resultado["fechaNacimiento"]);
                paciente.IdDistrito      = Convert.ToInt32(resultado["idDistrito"]);
                paciente.IdSector        = Convert.ToInt32(resultado["idSector"]);

                diccionario.Add(paciente.IdData, paciente);
            }
            resultado.Close();
            conexion.Close();
            comando.Dispose();

            return(diccionario);
        }
コード例 #30
0
ファイル: DataOrden.cs プロジェクト: game8149/MinLab
        public List <object[]> GetReporteResultadoFromDB(int año, int mes)
        {
            SqlConnection   conexion = new SqlConnection();
            SqlCommand      comando  = new SqlCommand();
            List <object[]> general  = new List <object[]>();

            try
            {
                conexion.ConnectionString = ConfiguracionDataAccess.GetInstance().CadenaConexion;
                comando.Connection        = conexion;
                comando.CommandText       = ProcGet.GET_REPORTE_RESULTADO;
                comando.Parameters.AddWithValue("@ano", año);
                comando.Parameters.AddWithValue("@mes", mes);
                comando.CommandType = CommandType.StoredProcedure;
                comando.Connection.Open();
                SqlDataReader resultado = comando.ExecuteReader();
                while (resultado.Read())
                {
                    object[] row = new object[12];

                    row[0]  = Convert.ToInt32(resultado["idPlantilla"]);
                    row[1]  = resultado["dni"];
                    row[2]  = resultado["nombre"].ToString();
                    row[3]  = resultado["apellido1"].ToString();
                    row[4]  = resultado["apellido2"].ToString();
                    row[5]  = Convert.ToDouble(resultado["edad"]);
                    row[6]  = Convert.ToInt32(resultado["sexo"]);
                    row[7]  = Convert.ToBoolean(resultado["gestante"]);
                    row[8]  = resultado["respuesta"].ToString();
                    row[9]  = resultado["unidad"].ToString();
                    row[10] = Convert.ToInt32(resultado["cobertura"]);
                    row[11] = Convert.ToInt32(resultado["estado"]);
                    general.Add(row);
                }
                resultado.Close();
            }
            catch (SqlException e)
            {
                throw new Exception(e.Message);
            }
            finally
            {
                conexion.Close();
                comando.Dispose();
            }
            return(general);
        }