Ejemplo n.º 1
0
        private void btn_registrar_Click(object sender, EventArgs e)
        {
            if (txt_apellidos.Text.Trim().Equals(""))
            {
                txt_apellidos.Focus();
                MessageBox.Show("Completar Apellidos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_nombre.Text.Trim().Equals(""))
            {
                txt_nombre.Focus();
                MessageBox.Show("Completar Nombre", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_cedula.Text.Trim().Length != 8)
            {
                txt_cedula.Focus();
                MessageBox.Show("Completar Cedula de 8 digitos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_direccion.Text.Trim().Equals(""))
            {
                txt_direccion.Focus();
                MessageBox.Show("Completar Direccion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (dgv_telefonos.Rows.Count == 0)
            {
                MessageBox.Show("Ingresar al menos un telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                var empleado = new Clases.Empleado(
                    txt_apellidos.Text.Trim().ToUpper(),
                    txt_nombre.Text.Trim().ToUpper(),
                    txt_cedula.Text.Trim(),
                    cbo_genero.Text,
                    cbo_estado_civil.Text,
                    txt_direccion.Text.Trim(),
                    cbo_distrito.SelectedValue.ToString()
                    );

                int ultimo_id = empleado.Registrar();

                int numero_filas = dgv_telefonos.Rows.Count;

                for (int i = 0; i < numero_filas; i++)
                {
                    string operador    = dgv_telefonos.Rows[i].Cells[0].Value.ToString();
                    string numero      = dgv_telefonos.Rows[i].Cells[1].Value.ToString();
                    int    empleado_id = ultimo_id;
                    var    telefono    = new Clases.Telefono(operador, numero, empleado_id);
                    var    resultado   = telefono.Registrar();

                    if (!resultado)
                    {
                        MessageBox.Show("Error al registrar telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                MessageBox.Show("Empleado registrado correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                empleado.ListarEmpleadoDataGridView(Vistas.Empleados.FormListar.MyForm.dgv_empleados); // Listado actualizado
            }
        }
Ejemplo n.º 2
0
 private void dgv_telefonos_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     if (e.RowIndex != -1)
     {
         if (dgv_telefonos.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar"))
         {
             DialogResult res = MessageBox.Show("Deseas eliminar este Item?", "Mensaje",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
             if (res == DialogResult.Yes)
             {
                 int telefono_id = int.Parse(dgv_telefonos.Rows[e.RowIndex].Cells[3].Value.ToString());
                 if (telefono_id > 0)
                 {
                     //CODIGO PARA ELIMINAR DE LA BASE DE DATOS
                     var telefono = new Clases.Telefono(telefono_id);
                     if (telefono.Eliminar())
                     {
                         dgv_telefonos.Rows.RemoveAt(e.RowIndex);
                     }
                     else
                     {
                         MessageBox.Show("Error al eliminar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     }
                 }
                 else
                 {
                     // ELIMINAR DE DATAGRIDVIEW
                     dgv_telefonos.Rows.RemoveAt(e.RowIndex);
                 }
             }
         }
     }
 }
Ejemplo n.º 3
0
        private void dgv_empleados_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                if (dgv_empleados.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar"))
                {
                    var f = new FormActualizar();
                    f.Show();
                    var empleado       = new Clases.Empleado();
                    int empleado_id    = int.Parse(dgv_empleados.Rows[e.RowIndex].Cells[6].Value.ToString());
                    var tabla_empleado = empleado.BuscarPorCodigo(empleado_id);
                    if (tabla_empleado.Rows.Count == 1)
                    {
                        FormActualizar.MyForm.txt_apellidos.Text    = tabla_empleado.Rows[0]["APELLIDOS"].ToString();
                        FormActualizar.MyForm.txt_nombre.Text       = tabla_empleado.Rows[0]["NOMBRE"].ToString();
                        FormActualizar.MyForm.txt_dni.Text          = tabla_empleado.Rows[0]["DNI"].ToString();
                        FormActualizar.MyForm.cbo_genero.Text       = tabla_empleado.Rows[0]["GENERO"].ToString();
                        FormActualizar.MyForm.cbo_estado_civil.Text = tabla_empleado.Rows[0]["ESTADO_CIVIL"].ToString();
                        FormActualizar.MyForm.txt_direccion.Text    = tabla_empleado.Rows[0]["DIRECCION"].ToString();

                        FormActualizar.MyForm.cbo_departamento.SelectedValue = tabla_empleado.Rows[0]["DEPARTAMENTO_ID"].ToString();
                        FormActualizar.MyForm.cbo_provincia.SelectedValue    = tabla_empleado.Rows[0]["PROVINCIA_ID"].ToString();
                        FormActualizar.MyForm.cbo_distrito.SelectedValue     = tabla_empleado.Rows[0]["DISTRITO_ID"].ToString();

                        var telefono        = new Clases.Telefono();
                        var tabla_telefonos = telefono.BuscarPorCodigo(empleado_id);

                        int numero_filas = tabla_telefonos.Rows.Count;
                        if (numero_filas > 0)
                        {
                            for (int i = 0; i < numero_filas; i++)
                            {
                                int    telefono_id = int.Parse(tabla_telefonos.Rows[i][0].ToString());
                                string operador    = tabla_telefonos.Rows[i][1].ToString();
                                string numero      = tabla_telefonos.Rows[i][2].ToString();
                                FormActualizar.MyForm.dgv_telefonos.Rows.Add(
                                    operador, numero, "Eliminar", empleado_id, telefono_id
                                    );
                            }
                        }
                        FormActualizar.MyForm.empleadoId_TEMP = empleado_id;
                    }
                }
                if (dgv_empleados.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar"))
                {
                    DialogResult res = MessageBox.Show("Deseas eliminar este empleado ? ", "Mensaje",
                                                       MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);

                    if (res == DialogResult.Yes)
                    {
                        int empleado_id = int.Parse(dgv_empleados.Rows[e.RowIndex].Cells[6].Value.ToString());
                        var empleado    = new Clases.Empleado(empleado_id);
                        if (empleado.Eliminar())
                        {
                            dgv_empleados.Rows.RemoveAt(e.RowIndex);
                        }
                        else
                        {
                            MessageBox.Show("Error al eliminar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        private void btn_actualizar_Click(object sender, EventArgs e)
        {
            if (txt_apellidos.Text.Trim().Equals(""))
            {
                txt_apellidos.Focus();
                MessageBox.Show("Completar Apellidos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_nombre.Text.Trim().Equals(""))
            {
                txt_nombre.Focus();
                MessageBox.Show("Completar Nombre", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_dni.Text.Trim().Equals(""))
            {
                txt_dni.Focus();
                MessageBox.Show("Completar Dni", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_dni.Text.Trim().Length != 8)
            {
                txt_dni.Focus();
                MessageBox.Show("Completar Dni de 8 digitos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_direccion.Text.Trim().Equals(""))
            {
                txt_direccion.Focus();
                MessageBox.Show("Completar la direccion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (dtp_fechaNacimiento.Value.Equals(""))
            {
                dtp_fechaNacimiento.Focus();
                MessageBox.Show("Completar la fecha de nacimiento", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_observaciones.Text.Trim().Equals(""))
            {
                txt_observaciones.Focus();
                MessageBox.Show("Completar la observacion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (dgv_telefonos.Rows.Count == 0)
            {
                MessageBox.Show("Ingresar al menos un telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                var paciente = new Clases.Paciente(
                    txt_apellidos.Text.Trim().ToUpper(),
                    txt_nombre.Text.Trim().ToUpper(),
                    txt_dni.Text.Trim(),
                    cbo_genero.Text,
                    cbo_estadoCivil.Text,
                    txt_direccion.Text.Trim(),
                    cbo_distrito.SelectedValue.ToString(),
                    dtp_fechaNacimiento.Value,
                    txt_observaciones.Text.Trim().ToUpper(),
                    pacienteId_TEMP
                    );


                bool resultado_emp = paciente.Actualizar();
                if (resultado_emp)
                {
                    int numero_filas = dgv_telefonos.Rows.Count;
                    for (int i = 0; i < numero_filas; i++)
                    {
                        int id = int.Parse(dgv_telefonos.Rows[i].Cells[3].Value.ToString());
                        if (id == 0)
                        {
                            string operador  = dgv_telefonos.Rows[i].Cells[0].Value.ToString();
                            string numero    = dgv_telefonos.Rows[i].Cells[1].Value.ToString();
                            var    telefono  = new Clases.Telefono(operador, numero, pacienteId_TEMP);
                            var    resultado = telefono.Registrar();

                            if (!resultado)
                            {
                                MessageBox.Show("Error al registrar telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                    historiaClinica_TEMP = int.Parse(txt_numeroHC.Text);
                    //ACTUALIZA HC
                    var historia_clinica = new Clases.HistoriaClinica(
                        txt_AntecedentePersonal.Text.Trim().ToUpper(),
                        pacienteId_TEMP,
                        historiaClinica_TEMP //ERROR
                        );
                    bool resultado_usu = historia_clinica.Actualizar();
                    MessageBox.Show("Paciente actualizado correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    paciente.ListarPacientesDataGridView(Vistas.Formularios.Pacientes.FormListarPacientes.MyForm.dgv_pacientes);
                    limpiar();
                }
                else
                {
                    MessageBox.Show("Error al actualizar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 5
0
        private void dgv_pacientes_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                if (dgv_pacientes.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar"))
                {
                    var f = new FormActualizarPacientes();
                    f.Show();

                    var paciente = new Clases.Paciente();

                    int paciente_id = int.Parse(dgv_pacientes.Rows[e.RowIndex].Cells[6].Value.ToString());

                    var tabla_paciente = paciente.BuscarPorCodigo(paciente_id);

                    if (tabla_paciente.Rows.Count == 1)
                    {
                        FormActualizarPacientes.MyForm.txt_apellidos.Text       = tabla_paciente.Rows[0]["APELLIDOS"].ToString();
                        FormActualizarPacientes.MyForm.txt_nombre.Text          = tabla_paciente.Rows[0]["NOMBRE"].ToString();
                        FormActualizarPacientes.MyForm.txt_dni.Text             = tabla_paciente.Rows[0]["DNI"].ToString();
                        FormActualizarPacientes.MyForm.cbo_genero.Text          = tabla_paciente.Rows[0]["GENERO"].ToString();
                        FormActualizarPacientes.MyForm.cbo_estadoCivil.Text     = tabla_paciente.Rows[0]["ESTADO_CIVIL"].ToString();
                        FormActualizarPacientes.MyForm.txt_direccion.Text       = tabla_paciente.Rows[0]["DIRECCION"].ToString();
                        FormActualizarPacientes.MyForm.dtp_fechaNacimiento.Text = tabla_paciente.Rows[0]["FECHA_NACIMIENTO"].ToString();
                        FormActualizarPacientes.MyForm.txt_observaciones.Text   = tabla_paciente.Rows[0]["OBSERVACIONES"].ToString();

                        FormActualizarPacientes.MyForm.cbo_departamento.SelectedValue = tabla_paciente.Rows[0]["DEPARTAMENTO_ID"].ToString();
                        FormActualizarPacientes.MyForm.cbo_provincia.SelectedValue    = tabla_paciente.Rows[0]["PROVINCIA_ID"].ToString();
                        FormActualizarPacientes.MyForm.cbo_distrito.SelectedValue     = tabla_paciente.Rows[0]["DISTRITO_ID"].ToString();


                        var telefono        = new Clases.Telefono();
                        var tabla_telefonos = telefono.BuscarPorCodigo(paciente_id);
                        var numero_filas    = tabla_telefonos.Rows.Count;
                        if (numero_filas > 0)
                        {
                            for (int i = 0; i < numero_filas; i++)
                            {
                                int    telefono_id = int.Parse(tabla_telefonos.Rows[i][0].ToString());
                                string operador    = tabla_telefonos.Rows[i][1].ToString();
                                string numero      = tabla_telefonos.Rows[i][2].ToString();

                                FormActualizarPacientes.MyForm.dgv_telefonos.Rows.Add(
                                    operador, numero, "Eliminar", paciente_id, telefono_id
                                    );
                                //listar el número de LA HISTORIA CLINICA
                                var historia_clinica       = new Clases.HistoriaClinica();
                                var tabla_historia_clinica = historia_clinica.BuscarPorCodigo(paciente_id);

                                FormActualizarPacientes.MyForm.txt_numeroHC.Text            = tabla_historia_clinica.Rows[0]["NUMERO_HISTORIA"].ToString();
                                FormActualizarPacientes.MyForm.txt_AntecedentePersonal.Text = tabla_historia_clinica.Rows[0]["ANTECEDENTE_PERSONAL"].ToString();
                            }
                        }
                        FormActualizarPacientes.MyForm.pacienteId_TEMP = paciente_id;
                    }
                }
                if (dgv_pacientes.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar"))
                {
                    int paciente_id = int.Parse(dgv_pacientes.Rows[e.RowIndex].Cells[6].Value.ToString());

                    DialogResult res = MessageBox.Show("Deseas eliminar este Paciente?", "Mensaje",
                                                       MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                    if (res == DialogResult.Yes)
                    {
                        var paciente = new Clases.Paciente(paciente_id);
                        if (paciente.Eliminar())
                        {
                            // ELIMINAR DE DATAGRIDVIEW Y DE LA BASE DE DATOS
                            dgv_pacientes.Rows.RemoveAt(e.RowIndex);
                        }
                        else
                        {
                            MessageBox.Show("Error al eliminar", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void btn_registrar_Click(object sender, EventArgs e)
        {
            if (txt_apellidos.Text.Trim().Equals(""))
            {
                txt_apellidos.Focus();
                MessageBox.Show("Completar Apellidos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_nombre.Text.Trim().Equals(""))
            {
                txt_nombre.Focus();
                MessageBox.Show("Completar Nombre", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_dni.Text.Trim().Equals(""))
            {
                txt_dni.Focus();
                MessageBox.Show("Completar Dni", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_dni.Text.Trim().Length != 8)
            {
                txt_dni.Focus();
                MessageBox.Show("Completar Dni de 8 digitos", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_direccion.Text.Trim().Equals(""))
            {
                txt_direccion.Focus();
                MessageBox.Show("Completar la direccion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (dtp_fechaNacimiento.Value.Equals(""))
            {
                dtp_fechaNacimiento.Focus();
                MessageBox.Show("Completar la fecha de nacimiento", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (txt_observaciones.Text.Trim().Equals(""))
            {
                txt_observaciones.Focus();
                MessageBox.Show("Completar la observacion", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (dgv_telefonos.Rows.Count == 0)
            {
                MessageBox.Show("Ingresar al menos un telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                var paciente = new Clases.Paciente(
                    txt_apellidos.Text.Trim().ToUpper(),
                    txt_nombre.Text.Trim().ToUpper(),
                    txt_dni.Text.Trim(),
                    cbo_genero.Text,
                    cbo_estadoCivil.Text,
                    txt_direccion.Text.Trim(),
                    cbo_distrito.SelectedValue.ToString(),
                    dtp_fechaNacimiento.Value,
                    txt_observaciones.Text.Trim().ToUpper()
                    );


                int ultimo_id = paciente.Registrar();
                if (ultimo_id > 0)
                {
                    int numero_filas = dgv_telefonos.Rows.Count;
                    for (int i = 0; i < numero_filas; i++)
                    {
                        string operador    = dgv_telefonos.Rows[i].Cells[0].Value.ToString();
                        string numero      = dgv_telefonos.Rows[i].Cells[1].Value.ToString();
                        int    paciente_id = ultimo_id;
                        var    telefono    = new Clases.Telefono(operador, numero, paciente_id);
                        var    resultado   = telefono.Registrar();

                        if (!resultado)
                        {
                            MessageBox.Show("Error al registrar telefono", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    //REGISTRA LA HISTORIA CLINICA
                    var historia_clinica = new Clases.HistoriaClinica(
                        txt_AntecedentePersonal.Text.Trim(),
                        ultimo_id
                        );
                    bool resultado_HC = historia_clinica.Registrar();

                    if (!resultado_HC)
                    {
                        MessageBox.Show("Error al registrar la Historia Clinica del Paciente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    MessageBox.Show("Paciente registrado correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    paciente.ListarPacientesDataGridView(Vistas.Formularios.Pacientes.FormListarPacientes.MyForm.dgv_pacientes);
                    limpiar();
                }
                else
                {
                    MessageBox.Show("Error al registrar paciente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }