Example #1
0
        private Boolean validarCampos()
        {
            if (string.IsNullOrEmpty(txtBoxNombre.Text) || (int)listBox2.Items.Count == 0)
            {
                String mensaje = "Los campos nombre y funcionalidades son obligatorios";
                String caption = "Error al crear el rol";
                MessageBox.Show(mensaje, caption, MessageBoxButtons.OK);
                return(false);
            }
            else
            {
                SqlConnection conexion = ManejadorConexiones.conectar();
                existeRol             = new SqlCommand("TRIGGER_EXPLOSION.ExisteRol", conexion);
                existeRol.CommandType = CommandType.StoredProcedure;
                existeRol.Parameters.Add("@nombre", SqlDbType.VarChar).Value = txtBoxNombre.Text;
                var resultado = existeRol.Parameters.Add("@Valor", SqlDbType.Int);
                resultado.Direction = ParameterDirection.ReturnValue;
                data = existeRol.ExecuteReader();
                var existeR = resultado.Value;
                data.Close();
                ManejadorConexiones.desconectar();

                if ((int)existeR == 1)
                {
                    String mensaje = "El rol ya existe, ingrese otro nombre";
                    String caption = "Error al crear el rol";
                    MessageBox.Show(mensaje, caption, MessageBoxButtons.OK);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
        public static void cargarGrillaSP(DataGridView grilla, String storeProcedure, List <SqlParameter> parametros)
        {
            DataTable dt = ManejadorConexiones.ExecuteQuery(storeProcedure, parametros);

            grilla.DataSource = null;
            grilla.DataSource = dt;
        }
Example #3
0
        private void crearNuevoRol()
        {
            SqlConnection conexion = ManejadorConexiones.conectar();

            crearRolNuevo             = new SqlCommand("TRIGGER_EXPLOSION.SP_altaRol", conexion);
            crearRolNuevo.CommandType = CommandType.StoredProcedure;
            crearRolNuevo.Parameters.Add("@nombre", SqlDbType.VarChar).Value = txtBoxNombre.Text;
            crearRolNuevo.ExecuteNonQuery();


            RolId             = new SqlCommand("TRIGGER_EXPLOSION.obtenerRolId", conexion);
            RolId.CommandType = CommandType.StoredProcedure;
            RolId.Parameters.Add("@nombre", SqlDbType.VarChar).Value = txtBoxNombre.Text;
            var resultado = RolId.Parameters.Add("@Valor", SqlDbType.Decimal);

            resultado.Direction = ParameterDirection.ReturnValue;
            data = RolId.ExecuteReader();
            ManejadorConexiones.desconectar();

            var idRol = resultado.Value;

            rol = decimal.Parse(idRol.ToString());
            data.Close();

            crearFuncionalidades();
        }
        public static List <Profesional> getProfesionales()
        {
            profesionales = new List <Profesional>();
            DataTable dt = new DataTable();

            using (SqlConnection sqlConnection = ManejadorConexiones.conectar())
            {
                String query = "SELECT * FROM TRIGGER_EXPLOSION.Profesional";
                using (var cmd = new SqlCommand(query, sqlConnection))
                {
                    using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
                    {
                        adapter.Fill(dt);
                        foreach (DataRow row in dt.Rows)
                        {
                            profesionales.Add(new Profesional(
                                                  Convert.ToString(row.Field <decimal>("Id_profesional")),
                                                  row.Field <string>("Nombre"),
                                                  row.Field <string>("Apellido")
                                                  ));
                        }
                    }
                }
            }

            return(profesionales);
        }
Example #5
0
        private void textBoxNroAfiliado_Leave(object sender, EventArgs e)
        {
            String query = "select Precio_bono_consulta from TRIGGER_EXPLOSION.Afiliado a JOIN TRIGGER_EXPLOSION.PlanMedico p ON (a.Plan_id = p.Id_plan) where Id_afiliado = " + textBoxNroAfiliado.Text;

            if (String.IsNullOrWhiteSpace(textBoxNroAfiliado.Text))
            {
                MessageBox.Show("Por favor, indique el nro de afiliado");
                return;
            }


            Object x      = ManejadorConexiones.ExecuteScalar("select COUNT(Id_afiliado) from TRIGGER_EXPLOSION.Afiliado WHERE Id_afiliado = " + textBoxNroAfiliado.Text);
            Int64  result = Convert.ToInt64(x);

            if (result <= 0)
            {
                MessageBox.Show("No existe el numero de afiliado indicado, por favor, indique otro");
                textBoxNroAfiliado.Text = "";
                return;
            }

            precioBono = Convert.ToInt32(ManejadorConexiones.ExecuteScalar(query));
            if (!String.IsNullOrWhiteSpace(textBoxCantBonos.Text))
            {
                calcularTotal();
            }
        }
        public int getProfesionalId()
        {
            string sqlQuery = "SELECT Id_profesional FROM TRIGGER_EXPLOSION.Profesional  WHERE Id_usuario =" + user_id;


            SqlCommand sqlCommand = new SqlCommand(sqlQuery, ManejadorConexiones.conectar());

            SqlDataReader reader = sqlCommand.ExecuteReader();


            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var a = reader.GetValue(0);


                    reader.Close();
                    return(Convert.ToInt32(a));
                }
            }
            else
            {
                MessageBox.Show("No es un numero de profesional válido");
                reader.Close();
            }


            return(1);
        }
Example #7
0
        private void btn_comprar_Click(object sender, EventArgs e)
        {
            if (precioTotal == 0)
            {
                MessageBox.Show("El numero de afiliado no es correcto");
                return;
            }
            else if (String.IsNullOrWhiteSpace(textBoxNroAfiliado.Text))
            {
                MessageBox.Show("Por favor, indique el nro de afiliado");
                return;
            }
            else if (String.IsNullOrWhiteSpace(textBoxCantBonos.Text))
            {
                MessageBox.Show("Por favor, indique la cantidad de bonos");
                return;
            }
            List <SqlParameter> parametros = new List <SqlParameter>();
            String   fechaSistemaString    = ConfigurationManager.AppSettings["fechaSistema"];
            DateTime fechaSistema          = DateTime.Parse(fechaSistemaString);

            parametros.Add(new SqlParameter("id_afiliado", Convert.ToInt32(textBoxNroAfiliado.Text)));
            parametros.Add(new SqlParameter("cantidad", cantBonos));
            parametros.Add(new SqlParameter("precioTotal", precioTotal));
            parametros.Add(new SqlParameter("fecha", fechaSistema));
            ManejadorConexiones.ExecuteQuery("TRIGGER_EXPLOSION.comprarBonos", parametros);
            MessageBox.Show("Se compraron " + cantBonos + " bonos satisfactoriamente");
            this.Close();
        }
Example #8
0
        public bool getIdAgenda()
        {
            string sender = "select Id_agenda from TRIGGER_EXPLOSION.Agenda where Id_profesional=" + id_profesional + " and Especialidad='" + comboBox1.Text + "'";



            Console.WriteLine(sender);
            SqlCommand sqlCommand = new SqlCommand(sender, ManejadorConexiones.conectar());

            SqlDataReader reader = sqlCommand.ExecuteReader();


            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    var a = reader.GetValue(0);


                    id_agenda = Convert.ToInt32(a);
                }

                reader.Close();

                return(true);
            }
            else
            {
                reader.Close();
                MessageBox.Show("Hubo un error en el cargado De los dias disponibles");

                return(false);
            }
        }
        private void AplicarDiagnostico()
        {
            if (Asistencia.Checked)
            {
                Diagnostico.Visible  = true;
                Diagnosticar.Visible = true;
                Sintomas.Visible     = true;
            }
            else
            {
                try
                {
                    string     query5 = "UPDATE TRIGGER_EXPLOSION.ConsultaMedica SET Consulta_realizada=1, Fecha_y_hora='" + (string)(Regex.Replace(Fecha.Text, @"\s+", "") + " " + Regex.Replace(Hora.Text, @"\s+", "")) + "' WHERE Id_consulta=" + id_consulta;
                    SqlCommand cmd5   = new SqlCommand(query5, ManejadorConexiones.conectar()); //Agregar este Stored
                    cmd5.ExecuteNonQuery();

                    MessageBox.Show("CARGA EXITOSA");
                    this.Close();
                } catch {
                    MessageBox.Show("Ocurrio un error, intentelo de nuevo");
                    return;
                }
                //catch
            }
        }
        private void Cargar_Click(object sender, EventArgs e)
        {
            if (id_consulta == -1)
            {
                MessageBox.Show("Debe elegir un turno");
                return;
            }

            if (checkBonos())
            {
                string sqlString2 = "UPDATE TRIGGER_EXPLOSION.Turno SET Fecha_y_hora_llegada='" + date + "' where Id_turno=" + id_consulta;


                SqlCommand command2 = new SqlCommand(sqlString2, ManejadorConexiones.conectar());//Agregar este Stored

                if (command2.ExecuteNonQuery() == 0)
                {
                    MessageBox.Show("Los datos no se cargaron correctamente intente nuevamente"); return;
                }

                InsertConsultaMedica();
                InsertarEnBono();

                ManejadorConexiones.desconectar();
                MessageBox.Show("CARGA EXITOSA");
                this.Close();
            }
        }
