Example #1
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            // Función que valide todos los campos

            string validacionE = validaCampos();

            if (validacionE == "OK")
            {
                //-------- EDITA PERSONA

                string   nombreE     = txtNombre.Text.Trim();
                string   apellidosE  = txtApellidos.Text.Trim();
                string   documentoE  = txtDocumento.Text.Trim();
                DateTime nacimientoE = dtNacimiento.Value.Date;
                string   generoE;
                if (cbGenero.SelectedItem == null)
                {
                    generoE = "";
                }
                else
                {
                    generoE = cbGenero.SelectedItem.ToString();
                }

                string calleE    = txtCalle.Text.Trim();
                string numeroE   = txtNumero.Text.Trim();
                string cpostalE  = txtCPostal.Text.Trim();
                string pisoE     = txtPiso.Text.Trim();
                string dptoE     = txtDepto.Text.Trim();
                string barrioE   = txtBarrio.Text.Trim();
                string telefonoE = txtTelefono.Text.Trim();
                string celularE  = txtCelular.Text.Trim();
                string emailE    = txtEmail.Text.Trim();

                //cbTurno.SelectedItem; no se agrega en ninguna tabla


                //   string id_salaE = cbSala.SelectedValue.ToString(); // debe tomar el id de la sala
                string id_salaE; // debe tomar el id de la sala


                if (cbSala.SelectedItem == null)
                {
                    id_salaE = "";
                }
                else
                {
                    id_salaE = cbSala.SelectedValue.ToString();
                }

                entPersona personaEditar = new entPersona();

                personaEditar.PER_ID         = idPersonaBuscar;
                personaEditar.PER_NOMBRE     = nombreE;
                personaEditar.PER_APELLIDO   = apellidosE;
                personaEditar.PER_DOCUMENTO  = Convert.ToInt32(documentoE);
                personaEditar.PER_GENERO     = generoE; //revisar
                personaEditar.PER_FECHA_NAC  = nacimientoE;
                personaEditar.PER_TELEFONO   = telefonoE;
                personaEditar.PER_TELEFONO_2 = celularE;
                personaEditar.PER_EMAIL      = emailE;
                //personaInsert.PER_TPE_ID = cbTipoPersona2.SelectedValue.ToString();
                //personaInsert.PER_LEGAJO = legajo;
                //personaInsert.PER_ESTADO = "1";

                string resultadoE = objMetPersonas.editarPersona(personaEditar);

                //-------- EDITA DOMICILIO
                entDomicilio domicilioEditar = new entDomicilio();

                domicilioEditar.DOM_PER_ID = idPersonaBuscar;
                domicilioEditar.DOM_CALLE  = calleE;
                domicilioEditar.DOM_NUMERO = Convert.ToInt32(numeroE);
                if (string.IsNullOrWhiteSpace(pisoE.Trim()) == true)
                {
                }
                else
                {
                    domicilioEditar.DOM_PISO = Convert.ToInt32(pisoE);
                }


                domicilioEditar.DOM_DPTO   = dptoE;
                domicilioEditar.DOM_BARRIO = barrioE;
                domicilioEditar.DOM_CP     = Convert.ToInt32(cpostalE);

                resultadoE = objmetDomicilio.editarDomicilio(domicilioEditar);

                //-------- EDITA SALA
                if ((cbTipoPersona.SelectedValue.ToString() == "2"))
                {
                    entGrupoSala grupoSalaEditar = new entGrupoSala();

                    grupoSalaEditar.GRS_PER_ID = Convert.ToInt32(idPersonaBuscar);
                    grupoSalaEditar.GRS_SAL_ID = Convert.ToInt32(id_salaE);

                    //metSalas metSalas = new metSalas();
                    resultadoE = objMetSalas.editarGrupoSala(grupoSalaEditar);
                }

                //al terminar de insertar Borra todos los campos
                if (resultadoE == "OK")
                {
                    MessageBox.Show("Se han editado los datos con éxito.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    limpiarCampos();
                }
            }
            else
            {
                MessageBox.Show("No olvide ingresar " + validacionE + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }