コード例 #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
            }
        }
コード例 #2
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);
                }
            }
        }
コード例 #3
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);
                }
            }
        }