Example #11
0
        private void Box_documento_Leave(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(Box_documento.Text))
            {
                MessageBox.Show("Por favor complete el numero de documento"); return;
            }
            if (!Regex.IsMatch(Box_documento.Text, @"^\d+$"))
            {
                MessageBox.Show("Este campo solo admite valores numericos");
                Box_documento.Text = "";
                return;
            }

            Int64 nroDoc = Convert.ToInt64(Box_documento.Text);

            Object  result = ManejadorConexiones.ExecuteScalar("select TRIGGER_EXPLOSION.YaExisteAfiliadoConDocumento(" + nroDoc + ", '" + comboBox1.Text + "')");
            Boolean yaExisteNroDocumento = Convert.ToBoolean(result);

            if (yaExisteNroDocumento)
            {
                MessageBox.Show("Ya existe un afiliado con ese numero de documento, por favor, indique otro");
                Box_documento.Text = "";
                return;
            }
        }
        public static List <Especialidad> getEspecialidades()
        {
            if (especialidades != null)
            {
                return(especialidades);
            }

            especialidades = new List <Especialidad>();
            DataTable dt = new DataTable();

            using (SqlConnection sqlConnection = ManejadorConexiones.conectar())
            {
                String query = "SELECT Id_especialidad, Descripcion FROM TRIGGER_EXPLOSION.Especialidad";
                using (var cmd = new SqlCommand(query, sqlConnection))
                {
                    using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
                    {
                        adapter.Fill(dt);
                        foreach (DataRow row in dt.Rows)
                        {
                            especialidades.Add(new Especialidad(row.Field <string>("Descripcion"),
                                                                Convert.ToString(row.Field <decimal>("Id_especialidad"))));
                        }
                    }
                }
            }

            return(especialidades);
        }
        private void Aceptar_Click(object sender, EventArgs e)
        {
            if (CheckCampos())
            {
                string sqlString2;

                id_afiliado = getIdAfiliado();

                ManejadorConexiones.desconectar();
                total_numero_consultas = Convert.ToInt64(ManejadorConexiones.ExecuteScalar("select top 1 Total_consultas_medicas FROM TRIGGER_EXPLOSION.Afiliado where id_afiliado = " + id_afiliado));
                ManejadorConexiones.conectar();
                if (!ar)
                {
                    return;
                }


                id_profesional = getIdProfesional();

                if (!ar)
                {
                    return;
                }


                date = ConfigurationManager.AppSettings["fechaSistema"];
                DateTime fechaSistema = DateTime.ParseExact(ConfigurationManager.AppSettings["fechaSistema"], "dd/MM/yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);


                Console.Write(date);

                if (comboBox1.Text.Length != 0)
                {
                    int especialidad = getEspecialidadId();
                    sqlString2 = " select id_turno, Nombre,Apellido, Fecha_programada, Descripcion from TRIGGER_EXPLOSION.Turno, TRIGGER_EXPLOSION.Especialidad, TRIGGER_EXPLOSION.Profesional where Profesional.Id_profesional=Turno.Id_profesional and Especialidad_id=Id_especialidad and Descripcion='" + comboBox1.Text + "' and id_afiliado=" + id_afiliado + " and FORMAT(Fecha_programada,'yyyy-MM-dd') ='" + fechaSistema.ToString("yyyy-MM-dd") + "' and Cancelado=0 and Fecha_y_hora_llegada is null";                   // sqlString2 = "UPDATE TRIGGER_EXPLOSION.Turno SET Fecha_y_hora_llegada='" + date + "' where Id_afiliado=" + id_afiliado + "and Id_profesional=" + id_profesional + "and Especialidad_id=" + especialidad + " and Id_turno=(select top 1 Id_turno from TRIGGER_EXPLOSION.Turno where Id_afiliado=" + id_afiliado + " and Id_profesional=" + id_profesional + " AND Fecha_programada >= '"+date+ "' order by Fecha_programada asc )";
                }
                else
                {
                    sqlString2 = " select id_turno, Nombre,Apellido, Fecha_programada, Descripcion from TRIGGER_EXPLOSION.Turno, TRIGGER_EXPLOSION.Especialidad, TRIGGER_EXPLOSION.Profesional where Profesional.Id_profesional=Turno.Id_profesional and Especialidad_id=Id_especialidad and Fecha_y_hora_llegada is null and id_afiliado=" + id_afiliado + " and FORMAT(Fecha_programada,'yyyy-MM-dd') = '" + fechaSistema.ToString("yyyy-MM-dd") + "'";
                }

                Console.WriteLine(sqlString2);
                if (!ar)
                {
                    return;
                }


                Interfaz.Interfaz.cargarGrilla(dataGridView1, sqlString2);
                // dataGridView1.DataSource=;
                //DataGridView grilla, String querySQL
            }
        }
Example #14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: esta línea de código carga datos en la tabla 'gD2C2016DataSet.Afiliado' Puede moverla o quitarla según sea necesario.

            List <SqlParameter> parametros = new List <SqlParameter>();

            ManejadorConexiones.conectar();
            DataTable tablaAfiliados = ManejadorConexiones.ExecuteQuery("TRIGGER_EXPLOSION.getAfiliados", parametros);
            Afiliado  afiliado       = new Afiliado();

            afiliado.ActualizarGrid(this.dataGridView1, "select * from TRIGGER_EXPLOSION.Afiliado");
        }
        public static void cargarGrilla(DataGridView grilla, String querySQL)
        {
            SqlDataReader valores = ManejadorConexiones.ExecuteReader(querySQL, null, ManejadorConexiones.conectar());

            DataTable dt = new DataTable();

            dt.Load(valores);

            ManejadorConexiones.desconectar();

            grilla.DataSource = null;
            grilla.DataSource = dt;
        }
