Ejemplo n.º 1
0
        // Método para botón realizar compra
        private void button1_Click(object sender, EventArgs e)
        {
            int importeTotal = 0;

            for (int i = 0; i < Convert.ToInt32(cantBonos.Value); i++)
            {
                SqlConnection conexion = SQL_Methods.IniciarConnection();
                SqlCommand    comando  = new SqlCommand("ORACLE_FANS.darAltaBonoFarmacia", conexion);

                SqlParameter ValorDeRetorno = comando.Parameters.Add("returnParameter", SqlDbType.Int);
                ValorDeRetorno.Direction = ParameterDirection.ReturnValue;

                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.Add("@Cod_PlanMedico", SqlDbType.Int).Value = Convert.ToInt32(planMedico.Text);
                comando.Parameters.Add("@Cod_Afiliado", SqlDbType.Int).Value   = Convert.ToInt32(codigoAfiliado.Text);
                comando.Parameters.Add("@fec_imp", SqlDbType.DateTime).Value   = @Clinica_Frba.Properties.Settings.Default.Fecha.ToString();
                importeTotal += importeBono;
                comando.ExecuteReader();
                comando.Connection.Close();
            }
            MessageBox.Show("Compra realizada. Importe total: $" + Convert.ToString(importeTotal));
            SqlConnection conexion2 = SQL_Methods.IniciarConnection();
            SqlCommand    comando2  = new SqlCommand("ORACLE_FANS.agregar_compra", conexion2);

            comando2.CommandType = CommandType.StoredProcedure;
            comando2.Parameters.Add("@tipo", SqlDbType.Char).Value      = 'F';
            comando2.Parameters.Add("@cod_afi", SqlDbType.Int).Value    = Convert.ToInt32(codigoAfiliado.Text);
            comando2.Parameters.Add("@cant_bonos", SqlDbType.Int).Value = Convert.ToInt32(cantBonos.Value);
            comando2.Parameters.Add("@importe", SqlDbType.Int).Value    = importeTotal;
            comando2.Parameters.Add("@fecha", SqlDbType.DateTime).Value = @Clinica_Frba.Properties.Settings.Default.Fecha;
            comando2.ExecuteReader();
            comando2.Connection.Close();
        }
Ejemplo n.º 2
0
        // Método para cargar profesionales en la tabla
        private void cargarProfesionales()
        {
            // Conexion al server
            SqlConnection myConnection = SQL_Methods.IniciarConnection();
            string        myQuery;

            if (this.comboBox1.Text.Trim().Equals(""))
            {
                myQuery = "SELECT Matricula, Nombre, Apellido, Tipo_Documento, Numero_Documento, Direccion, Mail, Telefono, Fecha_Nac, Sexo FROM ORACLE_FANS.Profesionales " +
                          "WHERE Nombre LIKE '%" + this.box_nombre.Text.Trim() + "%' " +
                          "AND Activo = 1 " +
                          "AND Apellido LIKE '%" + this.box_apellido.Text.Trim() + "%' " +
                          "AND Matricula LIKE '%" + this.box_matricula.Text.Trim() + "%'";
            }
            else
            {
                myQuery = "SELECT P.Matricula, P.Nombre, P.Apellido, P.Tipo_Documento, P.Numero_Documento, P.Direccion, P.Mail, P.Telefono, P.Fecha_Nac, P.Sexo FROM ORACLE_FANS.Profesionales P " +
                          "JOIN ORACLE_FANS.Medico_Especialidad ME on P.Matricula = ME.Matricula " +
                          "JOIN ORACLE_FANS.Especialidades E on E.Cod_Especialidad = ME.Cod_Especialidad " +
                          "WHERE P.Nombre LIKE '%" + this.box_nombre.Text.Trim() + "%' " +
                          "AND P.Activo = 1 " +
                          "AND P.Apellido LIKE '%" + this.box_apellido.Text.Trim() + "%' " +
                          "AND P.Matricula LIKE '%" + this.box_matricula.Text.Trim() + "%' " +
                          "AND E.Descripcion = '" + this.comboBox1.Text + "'";
            }

            if (SQL_Methods.DBConnectStatus)
            {
                TablaProfesionales = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
            }
        }
Ejemplo n.º 3
0
        // Método para comprobar turno ingresado
        private bool comprobarTurno()
        {
            bool retorno = true;

            if (horaTurno.Text.Trim() == "" || minutosTurno.Text.Trim() == "")
            {
                retorno = false;
                return(retorno);
            }
            int           añoTurno = Convert.ToDateTime(fechaTurno.Text).Year;
            int           mesTurno = Convert.ToDateTime(fechaTurno.Text).Month;
            int           diaTurno = Convert.ToDateTime(fechaTurno.Text).Day;
            DateTime      fecha    = new DateTime(añoTurno, mesTurno, diaTurno);
            SqlConnection conexion = SQL_Methods.IniciarConnection();
            string        query    = "SELECT * FROM ORACLE_FANS.Turnos " +
                                     "WHERE Cod_Afiliado = " + afiliado.Text + " " +
                                     "AND Fecha = '" + fecha.ToString() + " " + horaTurno.Text + ":" + minutosTurno.Text + ":00' " +
                                     "AND habilitado = 1";

            turno = SQL_Methods.EjecutarProcedure(conexion, query);
            if (turno.Rows.Count == 0)
            {
                retorno = false;
                MessageBox.Show("La fecha del turno ingresada no es válida. Ingrese nuevamente los campos fecha, hora y minutos.");
            }
            return(retorno);
        }