Example #16
0
        private void btn_buscar_Click(object sender, EventArgs e)
        {
            if (cboAño.Text != "" && cboEspecialidad.Text != "" && cboPlan.Text != "" && cboMes.Text != "")
            {
                DataTable dt = new DataTable();

                int mes, planId, especialidadId, semestre, anio;
                try
                {
                    mes            = Convert.ToInt32(cboMes.SelectedValue.ToString());
                    planId         = Convert.ToInt32(cboPlan.SelectedValue.ToString());
                    especialidadId = Convert.ToInt32(cboEspecialidad.SelectedValue.ToString());
                    semestre       = int.Parse(cboSemestre.Text);
                    anio           = Convert.ToInt32(cboAño.Text);
                }
                catch (Exception ex)
                {
                    Interfaz.Interfaz.mostrarMensaje("Verifique que los campos insertados sean correctos");
                    return;
                }



                String     query = "select * from TRIGGER_EXPLOSION.ProfesionalesConsultados(@Plan,@Especialidad,@Semestre,@Mes,@Anio)";
                SqlCommand cmd   = new SqlCommand(query, ManejadorConexiones.conectar());
                cmd.Parameters.Add("@Plan", SqlDbType.Int).Value         = planId;
                cmd.Parameters.Add("@Especialidad", SqlDbType.Int).Value = especialidadId;
                cmd.Parameters.Add("@Semestre", SqlDbType.Int).Value     = semestre;
                cmd.Parameters.Add("@Mes", SqlDbType.Int).Value          = mes;
                cmd.Parameters.Add("@Anio", SqlDbType.Int).Value         = anio;

                using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
                {
                    adapter.Fill(dt);
                    if (dt.Rows.Count == 0)
                    {
                        Interfaz.Interfaz.mostrarMensaje("No se han encontrado resultados!");
                    }
                    else
                    {
                        dataGridView1.DataSource = dt;
                    }
                    cmd.Dispose();
                    ManejadorConexiones.desconectar();
                }
            }
            else
            {
                MessageBox.Show("Complete los criterios de busqueda");
            }
        }
        private bool check48Horas()
        {
            double totalHoras = 0;

            for (int i = 0; i < diasLaborales.Count; i++)
            {
                DateTime timeInicial = DateTime.ParseExact(diasLaborales[i][1].ToString(), "HH:mm", System.Globalization.CultureInfo.InvariantCulture);
                DateTime timeFinal   = DateTime.ParseExact(diasLaborales[i][2].ToString(), "HH:mm", System.Globalization.CultureInfo.InvariantCulture);

                TimeSpan difference  = timeFinal - timeInicial;
                double   diffInHours = difference.TotalHours;
                totalHoras = totalHoras + diffInHours;
            }


            String     query = "select (SUM(DATEDIFF(MINUTE,dd.inicio_jornada,dd.fin_jornada)) / 60) FROM TRIGGER_EXPLOSION.Dias_disponible dd JOIN TRIGGER_EXPLOSION.Agenda ag ON dd.Id_agenda = ag.Id_agenda JOIN TRIGGER_EXPLOSION.Profesional p ON ag.Id_profesional = p.Id_profesional and p.Id_profesional = " + id_profesional + "and dd.Dia != 'Domingo' group by p.Id_profesional";
            SqlCommand cmd   = new SqlCommand(query, ManejadorConexiones.conectar());

            using (SqlDataReader reader = cmd.ExecuteReader())
            {
                if (reader.Read())
                { // ya tiene una agenda registrada, cuento los dias laborales que ya tiene
                    var a = reader.GetValue(0);


                    if ((Convert.ToInt32(a) + totalHoras) > 48)
                    {
                        MessageBox.Show("La sumatoria de sus agendas superan las 48 horas semanales");
                        reader.Close();
                        return(false);
                    }
                    else
                    {
                        reader.Close();
                        return(true);
                    }
                }
                else
                {// no tiene ninguna agenda registrada
                    if ((totalHoras) > 48)
                    {
                        MessageBox.Show("Los horarios superan las 48 horas semanales"); return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
            }
        }
        private void EliminarRol_Load(object sender, EventArgs e)
        {
            SqlConnection conexion = ManejadorConexiones.conectar();

            cargarRoles             = new SqlCommand("TRIGGER_EXPLOSION.getRolesHabilitados", conexion);
            cargarRoles.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter adapter = new SqlDataAdapter(cargarRoles);
            DataTable      table   = new DataTable();

            ManejadorConexiones.desconectar();
            adapter.Fill(table);
            comboBox1.DataSource    = table;
            comboBox1.DisplayMember = "Nombre";
        }
Example #19
0
        private void CompraBono_Load(object sender, EventArgs e)
        {
            String query;

            if (Repositorio.getUserActual().rolActual == "Afiliado" && Repositorio.getUserActual().Username != "admin")
            {
                query = "SELECT Id_afiliado FROM TRIGGER_EXPLOSION.Afiliado WHERE Id_usuario = " + Repositorio.getUserActual().Id_usuario;
                String id_afiliado = ManejadorConexiones.ExecuteScalar(query).ToString();
                textBoxNroAfiliado.Text          = id_afiliado;
                this.textBoxNroAfiliado.ReadOnly = true;
            }

            textBoxPrecio.ReadOnly = true;
        }
Example #20
0
        private void cargarFuncionalidades()
        {
            conexion               = ManejadorConexiones.conectar();
            cargarFunc             = new SqlCommand("TRIGGER_EXPLOSION.getFuncionalidades", conexion);
            cargarFunc.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter adapter = new SqlDataAdapter(cargarFunc);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            SqlDataReader reader = cargarFunc.ExecuteReader();

            listBox1.DataSource    = table;
            listBox1.DisplayMember = "Nombre";
            ManejadorConexiones.desconectar();
        }
Example #21
0
        private void btn_habilitar_Click(object sender, EventArgs e)
        {
            conexion              = ManejadorConexiones.conectar();
            habilitar             = new SqlCommand("TRIGGER_EXPLOSION.SP_habilitarRol", conexion);
            habilitar.CommandType = CommandType.StoredProcedure;
            habilitar.Parameters.Add("@nombre", SqlDbType.VarChar).Value = comboBox1.Text.ToString();
            habilitar.ExecuteNonQuery();
            ManejadorConexiones.desconectar();

            String mensaje = "El rol ha sido habilitado";
            String caption = "Rol modificado";

            MessageBox.Show(mensaje, caption, MessageBoxButtons.OK);
            btn_habilitar.Visible = false;
        }
Example #22
0
        private void AgregarDataEnAgenda()
        {
            using (SqlConnection sqlConnection = ManejadorConexiones.conectar())
            {    //FORMAT(Now(),'YYYY-MM-DD')
                DateTime fechaInicial = DateTime.ParseExact(Regex.Replace(FechaInit.Text, @"\s+", ""), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);

                DateTime fechaFinal = DateTime.ParseExact(Regex.Replace(FechaFin.Text, @"\s+", ""), "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture);

                string query = "INSERT INTO TRIGGER_EXPLOSION.Agenda (Id_profesional, Fecha_inicio,Fecha_fin, Especialidad)VALUES (" + id_profesional + ",  '" + fechaInicial + "' ,'" + fechaFinal + "', '" + comboBox1.Text + "')";

                SqlCommand cmd = new SqlCommand(query, ManejadorConexiones.conectar());

                cmd.ExecuteNonQuery();
            }
        }
Example #23
0
        public static void QueryAGrid(String query, DataGridView grid)
        {
            SqlConnection db = ManejadorConexiones.conectar();

            SqlCommand cmd = new SqlCommand(query, db);

            cmd.CommandType = CommandType.Text;

            SqlDataAdapter sqlDataAdap = new SqlDataAdapter(cmd);

            DataTable dtRecord = new DataTable();

            sqlDataAdap.Fill(dtRecord);
            grid.DataSource = dtRecord;
        }
        private void btn_buscar_Click(object sender, EventArgs e)
        {
            if (cboAño.Text != "" && cboEspecialidad.Text != "" && cboMes.Text != "")
            {
                int anio, mes, especialidadId, semestre;

                try
                {
                    anio           = Convert.ToInt32(cboAño.Text);
                    mes            = Convert.ToInt32(cboMes.SelectedValue);
                    semestre       = Convert.ToInt32(cboSemestre.Text.ToString());
                    especialidadId = Convert.ToInt32(cboEspecialidad.SelectedValue.ToString());

                    DataTable dt = new DataTable();

                    String query = "SELECT * from TRIGGER_EXPLOSION.ProfesionalesHoras(@Semestre,@Mes,@Anio,@EspecialidadId) ";

                    SqlCommand cmd = new SqlCommand(query, ManejadorConexiones.conectar());
                    cmd.Parameters.Add("@Semestre", SqlDbType.Int).Value       = semestre;
                    cmd.Parameters.Add("@Mes", SqlDbType.Int).Value            = mes;
                    cmd.Parameters.Add("@Anio", SqlDbType.Int).Value           = anio;
                    cmd.Parameters.Add("@EspecialidadId", SqlDbType.Int).Value = especialidadId;
                    using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
                    {
                        adapter.Fill(dt);
                        cmd.Dispose();
                        ManejadorConexiones.desconectar();
                        if (dt.Rows.Count == 0)
                        {
                            Interfaz.Interfaz.mostrarMensaje("No hay ningun Profesional para los parametros seleccionados!");
                        }
                        else
                        {
                            dataGridView1.DataSource = dt;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Interfaz.Interfaz.mostrarMensaje("Por favor revise los parametros seleccionados");
                    return;
                }
            }
            else
            {
                MessageBox.Show("Complete los criterios de busqueda");
            }
        }
Example #25
0
        private void ModificarRol_Load(object sender, EventArgs e)
        {
            conexion                = ManejadorConexiones.conectar();
            cargarRoles             = new SqlCommand("TRIGGER_EXPLOSION.getRoles", conexion);
            cargarRoles.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter adapter = new SqlDataAdapter(cargarRoles);
            DataTable      table   = new DataTable();

            conexion.Close();
            adapter.Fill(table);
            comboBox1.DataSource    = table;
            comboBox1.DisplayMember = "Nombre";
            comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;

            cargarFuncionalidades();
        }
Example #26
0
        private void CrearRol_Load(object sender, EventArgs e)
        {
            SqlConnection conexion = ManejadorConexiones.conectar();

            cargarFuncionalidades             = new SqlCommand("TRIGGER_EXPLOSION.getFuncionalidades", conexion);
            cargarFuncionalidades.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter adapter = new SqlDataAdapter(cargarFuncionalidades);
            DataTable      table   = new DataTable();

            adapter.Fill(table);
            SqlDataReader reader = cargarFuncionalidades.ExecuteReader();

            listBox1.DataSource    = table;
            listBox1.DisplayMember = "Nombre";
            ManejadorConexiones.desconectar();
        }
        private void botonBajaAfiliado_Click(object sender, EventArgs e)
        {
            if (FilaSeleccionada == -1)
            {
                MessageBox.Show("Por favor, seleccione primero un elemento de la grilla");
                return;
            }
            List <SqlParameter> parametros = new List <SqlParameter>();

            parametros.Add(new SqlParameter("id_afiliado", id_afiliado));
            String bajaAfiliado = "TRIGGER_EXPLOSION.baja_afiliado";

            ManejadorConexiones.ExecuteQuery(bajaAfiliado, parametros);
            MessageBox.Show("Afiliado Nº " + id_afiliado + " dado de baja");
            this.getAfiliados();
        }
Example #28
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (interfaz.elementosEstanIncompletos())
     {
         MessageBox.Show("Por favor, complete los campos antes de enviar");
     }
     else
     {
         List <SqlParameter> parametros = new List <SqlParameter>();
         parametros.Add(new SqlParameter("username", txtUsername.Text));
         parametros.Add(new SqlParameter("contrasenia", txtContrasenia.Text));
         ManejadorConexiones.ExecuteQuery("TRIGGER_EXPLOSION.alta_usuario", parametros);
         MessageBox.Show("Usuario creado");
         this.Close();
     }
 }
Example #29
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (cboAño.Text != "" && cboMes.Text != "")
            {
                try
                {
                    int anio, mes, semestre;
                    anio = Convert.ToInt32(cboAño.SelectedItem.ToString());
                    String mesString = cboMes.SelectedValue.ToString();
                    mes      = Convert.ToInt32(mesString);
                    semestre = Convert.ToInt32(cboSemestre.SelectedItem.ToString());


                    DataTable dt = new DataTable();

                    String query = "SELECT * from TRIGGER_EXPLOSION.AfiliadosBonos(@Semestre,@Mes,@Anio) ";

                    SqlCommand cmd = new SqlCommand(query, ManejadorConexiones.conectar());
                    cmd.Parameters.Add("@Semestre", SqlDbType.Int).Value = semestre;
                    cmd.Parameters.Add("@Mes", SqlDbType.Int).Value      = mes;
                    cmd.Parameters.Add("@Anio", SqlDbType.Int).Value     = anio;
                    using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
                    {
                        adapter.Fill(dt);
                        cmd.Dispose();
                        ManejadorConexiones.desconectar();
                        if (dt.Rows.Count == 0)
                        {
                            Interfaz.Interfaz.mostrarMensaje("No hay ningun afiliado para los parametros seleccionados!");
                        }
                        else
                        {
                            dataGridView1.DataSource = dt;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Interfaz.Interfaz.mostrarMensaje("Consulta cancelada, revise los parametros seleccionados ");
                    ManejadorConexiones.desconectar();
                }
            }
            else
            {
                MessageBox.Show("Complete los criterios de busqueda");
            }
        }
        public bool checkBonos()
        {
            string sql = "select Total_consultas_medicas from TRIGGER_EXPLOSION.Afiliado where Id_afiliado=" + id_afiliado;

            SqlCommand cmd = new SqlCommand(sql, ManejadorConexiones.conectar()); //Agregar este Stored

            using (var reader = cmd.ExecuteReader())
            {
                reader.Read();
                consultas = Convert.ToInt32(reader.GetValue(0));
            }


            int firstDigit = getBaseNumber();

            // firstDigit= firstDigit*100;

            int limitDigit = firstDigit + 100;


            string query = "select top 1 Id_bono from TRIGGER_EXPLOSION.Bono where id_afiliado_comprador between " + firstDigit + " and " + limitDigit + " AND id_usado_por is NULL";

            SqlCommand cmd2 = new SqlCommand(query, ManejadorConexiones.conectar());

            using (SqlDataReader reader = cmd2.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        bono = Convert.ToInt32(reader.GetValue(0));
                        return(true);
                    }

                    reader.Close();

                    return(true);
                }
                else
                {
                    MessageBox.Show("No posee bonos para realizar la consulta, por favor compre primero");
                    ManejadorConexiones.desconectar();
                    this.Close();
                    return(false);
                }
            }
        }