Ejemplo n.º 4
0
        // Método para cargar turnos del profesional
        private void cargarTurnos()
        {
            int fecha        = 0;
            int fechaMas1    = 0;
            int minutosMas15 = @Clinica_Frba.Properties.Settings.Default.Fecha.Minute + 15;

            fecha    += @Clinica_Frba.Properties.Settings.Default.Fecha.Day;
            fecha    += @Clinica_Frba.Properties.Settings.Default.Fecha.Month * 100;
            fecha    += @Clinica_Frba.Properties.Settings.Default.Fecha.Year * 10000;
            fechaMas1 = fecha + 1;
            SqlConnection conexion = SQL_Methods.IniciarConnection();
            string        query    = "SELECT Cod_Turno, Fecha FROM ORACLE_FANS.Turnos " +
                                     "WHERE Matricula = " + matricula.Text + " " +
                                     "AND habilitado = 0 " +
                                     "AND Fecha >= '" + fecha.ToString() + " " + @Clinica_Frba.Properties.Settings.Default.Fecha.Hour.ToString() + ":" + minutosMas15.ToString() + ":" + @Clinica_Frba.Properties.Settings.Default.Fecha.Second.ToString() + "' " +
                                     "AND Fecha < '" + fechaMas1.ToString() + "'";

            turnos = SQL_Methods.EjecutarProcedure(conexion, query);
            dataGridView1.Columns.Clear();
            dataGridView1.AllowUserToAddRows = false;
            dataGridView1.DataSource         = turnos;
            dataGridView1.Visible            = true;
            DataGridViewButtonColumn boton = new DataGridViewButtonColumn();

            this.dataGridView1.Columns.Add(boton);
            boton.HeaderText = "Action";
            boton.Text       = "Ingresar Afiliado";
            boton.Name       = "row_button";
            boton.UseColumnTextForButtonValue = true;
            dataGridView1.Columns[1].Width    = 150;
            dataGridView1.Columns[2].Width    = 100;
        }
Ejemplo n.º 5
0
        private void CargarUsuarios()
        {
            TablaUsuario.Rows.Clear();


            if (this.box_nombre.Text.Trim().Equals("") &&
                this.box_apellido.Text.Trim().Equals("") &&
                this.box_codafiliado.Text.Trim().Equals("") &&
                this.box_dni.Text.Trim().Equals("")
                )
            {
                MessageBox.Show("Debe introducir al menos un criterio de búsqueda");
                return;
            }

            string myQuery = "SELECT * FROM ORACLE_FANS.Afiliados " +
                             "WHERE Nombre LIKE '%" + this.box_nombre.Text.Trim() + "%' " +
                             "AND Apellido LIKE '%" + this.box_apellido.Text.Trim() + "%' " +
                             "AND Cod_Afiliado LIKE '%" + this.box_codafiliado.Text.Trim() + "%' " +
                             "AND Numero_Documento LIKE '%" + this.box_dni.Text.Trim() + "%' " +
                             " AND Activo = 1";

            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaUsuario = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
            }
        }
Ejemplo n.º 6
0
        // Método para boton Aceptar
        private void button1_Click(object sender, EventArgs e)
        {
            if (afiliado.Text.Trim() == "")
            {
                MessageBox.Show("Debe ingresar un número de afiliado.");
                afiliado.Select();
                return;
            }
            if (bono.Text.Trim() == "")
            {
                MessageBox.Show("Debe ingresar un número de bono.");
                bono.Select();
                return;
            }
            SqlConnection conexion = SQL_Methods.IniciarConnection();
            string        query    = "SELECT * FROM ORACLE_FANS.Turnos " +
                                     "WHERE Cod_Afiliado = " + afiliado.Text + " " +
                                     "AND Cod_Turno = " + codigo_turno;

            turno = SQL_Methods.EjecutarProcedure(conexion, query);
            if (turno.Rows.Count == 0)
            {
                MessageBox.Show("El afiliado ingresado no tenía el turno ingresado anteriormente. Ingrese nuevamente el número de afiliado o vuelva e ingrese nuevamente el turno.");
                return;
            }
            else
            {
                MessageBox.Show("El afiliado ingresado es correcto.");
                string query2 = "SELECT * FROM ORACLE_FANS.Bono_Consulta " +
                                "WHERE Cod_Afiliado = " + afiliado.Text + " " +
                                "AND Numero = " + bono.Text +
                                "AND Numero_Consulta is null ";
                bonoIngresado = SQL_Methods.EjecutarProcedure(conexion, query2);
                if (bonoIngresado.Rows.Count == 0)
                {
                    MessageBox.Show("El bono ingresado es incorrecto. Ingrese nuevamente el bono.");
                    return;
                }
                else
                {
                    MessageBox.Show("El bono ingresado es correcto.");
                    SqlCommand comando = new SqlCommand("ORACLE_FANS.ActualizarConsulta", conexion);
                    comando.CommandType = CommandType.StoredProcedure;
                    comando.Parameters.Add("@Numero_Bono", SqlDbType.Int).Value  = Convert.ToInt32(bono.Text);
                    comando.Parameters.Add("@Cod_Afiliado", SqlDbType.Int).Value = Convert.ToInt32(afiliado.Text);
                    comando.Parameters.Add("@Cod_Turno", SqlDbType.Int).Value    = Convert.ToInt32(turno.Rows[0][0].ToString());
                    comando.ExecuteReader();
                    menuAnt.cerrarForm();
                    this.Dispose();
                    return;
                }
            }
        }
Ejemplo n.º 7
0
        // Método para corroborar bono
        private void corroborarBono()
        {
            SqlConnection conexion = SQL_Methods.IniciarConnection();
            string        query    = "SELECT * FROM ORACLE_FANS.Bono_Consulta " +
                                     "WHERE Cod_Afiliado = " + afiliado.Text + " " +
                                     "AND Numero = " + bono.Text +
                                     "AND Numero_Consulta is null ";

            bonoIngresado = SQL_Methods.EjecutarProcedure(conexion, query);
            if (bonoIngresado.Rows.Count == 0)
            {
                MessageBox.Show("El bono ingresado es incorrecto. Ingrese nuevamente el bono.");
                return;
            }
        }
Ejemplo n.º 8
0
        private void cargarComboBox()
        {
            string        myQuery = "SELECT Descripcion FROM ORACLE_FANS.Especialidades ORDER BY 1";
            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaEspecialidades = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
            }
            for (int i = 0; i < Convert.ToInt32(TablaEspecialidades.Rows.Count.ToString()); i++)
            {
                this.comboBox1.Items.Add(TablaEspecialidades.Rows[i][0]);
            }
        }
Ejemplo n.º 9
0
        // Método para cargar medicamentos
        private void cargarMedicamentos()
        {
            SqlConnection conexion          = SQL_Methods.IniciarConnection();
            string        query             = "SELECT Descripcion FROM ORACLE_FANS.Medicamentos_Acomodados";
            DataTable     tablaMedicamentos = new DataTable();

            tablaMedicamentos = SQL_Methods.EjecutarProcedure(conexion, query);
            for (int i = 0; i < Convert.ToInt32(tablaMedicamentos.Rows.Count.ToString()); i++)
            {
                med1.Items.Add(tablaMedicamentos.Rows[i][0]);
                med2.Items.Add(tablaMedicamentos.Rows[i][0]);
                med3.Items.Add(tablaMedicamentos.Rows[i][0]);
                med4.Items.Add(tablaMedicamentos.Rows[i][0]);
                med5.Items.Add(tablaMedicamentos.Rows[i][0]);
            }
        }
Ejemplo n.º 10
0
        private void CargarPlanesMedicos() // Método para llenar Tabla de Planes Medicos
        {
            string        myQuery = "SELECT * FROM ORACLE_FANS.Planes_Medicos";
            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaPlanesMedicos = SQL_Methods.EjecutarProcedure(myConnection, myQuery);

                foreach (DataRow Row in TablaPlanesMedicos.Rows)
                {
                    this.Box_PlanMed.Items.Add(Row[1].ToString());
                }
            }
        }
Ejemplo n.º 11
0
        public void CargarFuncionalidades() // Método para llenar Tabla de Funcionalidades
        {
            string        myQuery = "SELECT * FROM ORACLE_FANS.Funcionalidades";
            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaFuncionalidades = SQL_Methods.EjecutarProcedure(myConnection, myQuery);

                foreach (DataRow Row in TablaFuncionalidades.Rows)
                {
                    this.FuncionalidadesCheckList.Items.Add(Row[1].ToString().Trim());
                }
            }
        }
Ejemplo n.º 12
0
        private void CargarEspecialidades()
        {
            string myQuery = "SELECT * FROM ORACLE_FANS.Especialidades ORDER BY 3";

            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaEspecialidades = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
            }

            for (int i = 0; i < Convert.ToInt32(TablaEspecialidades.Rows.Count.ToString()); i++)
            {
                this.box_especialidad.Items.Add(TablaEspecialidades.Rows[i][2]);
            }
        }
Ejemplo n.º 13
0
        public CompraBonoFarmacia(MenuPrincipal sender, int codAfi, int planMed)
        {
            InitializeComponent();
            codigoAfiliado.Text = Convert.ToString(codAfi);
            planMedico.Text     = Convert.ToString(planMed);
            menu         = sender;
            menu.Visible = false;
            this.Visible = true;
            SqlConnection conexion = SQL_Methods.IniciarConnection();
            string        myQuery  = "SELECT Precio_Bono_Farmacia FROM ORACLE_FANS.Planes_Medicos WHERE Cod_PlanMedico = " + planMedico.Text;

            if (SQL_Methods.DBConnectStatus)
            {
                Precio = SQL_Methods.EjecutarProcedure(conexion, myQuery);
            }
            importeBono = Convert.ToInt32(Precio.Rows[0][0].ToString());
        }
Ejemplo n.º 14
0
        // Metodo para cargar afiliados en la tabla
        private void CargarAfiliados()
        {
            TablaAfiliados.Rows.Clear();

            string myQuery = "SELECT * FROM ORACLE_FANS.Afiliados " +
                             "WHERE Nombre LIKE '%" + this.box_nombre.Text.Trim() + "%' " +
                             "AND Apellido LIKE '%" + this.box_apellido.Text.Trim() + "%' " +
                             "AND Cod_Afiliado LIKE '%" + this.box_codigo.Text.Trim() + "%' " +
                             "AND Numero_Documento LIKE '%" + this.box_documento.Text.Trim() + "%' ";

            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaAfiliados = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
            }
        }
Ejemplo n.º 15
0
        // Método para mostrar planes médicos
        private void cargarPlanes()
        {
            string myQuery = "SELECT Descripcion, Precio_Bono_Consulta, Precio_Bono_Farmacia " +
                             "FROM ORACLE_FANS.Planes_Medicos " +
                             "ORDER by 1";
            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaPlanes = SQL_Methods.EjecutarProcedure(myConnection, myQuery);

                foreach (DataRow Row in TablaPlanes.Rows)
                {
                    this.dataGridView1.Rows.Add(Row[0].ToString(), Row[1].ToString(), Row[2].ToString());
                }
            }
        }
Ejemplo n.º 16
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == 10)
     {
         if (flagMenuPpal == 1)
         {
             //new CancelacionProfesionalForm(menuPpal, TablaProfesionales.Rows[e.RowIndex][0].ToString(), TablaProfesionales.Rows[e.RowIndex][1].ToString(), TablaProfesionales.Rows[e.RowIndex][2].ToString());
             this.Dispose();
             return;
         }
         ProfesionalClass prof = new ProfesionalClass();
         prof.apellido        = TablaProfesionales.Rows[e.RowIndex][2].ToString();
         prof.nombre          = TablaProfesionales.Rows[e.RowIndex][1].ToString();
         prof.numeroDocumento = Convert.ToInt32(TablaProfesionales.Rows[e.RowIndex][4].ToString());
         prof.matricula       = Convert.ToInt32(TablaProfesionales.Rows[e.RowIndex][0].ToString());
         prof.direccion       = TablaProfesionales.Rows[e.RowIndex][5].ToString();
         prof.numeroTelefono  = Convert.ToInt32(TablaProfesionales.Rows[e.RowIndex][7].ToString());
         prof.mail            = TablaProfesionales.Rows[e.RowIndex][6].ToString();
         prof.fechaNacimiento = Convert.ToDateTime(TablaProfesionales.Rows[e.RowIndex][8].ToString());
         prof.tipoDocumento   = TablaProfesionales.Rows[e.RowIndex][3].ToString();
         prof.sexo            = Convert.ToChar(TablaProfesionales.Rows[e.RowIndex][9].ToString());
         if (eliminar)
         {
             // Se quiere eliminar Profesional
             // Conexion al server
             SqlConnection myConnection = SQL_Methods.IniciarConnection();
             SqlCommand    comando      = new SqlCommand("ORACLE_FANS.baja_profesional", myConnection);
             comando.CommandType = CommandType.StoredProcedure;
             comando.Parameters.Add("@mat", SqlDbType.Int).Value = Convert.ToInt32(TablaProfesionales.Rows[e.RowIndex][0].ToString());
             comando.ExecuteReader();
             MessageBox.Show(TablaProfesionales.Rows[e.RowIndex][2].ToString() + " " + TablaProfesionales.Rows[e.RowIndex][1].ToString() + " ha sido eliminado.");
             menu.Visible = true;
             this.Dispose();
         }
         else
         {
             // Se quiere modificar un Profesional
             new AddModProfesional(menu, true, prof);
             this.Dispose();
         }
     }
 }
Ejemplo n.º 17
0
        // Método para llenar la tabla de especialidades
        private void cargarEspecialidades()
        {
            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            string myQuery = "SELECT Descripcion FROM ORACLE_FANS.Especialidades " +
                             "ORDER BY 1";
            DataTable TablaEspecialidades2 = new DataTable();
            int       cantEspMedico        = 0;

            if (modificar)
            {
                string query2 = "SELECT E.Descripcion FROM ORACLE_FANS.Especialidades E " +
                                "JOIN ORACLE_FANS.Medico_Especialidad ME on ME.Cod_Especialidad = E.Cod_Especialidad " +
                                "JOIN ORACLE_FANS.Profesionales P ON P.Matricula = ME.Matricula " +
                                "WHERE P.Matricula = " + matricula.Text;
                TablaEspecialidades2 = SQL_Methods.EjecutarProcedure(myConnection, query2);
                cantEspMedico        = Convert.ToInt32(TablaEspecialidades2.Rows.Count.ToString());
            }
            if (SQL_Methods.DBConnectStatus)
            {
                TablaEspecialidades = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
                foreach (DataRow Row in TablaEspecialidades.Rows)
                {
                    this.EspecialidadesCheckList.Items.Add(Row[0].ToString().Trim());
                    if (modificar)
                    {
                        string    id_Especialidad = Row[0].ToString();
                        DataRow[] Rows            = TablaEspecialidades.Select("Descripcion = '" + id_Especialidad.Trim() + "'");
                        String    Descripcion     = Rows[0][0].ToString().Trim();
                        for (int i = 0; i < cantEspMedico; i++)
                        {
                            if (Descripcion == TablaEspecialidades2.Rows[i][0].ToString())
                            {
                                int index = this.EspecialidadesCheckList.Items.IndexOf(Descripcion);
                                this.EspecialidadesCheckList.SetItemChecked(index, true);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 18
0
        // Método para mostrar especialidades
        private void cargarEspecialidades()
        {
            string myQuery = "SELECT T.Descripcion, E.Descripcion " +
                             "FROM ORACLE_FANS.Especialidades E " +
                             "JOIN ORACLE_FANS.Tipo_Especialidad T on E.Cod_Tipo_Especialidad = T.Cod_Tipo_Especialidad " +
                             "ORDER BY 1, 2";

            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaEspecialidades = SQL_Methods.EjecutarProcedure(myConnection, myQuery);

                foreach (DataRow Row in TablaEspecialidades.Rows)
                {
                    this.dataGridView1.Rows.Add(Row[0].ToString(), Row[1].ToString());
                }
            }
        }
Ejemplo n.º 19
0
        // Método para corroborar el número de bono
        private bool corroborarNumBono()
        {
            bool retorno = true;

            if (numBono.Text.Trim() == "")
            {
                retorno = false;
            }
            if (numBono.Text.Trim() == "")
            {
                MessageBox.Show("No ingresó ningún número de bono. Ingrese un número de bono para su verificación.");
                retorno = false;
                return(retorno);
            }
            int fechaActual = 0;

            fechaActual += @Clinica_Frba.Properties.Settings.Default.Fecha.Day;
            fechaActual += @Clinica_Frba.Properties.Settings.Default.Fecha.Month * 100;
            fechaActual += @Clinica_Frba.Properties.Settings.Default.Fecha.Year * 10000;
            SqlConnection conexion = SQL_Methods.IniciarConnection();
            string        query    = "SELECT * FROM ORACLE_FANS.Bono_Farmacia " +
                                     "WHERE Numero = " + numBono.Text + " " +
                                     "AND Activo = 1 " +
                                     "AND Fecha_Impresion <= '" + fechaActual.ToString() + "' " +
                                     "AND Fecha_Vencimiento > '" + fechaActual.ToString() + "' ";

            DataTable bonos = new DataTable();

            bonos = SQL_Methods.EjecutarProcedure(conexion, query);
            if (bonos.Rows.Count != 0)
            {
                MessageBox.Show("El bono ingresado es correcto.");
            }
            else
            {
                MessageBox.Show("El bono ingresado es incorrecto o ya venció.");
                retorno = false;
                return(retorno);
            }
            return(retorno);
        }
Ejemplo n.º 20
0
        private void CargarRol(int id_Rol) // Metodo Exclusivo para Modificacion de Roles
        {
            string myQuery = "SELECT * FROM ORACLE_FANS.Roles " +
                             "WHERE id_Rol = " + id_Rol.ToString() + "";

            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaRoles = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
            }

            this.NameTextBox.Text = TablaRoles.Rows[0][1].ToString();

            myQuery = "SELECT * FROM ORACLE_FANS.Roles_Funcionalidad " +
                      "WHERE id_Rol = " + id_Rol.ToString();

            if (SQL_Methods.DBConnectStatus)
            {
                TablaRolesFuncionalidades = SQL_Methods.EjecutarProcedure(myConnection, myQuery);

                foreach (DataRow Row in TablaRolesFuncionalidades.Rows)
                {
                    int       id_Funcionalidad = Convert.ToInt32(Row[0]);
                    DataRow[] Rows             = TablaFuncionalidades.Select("id_funcionalidad = '" + id_Funcionalidad.ToString().Trim() + "'");
                    String    Descripcion      = Rows[0][1].ToString().Trim();
                    int       index            = FuncionalidadesCheckList.Items.IndexOf(Descripcion);
                    FuncionalidadesCheckList.SetItemChecked(index, true);
                }
            }

            if (Convert.ToBoolean(TablaRoles.Rows[0][2].ToString())) // Rol Activo
            {
                this.box_checkActive.CheckState = CheckState.Checked;
                this.box_checkActive.Enabled    = false;
            }
        }
Ejemplo n.º 21
0
        private void CargarRoles()
        {
            if (this.Rol_TextBox.Text.Trim().Equals(""))
            {
                if (Flag_deletion)
                {
                    MessageBox.Show("Debe ingresar el nombre del Rol a Eliminar");
                    return;
                }

                MessageBox.Show("Debe ingresar el nombre del Rol a Modificar");
                return;
            }

            string myQuery;

            if (Flag_deletion)
            {
                myQuery = "SELECT * FROM ORACLE_FANS.Roles " +
                          "WHERE Nombre LIKE '%" + this.Rol_TextBox.Text.Trim() + "%' " +
                          "AND isActive = 1";
            }
            else
            {
                myQuery = "SELECT * FROM ORACLE_FANS.Roles " +
                          "WHERE Nombre LIKE '%" + this.Rol_TextBox.Text.Trim() + "%'";
            }

            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaRoles = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
            }
        }
Ejemplo n.º 22
0
        // Método para botón generar receta
        private void button3_Click(object sender, EventArgs e)
        {
            if (!comprobarBono())
            {
                return;
            }
            if (!comprobarMedicamentos(Convert.ToInt32(cantMed.Value)))
            {
                MessageBox.Show("Debe ingresar medicamentos existentes en las opciones que se ofrecen. Re ingrese los medicamentos.");
                return;
            }
            if (!comprobarNombresMedicamentos(Convert.ToInt32(cantMed.Value)))
            {
                MessageBox.Show("Debe ingresar medicamentos distintos en la misma receta. Re ingrese los medicamentos.");
                return;
            }
            if (numeroAfiliado.Text.Trim() == "")
            {
                MessageBox.Show("Debe ingresar un número de afiliado.");
                return;
            }
            if (!comprobarValoresTurno())
            {
                MessageBox.Show("Debe ingresar valores en los campos de turno válidos. La hora y los minutos del turno deben ser los de las opciones ofrecidas. Re ingrese los valores.");
                return;
            }
            if (comprobarTurno())
            {
                int[]      cantidades     = new int[5];
                string[]   medicamentos   = new string[5];
                DateTime[] prescripciones = new DateTime[5];
                cantidades[0]     = Convert.ToInt32(cantMed1.Value);
                prescripciones[0] = Convert.ToDateTime(fecha1.Text);
                cantidades[1]     = Convert.ToInt32(cantMed2.Value);
                prescripciones[1] = Convert.ToDateTime(fecha2.Text);
                cantidades[2]     = Convert.ToInt32(cantMed3.Value);
                prescripciones[2] = Convert.ToDateTime(fecha3.Text);
                cantidades[3]     = Convert.ToInt32(cantMed4.Value);
                prescripciones[3] = Convert.ToDateTime(fecha4.Text);
                cantidades[4]     = Convert.ToInt32(cantMed5.Value);
                prescripciones[4] = Convert.ToDateTime(fecha5.Text);
                if (med1.Text.Trim() != "")
                {
                    medicamentos[0] = med1.Text;
                }
                else
                {
                    medicamentos[0] = "ninguno";
                }

                if (med2.Text.Trim() != "")
                {
                    medicamentos[1] = med2.Text;
                }
                else
                {
                    medicamentos[1] = "ninguno";
                }

                if (med3.Text.Trim() != "")
                {
                    medicamentos[2] = med3.Text;
                }
                else
                {
                    medicamentos[2] = "ninguno";
                }

                if (med4.Text.Trim() != "")
                {
                    medicamentos[3] = med4.Text;
                }
                else
                {
                    medicamentos[3] = "ninguno";
                }

                if (med5.Text.Trim() != "")
                {
                    medicamentos[4] = med5.Text;
                }
                else
                {
                    medicamentos[4] = "ninguno";
                }
                if (comprobarBono())
                {
                    for (int i = 0; i < Convert.ToInt32(cantMed.Value); i++)
                    {
                        SqlConnection conexion = SQL_Methods.IniciarConnection();
                        SqlCommand    comando  = new SqlCommand("ORACLE_FANS.crearReceta", conexion);
                        SqlCommand    comando2 = new SqlCommand("ORACLE_FANS.medicamentosRecetadosP", conexion);
                        comando.CommandType = CommandType.StoredProcedure;
                        comando.Parameters.Add("@num_bono", SqlDbType.Int).Value          = Convert.ToInt32(numeroBono.Text);
                        comando.Parameters.Add("@Cod_Turno", SqlDbType.Int).Value         = turno.Rows[0][0].ToString();
                        comando2.Parameters.Add("@nom_med", SqlDbType.VarChar, 255).Value = medicamentos[i];
                        comando2.Parameters.Add("@cant_med", SqlDbType.Int).Value         = cantidades[i];
                        comando2.Parameters.Add("@pres_med", SqlDbType.DateTime).Value    = prescripciones[i];
                        comando2.Parameters.Add("@cod_turno", SqlDbType.Int).Value        = turno.Rows[0][0].ToString();
                        comando.ExecuteReader();
                        comando.Connection.Close();
                        comando2.ExecuteReader();
                        comando2.Connection.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Ingresó algún valor de forma incorrecta. Por favor re-ingrese los valores.");
                }
            }
        }
Ejemplo n.º 23
0
        private void CargarProfesional()
        {
            string myQuery = "";
            int    Matricula;

            if (PedirTurno)
            {
                if (this.box_Matricula.Text.Trim().Equals(""))
                {
                    Matricula = -1;
                }
                else
                {
                    Matricula = Convert.ToInt32(this.box_Matricula.Text.Trim());
                }

                TablaProfesionales = SQL_Methods.Profesional_Listar(Matricula,
                                                                    this.box_nombre.Text.Trim(),
                                                                    this.box_apellido.Text.Trim(),
                                                                    this.box_especialidad.Text.Trim(),
                                                                    FechaTurno);
                return;
            }


            if (this.box_especialidad.Text.Trim().Equals(""))
            {
                myQuery = "SELECT " +
                          "P.Matricula, P.Nombre, P.Apellido " +
                          "FROM " +
                          "ORACLE_FANS.Profesionales P " +
                          "WHERE P.Nombre LIKE '%" + this.box_nombre.Text.Trim() + "%' " +
                          "AND P.Apellido LIKE '%" + this.box_apellido.Text.Trim() + "%' " +
                          "AND P.Matricula LIKE '%" + this.box_Matricula.Text.Trim() + "%' ";
            }
            else
            {
                DataRow[] Rows = TablaEspecialidades.Select("Descripcion = '" + this.box_especialidad.Text.Trim() + "'");
                int       Cod_Especialidad;
                if (Rows.Length > 0)
                {
                    Cod_Especialidad = Convert.ToInt32(Rows[0][0].ToString().Trim());
                    myQuery          = "SELECT " +
                                       "P.Matricula, P.Nombre, P.Apellido, E.Descripcion As Especialidad " +
                                       "FROM " +
                                       "ORACLE_FANS.Profesionales P, ORACLE_FANS.Especialidades E, " +
                                       "ORACLE_FANS.Tipo_Especialidad T, ORACLE_FANS.Medico_Especialidad ME " +
                                       "WHERE ME.Cod_Especialidad = E.Cod_Especialidad " +
                                       "AND E.Cod_Tipo_Especialidad = T.Cod_Tipo_Especialidad " +
                                       "AND P.Nombre LIKE '%" + this.box_nombre.Text.Trim() + "%' " +
                                       "AND P.Apellido LIKE '%" + this.box_apellido.Text.Trim() + "%' " +
                                       "AND P.Matricula LIKE '%" + this.box_Matricula.Text.Trim() + "%' " +
                                       "AND ME.Cod_Especialidad = " + Cod_Especialidad.ToString();
                }
            }

            SqlConnection myConnection;

            myConnection = SQL_Methods.IniciarConnection();
            if (SQL_Methods.DBConnectStatus)
            {
                TablaProfesionales = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
            }
        }
Ejemplo n.º 24
0
        // Metodo para boton aceptar
        public void botonAceptar_Click(object sender, EventArgs e)
        {
            // Variable para determinar si el login fue correcto o no
            bool errorLogin = false;

            // Conexion al server
            SqlConnection myConnection = SQL_Methods.IniciarConnection();

            try
            {
                // Comando donde cargo el store procedure para la validacion del usuario
                SqlCommand comando = new SqlCommand("ORACLE_FANS.proc_login", myConnection);
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.Add("@user_name", SqlDbType.VarChar, 10).Value = this.usuario.Text;

                SqlDataAdapter da = new SqlDataAdapter(comando);
                DataSet        ds = new DataSet();
                da.Fill(ds, "Usuarios");
                if (ds.Tables["Usuarios"].Rows.Count == 0)
                {
                    // No existe el nombre de usuario
                    errorLogin = true;
                }
                else
                {
                    // El usuario existe
                    if (ds.Tables["Usuarios"].Rows[0]["estado"].ToString().Trim().Equals("False"))
                    {
                        // Usuario no activo
                        MessageBox.Show("El usuario con el que desea ingresar esta inhabilitado.", "Usuario Inhabilitado", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.contraseña.Text = "";
                        this.usuario.Text    = "";
                        this.usuario.Select();
                        return;
                    }

                    if (ds.Tables["Usuarios"].Rows[0]["usuario_intentos_fallidos"].ToString().Equals("0"))
                    {
                        // Es la cuarta vez que se intenta iniciar sesion
                        this.deshabilitarUsuario(this.usuario.Text, myConnection);
                        MessageBox.Show("Ud. ha sido bloqueado, comuniquese con su administrador para que lo desbloquee.", "Usuario bloqueado", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        //errorLogin = true;
                        //return;
                    }
                    else
                    {
                        // Intento valido de inicio de sesion
                        if (ds.Tables["Usuarios"].Rows[0]["password"].ToString() == encriptar(this.contraseña.Text))
                        {
                            // La contraseña es correcta
                            //this.Visible = false;
                            int idRol            = Convert.ToInt32(ds.Tables["Usuarios"].Rows[0]["id_Rol"].ToString());
                            int numero_documento = -1;
                            if (idRol != 2)
                            {
                                numero_documento = Convert.ToInt32(ds.Tables["Usuarios"].Rows[0]["username"].ToString());
                            }

                            menu.SetRol(idRol, numero_documento);
                            this.Dispose();
                            return;
                        }
                        else
                        {
                            // La contraseña es incorrecta
                            errorLogin = true;
                            this.registrarLoginInvalido(this.usuario.Text, myConnection);
                        }
                    }
                }

                if (errorLogin)
                {
                    MessageBox.Show("Usuario o contraseña inválidos");
                }
                this.contraseña.Text = "";
                this.usuario.Text    = "";
                this.usuario.Select();
            }
            catch (Exception excepcion)
            {
                MessageBox.Show("Error en la aplicación: " + excepcion.Message);
            }
            finally
            {
            }
        }
Ejemplo n.º 25
0
        // Método para botón guardar
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conexion = SQL_Methods.IniciarConnection();
            SqlCommand    comando;

            if (modificar)
            {
                if (!verificarEspecialidades())
                {
                    MessageBox.Show("Debe ingresar al menos 1 especialidad en la cual el profesional se desarrolla.");
                    return;
                }
                // Si se está modificando
                if (comprobarValoresIngresados())
                {
                    comando             = new SqlCommand("ORACLE_FANS.modificarProfesional", conexion);
                    comando.CommandType = CommandType.StoredProcedure;
                    comando.Parameters.Add("@Matricula", SqlDbType.Int).Value             = Convert.ToInt32(matricula.Text);
                    comando.Parameters.Add("@Nombre", SqlDbType.VarChar, 255).Value       = nombre.Text;
                    comando.Parameters.Add("@Apellido", SqlDbType.VarChar, 255).Value     = apellido.Text;
                    comando.Parameters.Add("@Tipo_Documento", SqlDbType.VarChar, 6).Value = tipoDocBox.Text;
                    comando.Parameters.Add("@Direccion", SqlDbType.VarChar, 255).Value    = direccion.Text;
                    comando.Parameters.Add("@Telefono", SqlDbType.Int).Value      = Convert.ToInt32(telefono.Text);
                    comando.Parameters.Add("@Mail", SqlDbType.VarChar, 255).Value = mail.Text;
                    if (sexoBox.Text == "Hombre")
                    {
                        comando.Parameters.Add("@Sexo", SqlDbType.Char).Value = 'H';
                    }
                    else
                    {
                        comando.Parameters.Add("@Sexo", SqlDbType.Char).Value = 'M';
                    }
                    comando.ExecuteReader();
                    comando.Connection.Close();
                    for (int i = 0; i < EspecialidadesCheckList.CheckedItems.Count; i++)
                    {
                        conexion = SQL_Methods.IniciarConnection();
                        SqlCommand comando2 = new SqlCommand("ORACLE_FANS.modif_esp", conexion);
                        comando2.CommandType = CommandType.StoredProcedure;
                        comando2.Parameters.Add("@esp", SqlDbType.VarChar, 255).Value = EspecialidadesCheckList.CheckedItems[i].ToString();
                        comando2.Parameters.Add("@prof", SqlDbType.Int).Value         = Convert.ToInt32(matricula.Text);
                        comando2.ExecuteReader();
                        comando2.Connection.Close();
                    }
                    MessageBox.Show(apellido.Text + " " + nombre.Text + " fue modificado exitosamente.");
                    abmProfesional.Visible = true;
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Ingresó valores incorrectos. Por favor verifique los valores.");
                }
            }
            else
            {
                // Si se está agregando
                if (comprobarValoresIngresados())
                {
                    comando             = new SqlCommand("ORACLE_FANS.altaProfesional", conexion);
                    comando.CommandType = CommandType.StoredProcedure;
                    comando.Parameters.Add("@Nombre", SqlDbType.VarChar, 255).Value       = nombre.Text;
                    comando.Parameters.Add("@Apellido", SqlDbType.VarChar, 255).Value     = apellido.Text;
                    comando.Parameters.Add("@Tipo_Documento", SqlDbType.VarChar, 6).Value = tipoDocBox.Text;
                    comando.Parameters.Add("@Numero_Documento", SqlDbType.Int).Value      = Convert.ToInt32(numDoc.Text);
                    comando.Parameters.Add("@Direccion", SqlDbType.VarChar, 255).Value    = direccion.Text;
                    comando.Parameters.Add("@Telefono", SqlDbType.Int).Value       = Convert.ToInt32(telefono.Text);
                    comando.Parameters.Add("@Mail", SqlDbType.VarChar, 255).Value  = mail.Text;
                    comando.Parameters.Add("@Fecha_Nac", SqlDbType.DateTime).Value = Convert.ToDateTime(fecNac.Text);
                    comando.Parameters.Add("@Matricula", SqlDbType.Int).Value      = Convert.ToInt32(matricula.Text);
                    if (sexoBox.Text == "Hombre")
                    {
                        comando.Parameters.Add("@Sexo", SqlDbType.Char).Value = 'H';
                    }
                    else
                    {
                        comando.Parameters.Add("@Sexo", SqlDbType.Char).Value = 'M';
                    }
                    comando.ExecuteReader();
                    comando.Connection.Close();
                    for (int i = 0; i < EspecialidadesCheckList.CheckedItems.Count; i++)
                    {
                        conexion = SQL_Methods.IniciarConnection();
                        SqlCommand comando2 = new SqlCommand("ORACLE_FANS.agregar_esp", conexion);
                        comando2.CommandType = CommandType.StoredProcedure;
                        comando2.Parameters.Add("@esp", SqlDbType.VarChar, 255).Value = EspecialidadesCheckList.CheckedItems[i].ToString();
                        comando2.Parameters.Add("@prof", SqlDbType.Int).Value         = Convert.ToInt32(matricula.Text);
                        comando2.ExecuteReader();
                        comando2.Connection.Close();
                    }
                    MessageBox.Show(apellido.Text + " " + nombre.Text + " fue agregado exitosamente.");

                    if (!SQL_Methods.Usuario_Crear(1, numDoc.Text.Trim()))
                    {
                        MessageBox.Show("El usuario para el Profesional no pudo ser creado");
                    }

                    abmProfesional.Visible = true;
                    this.Dispose();
                }
                else
                {
                    MessageBox.Show("Ingresó valores incorrectos. Por favor verifique los valores.");
                }
            }
        }
Ejemplo n.º 26
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (this.dataGridView1.Columns[e.ColumnIndex].HeaderText.Equals("Action"))
            {
                int Matricula = Convert.ToInt32(TablaProfesionales.Rows[e.RowIndex]["Matricula"].ToString());


                if (PedirTurno)
                {
                    DataRow[] Rows = TablaEspecialidades.Select("Descripcion = '" +
                                                                TablaProfesionales.Rows[e.RowIndex]["Especialidad"].ToString().Trim() +
                                                                "'");
                    int Cod_Especialidad;
                    if (Rows.Length != 1)
                    {
                        return;
                    }

                    Cod_Especialidad = Convert.ToInt32(Rows[0][0].ToString().Trim());
                    menuPedirTurno.SetProfesional(Matricula,
                                                  Cod_Especialidad,
                                                  TablaProfesionales.Rows[e.RowIndex]["Nombre"].ToString() + " " +
                                                  TablaProfesionales.Rows[e.RowIndex]["Apellido"].ToString());
                    menuPedirTurno.Visible = true;
                    this.Dispose();
                    return;
                }

                if (CancelarTurno)
                {
                    menuCancelarTurno.SetProfesional(Matricula,
                                                     TablaProfesionales.Rows[e.RowIndex]["Nombre"].ToString() + " " +
                                                     TablaProfesionales.Rows[e.RowIndex]["Apellido"].ToString());

                    menuCancelarTurno.Visible = true;
                    this.Dispose();
                    return;
                }

                string myQuery = "SELECT FechaInicio, FechaFinal FROM ORACLE_FANS.Cartilla_Medica " +
                                 "WHERE Matricula =  " + Matricula.ToString();

                SqlConnection myConnection;
                myConnection = SQL_Methods.IniciarConnection();

                if (SQL_Methods.DBConnectStatus)
                {
                    DataTable Aux = SQL_Methods.EjecutarProcedure(myConnection, myQuery);
                    if (Aux.Rows.Count > 0)
                    {
                        DateTime FechaInicio = Convert.ToDateTime(Aux.Rows[0][0].ToString());
                        DateTime FechaFinal  = Convert.ToDateTime(Aux.Rows[0][1].ToString());

                        MessageBox.Show("Este profesional ya tiene una Agenda Profesional en Progreso" + System.Environment.NewLine +
                                        "Fecha Desde = " + FechaInicio.ToShortDateString() + System.Environment.NewLine +
                                        "Fecha Hasta = " + FechaFinal.ToShortDateString());
                        return;
                    }
                }

                new RegistrarAgendaForm(menu, Matricula);
                this.Dispose();
            }
        }