示例#1
0
        public string editarGrupoSala(entGrupoSala grupoSalaEditar)
        {
            string result = "";

            try
            {
                con = generarConexion();
                con.Open();

                string consulta = "UPDATE T_GRUPO_SALA SET " +
                                  "GRS_SAL_ID = " + "'" + grupoSalaEditar.GRS_SAL_ID + "'" +
                                  " " +
                                  "WHERE GRS_PER_ID = " + "'" + grupoSalaEditar.GRS_PER_ID + "'" +
                                  ";";


                cmd = new SqlCommand(consulta, con);
                cmd.ExecuteNonQuery();
                con.Close();

                result = "OK";
            }
            catch
            {
                result = "ERROR";
                MessageBox.Show("Hubo un problema. Contáctese con su administrador.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            return(result);
        }
示例#2
0
        public string insertarGrupoSala(entGrupoSala grupoSala)
        {
            string result = "";

            try
            {
                con = generarConexion();
                con.Open();

                string consulta = "INSERT INTO T_GRUPO_SALA " +
                                  "(GRS_SAL_ID" +
                                  ", GRS_PER_ID)" +
                                  "VALUES " +
                                  "('" + grupoSala.GRS_SAL_ID + "'" +
                                  ", '" + grupoSala.GRS_PER_ID + "')";


                cmd = new SqlCommand(consulta, con);
                cmd.ExecuteNonQuery();
                con.Close();

                result = "OK";
            }
            catch
            {
                result = "ERROR";
                MessageBox.Show("Hubo un problema. Contáctese con su administrador.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            return(result);
        }
示例#3
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            string      id_salaE    = cbSala.SelectedValue.ToString();
            string      turno       = cbTurno.SelectedItem.ToString();
            DateTime    dt_nac      = dtNacimiento.Value;
            string      validacion  = validaCampos();
            logPersonas logPersonas = new logPersonas();

            string resultado_val_salas = logPersonas.Validar_Salas(dt_nac, id_salaE, turno);

            if (validacion == "OK" && resultado_val_salas == "OK")
            {
                //-------- EDITA PERSONA

                string   nombreE     = txtNombre.Text.Trim();
                string   apellidosE  = txtApellidos.Text.Trim();
                string   documentoE  = txtDocumento.Text.Trim();
                DateTime nacimientoE = dtNacimiento.Value.Date;


                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();


                entPersona personaEditar = new entPersona();

                string genero;

                if (cbGenero.SelectedItem == null)
                {
                    genero = "";
                }
                else
                {
                    genero = cbGenero.SelectedItem.ToString();
                }


                personaEditar.PER_ID         = Convert.ToInt32(idPersonaSelect);
                personaEditar.PER_NOMBRE     = nombreE;
                personaEditar.PER_APELLIDO   = apellidosE;
                personaEditar.PER_DOCUMENTO  = Convert.ToInt32(documentoE);
                personaEditar.PER_GENERO     = genero;//cbGenero.SelectedValue.ToString(); //revisar
                personaEditar.PER_FECHA_NAC  = nacimientoE;
                personaEditar.PER_TELEFONO   = telefonoE;
                personaEditar.PER_TELEFONO_2 = celularE;
                personaEditar.PER_EMAIL      = emailE;


                int vacante = Convert.ToInt32(txtLegajo.Text);
                if (vacante == 0)
                {
                    txtLegajo.Style = MetroFramework.MetroColorStyle.Red;
                    txtLegajo.Focus();

                    MessageBox.Show("No existen vacantes para el turno y sala elegida. Por favor elija otro turno.", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    string resultadoE = metPers.editarPersona(personaEditar);

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

                    domicilioEditar.DOM_PER_ID = Convert.ToInt32(idPersonaSelect);
                    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 = metDomic.editarDomicilio(domicilioEditar);

                    //-------- EDITA SALA

                    entGrupoSala grupoSalaEditar = new entGrupoSala();

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

                    resultadoE = metSala.editarGrupoSala(grupoSalaEditar);

                    if (resultadoE == "OK")
                    {
                        MessageBox.Show("Se han editado los datos con éxito.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
            }
            else if (resultado_val_salas != "OK")
            {
                MessageBox.Show(resultado_val_salas);
                cbSala.SelectedIndex = -1;
                cbSala.Style         = MetroFramework.MetroColorStyle.Red;
                cbSala.Focus();
                lblSala.Text      = "Por favor, seleccione una sala";
                lblSala.ForeColor = Color.Red;
            }
            else
            {
                MessageBox.Show("No olvide ingresar " + validacion + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            string      sala        = cbSala.SelectedValue.ToString();
            string      turno       = cbTurno.SelectedItem.ToString();
            DateTime    dt_nac      = dtNacimiento.Value;
            string      validacion  = validaCampos();
            logPersonas logPersonas = new logPersonas();

            string resultado_val_salas = logPersonas.Validar_Salas(dt_nac, sala, turno);

            if (validacion == "OK" && resultado_val_salas == "OK")
            {
                // Preparo la info de todos los campos

                string   nombre     = txtNombre.Text.Trim();
                string   apellidos  = txtApellidos.Text.Trim();
                string   documento  = txtDocumento.Text.Trim();
                DateTime nacimiento = dtNacimiento.Value.Date;
                string   genero;
                if (cbGenero.SelectedItem == null)
                {
                    genero = "";
                }
                else
                {
                    genero = cbGenero.SelectedItem.ToString();
                }

                string calle    = txtCalle.Text.Trim();
                string numero   = txtNumero.Text.Trim();
                string cpostal  = txtCPostal.Text.Trim();
                string piso     = txtPiso.Text.Trim();
                string dpto     = txtDepto.Text.Trim();
                string barrio   = txtBarrio.Text.Trim();
                string telefono = txtTelefono.Text.Trim();
                string celular  = txtCelular.Text.Trim();
                string email    = txtEmail.Text.Trim();

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

                //-- Termina de preparar todos los datos

                //--- Secuenciador de Legajo
                logParametricas logParametricas = new logParametricas();
                string          legajo          = logParametricas.secuenciadorLegajoAlumnos(); // lo genera solo
                //--------

                entPersona personaInsert = new entPersona();

                personaInsert.PER_NOMBRE     = nombre;
                personaInsert.PER_APELLIDO   = apellidos;
                personaInsert.PER_DOCUMENTO  = Convert.ToInt32(documento);
                personaInsert.PER_GENERO     = genero; //revisar
                personaInsert.PER_FECHA_NAC  = nacimiento;
                personaInsert.PER_TELEFONO   = telefono;
                personaInsert.PER_TELEFONO_2 = celular;
                personaInsert.PER_EMAIL      = email;
                personaInsert.PER_TPE_ID     = "2";
                personaInsert.PER_LEGAJO     = legajo;
                personaInsert.PER_ESTADO     = "S";

                // INSERTA PERSONA
                logPersonas metPersona = new logPersonas();
                string      resultado  = metPersona.Insertar(personaInsert);
                // -----

                if (resultado == "OK")
                {                                                                          // entra solo si inserto la persona correctamente
                    personaInsert = metPersona.BuscaPersona(nombre, apellidos, documento); // TRAE EL ID RECIEN INSERTADO
                    Int32 id_persona = personaInsert.PER_ID;

                    // INSERTA GRUPO FAMILIAR
                    //string valor = cbHrmDomicilio.SelectedItem.ToString();
                    string valor;

                    if (cbHrmDomicilio.SelectedItem == null)
                    {
                        valor = "";
                    }
                    else
                    {
                        valor = cbHrmDomicilio.SelectedItem.ToString();
                    }

                    if (valor.StartsWith("SI"))
                    {
                        logGrupoFlia objGrpFlia = new logGrupoFlia();
                        string       resulta3   = objGrpFlia.insertaEnGrupoFlia(Convert.ToInt32(id_persona), Convert.ToString(idHmno)); // antes se pasaba el legajo como segundo parametro, ahora pasamos el id_persona del hermano
                    }
                    else
                    {
                        logGrupoFlia objGrpFlia = new logGrupoFlia();
                        string       resulta3   = objGrpFlia.insertaEnGrupoFlia(Convert.ToInt32(id_persona), Convert.ToString(id_persona));
                    }
                    // -----

                    //INSERTA DOMICILIO
                    entDomicilio domicilioInsertar = new entDomicilio();

                    domicilioInsertar.DOM_PER_ID = id_persona;
                    domicilioInsertar.DOM_CALLE  = calle;
                    domicilioInsertar.DOM_NUMERO = Convert.ToInt32(numero);
                    if (string.IsNullOrWhiteSpace(piso.Trim()) == true)
                    {
                    }
                    else
                    {
                        domicilioInsertar.DOM_PISO = Convert.ToInt32(piso);
                    }

                    domicilioInsertar.DOM_DPTO   = dpto;
                    domicilioInsertar.DOM_BARRIO = barrio;
                    domicilioInsertar.DOM_CP     = Convert.ToInt32(cpostal);

                    logDomicilio logDomicilio = new logDomicilio();
                    resultado = logDomicilio.Insertar(domicilioInsertar);
                    // -----

                    //INSERTA GRUPO SALA

                    entGrupoSala grupoSalaInsertar = new entGrupoSala();

                    grupoSalaInsertar.GRS_PER_ID = Convert.ToInt32(id_persona);
                    grupoSalaInsertar.GRS_SAL_ID = Convert.ToInt32(id_sala);

                    logSalas logSalas = new logSalas();
                    resultado = logSalas.insertarGrupoSala(grupoSalaInsertar);
                    // -----

                    if (resultado == "OK")
                    {
                        MessageBox.Show("Se ha ingresado el registro con éxito.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        logCuota logCuota = new logCuota();
                        decimal  monto    = logCuota.Monto_Matricula();

                        string resultadoGenerarMat = logCuota.GeneraraMatricula(monto, id_persona);
                        if (resultadoGenerarMat == "OK")
                        {
                            int cuo_id = logCuota.cuoId(id_persona);

                            string resultadoMat = logCuota.InsertarCuotaDetalle(cuo_id, 1, monto);
                            if (resultadoMat == "OK")
                            {
                                MessageBox.Show("Se genero la solicitud de cobro de 'MATRICULA' para efectuar el mismo ingresar a GESTIÓN COBROS > GESTIONAR.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                reciboMatricula reciboMatricula = new reciboMatricula(id_persona);
                                this.Close();
                            }
                        }
                        //limpiarCampos();
                    }
                }
            }

            else if (resultado_val_salas != "OK")
            {
                MessageBox.Show(resultado_val_salas);
                cbSala.SelectedIndex = -1;
                cbSala.Style         = MetroFramework.MetroColorStyle.Red;
                cbSala.Focus();
                lblSala.Text      = "Por favor, seleccione una sala";
                lblSala.ForeColor = Color.Red;
            }
            else
            {
                MessageBox.Show("No olvide ingresar " + validacion + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#5
0
        /*********************************/
        /*********GUARDAR EDITAR**********/
        /*********************************/

        private void btnguardar_Click(object sender, EventArgs e)
        {
            frmDocentes Docentes = Owner as frmDocentes;

            objlogPersonas.EdadDocente(dtNacimiento.Value);

            string validacionE = validaCampos();

            if (validacionE == "OK")

            {
                idPersonaBuscar = Convert.ToInt32(txt_id_Docente.Text);

                string   nombreE     = txtNombre.Text.Trim();
                string   apellidosE  = txtApellidos.Text.Trim();
                string   documentoE  = txtDocumento.Text.Trim();
                DateTime nacimientoE = dtNacimiento.Value.Date;

                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();

                entPersona personaEditar = new entPersona();

                string genero;
                if (cbGenero.SelectedItem == null)
                {
                    genero = "";
                }
                else
                {
                    genero = cbGenero.SelectedItem.ToString();
                }

                personaEditar.PER_ID         = Convert.ToInt32(idPersonaBuscar);
                personaEditar.PER_NOMBRE     = nombreE;
                personaEditar.PER_APELLIDO   = apellidosE;
                personaEditar.PER_DOCUMENTO  = Convert.ToInt32(documentoE);
                personaEditar.PER_GENERO     = genero;
                personaEditar.PER_FECHA_NAC  = nacimientoE;
                personaEditar.PER_TELEFONO   = telefonoE;
                personaEditar.PER_TELEFONO_2 = celularE;
                personaEditar.PER_EMAIL      = emailE;

                string resultadoE = objlogPersonas.editarPersona(personaEditar);

                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 = objlogDomicilio.editarDomicilio(domicilioEditar);

                if (resultadoE == "OK")
                {
                    string CARGO;

                    if (Cbocargo.SelectedItem == null)
                    {
                        CARGO = "";
                    }
                    else
                    {
                        CARGO = Cbocargo.SelectedItem.ToString();
                        if (CARGO == "TITULAR")
                        {
                            CARGO = "TITULAR";
                        }
                        else
                        {
                            CARGO = "SUPLENTE";
                        }
                    }

                    string turno;

                    if (cbTurno.SelectedItem == null)
                    {
                        turno = "";
                    }
                    else
                    {
                        turno = cbTurno.SelectedItem.ToString();

                        if (turno == "MAÑANA")
                        {
                            turno = "MANANA";
                        }
                        else
                        {
                            turno = "TARDE";
                        }
                    }
                    string id_sala;

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

                    if (turno == cbTurno.Text && id_sala == cbSala.Text)
                    {
                        MessageBox.Show("Se ha ingresado el registro con éxito.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                    //else
                    //{

                    entGrupoSala grupoSalaEditar = new entGrupoSala();
                    grupoSalaEditar.GRS_PER_ID = Convert.ToInt32(idPersonaBuscar);
                    grupoSalaEditar.GRS_SAL_ID = Convert.ToInt32(id_sala);
                    grupoSalaEditar.GRS_CARGO  = CARGO.ToString();
                    resultadoE = objlogSalas.editarGrupoSala(grupoSalaEditar);
                    if (resultadoE == "OK")
                    {
                        MessageBox.Show("Se actualizado ok el registro.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }

                    else
                    {
                        MessageBox.Show("El cupo de docente en la sala y turno seleccionados ya esta completo", "Salir", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        cbTurno.SelectedIndex = -1;
                        cbSala.SelectedIndex  = -1;
                    }  //}
                }
                else
                {
                    MessageBox.Show("NO OLVIDE INGRESAR " + validacionE + ".", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
示例#6
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);
            }
        }
示例#7
0
        private void btnInsertar_Click(object sender, EventArgs e)
        {
            // Función que valide todos los campos

            string validacion = validaCampos();

            if (validacion == "OK")
            {
                // Preparo la info de todos los campos

                string   nombre     = txtNombre.Text.Trim();
                string   apellidos  = txtApellidos.Text.Trim();
                string   documento  = txtDocumento.Text.Trim();
                DateTime nacimiento = dtNacimiento.Value.Date;
                string   genero;
                if (cbGenero.SelectedItem == null)
                {
                    genero = "";
                }
                else
                {
                    genero = cbGenero.SelectedItem.ToString();
                }

                string calle    = txtCalle.Text.Trim();
                string numero   = txtNumero.Text.Trim();
                string cpostal  = txtCPostal.Text.Trim();
                string piso     = txtPiso.Text.Trim();
                string dpto     = txtDepto.Text.Trim();
                string barrio   = txtBarrio.Text.Trim();
                string telefono = txtTelefono.Text.Trim();
                string celular  = txtCelular.Text.Trim();
                string email    = txtEmail.Text.Trim();

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

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

                metParametricas metParametricas = new metParametricas();
                string          legajo          = metParametricas.secuenciadorLegajoAlumnos(); // lo genera solo
                //--------

                entPersona personaInsert = new entPersona();

                personaInsert.PER_NOMBRE     = nombre;
                personaInsert.PER_APELLIDO   = apellidos;
                personaInsert.PER_DOCUMENTO  = Convert.ToInt32(documento);
                personaInsert.PER_GENERO     = genero; //revisar
                personaInsert.PER_FECHA_NAC  = nacimiento;
                personaInsert.PER_TELEFONO   = telefono;
                personaInsert.PER_TELEFONO_2 = celular;
                personaInsert.PER_EMAIL      = email;
                personaInsert.PER_TPE_ID     = cbTipoPersona2.SelectedValue.ToString();
                personaInsert.PER_LEGAJO     = legajo;
                personaInsert.PER_ESTADO     = "1";


                metPersonas metPersona = new metPersonas();
                string      resultado  = metPersona.Insertar(personaInsert); // INSERTA PERSONA
                //nombre = "RAMON";
                //apellidos = "LOPEZ";
                //documento = "25654987";

                if (resultado == "OK")   // entra a insertar el domicilio de la persona solo si inserto la persona correctamente

                {
                    personaInsert = metPersona.BuscaPersona(nombre, apellidos, documento); // TRAE EL ID RECIEN INSERTADO
                    Int32 id_persona = personaInsert.PER_ID;

                    // popUp del familiar
                    if ((cbTipoPersona2.SelectedValue.ToString() != "1") && (cbTipoPersona2.SelectedValue.ToString() != "2"))
                    {
                        frmPopUpFlia frmFlia = new frmPopUpFlia();
                        frmFlia.ShowDialog();

                        string LegajoAsociado = frmFlia.Legajo; // familiar al que se asocia al ingresado

                        metGrupoFlia objGrpFlia = new metGrupoFlia();

                        string resulta3 = objGrpFlia.insertaEnGrupoFlia(Convert.ToInt32(id_persona), LegajoAsociado);
                    }
                    else if (cbTipoPersona2.SelectedValue.ToString() == "2")
                    {
                        metGrupoFlia objGrpFlia = new metGrupoFlia();
                        string       resulta3   = objGrpFlia.insertaEnGrupoFlia(Convert.ToInt32(id_persona), legajo);
                    }
                    // -----

                    //INSERTA DOMICILIO
                    entDomicilio domicilioInsertar = new entDomicilio();

                    domicilioInsertar.DOM_PER_ID = id_persona;
                    domicilioInsertar.DOM_CALLE  = calle;
                    domicilioInsertar.DOM_NUMERO = Convert.ToInt32(numero);
                    if (string.IsNullOrWhiteSpace(piso.Trim()) == true)
                    {
                    }
                    else
                    {
                        domicilioInsertar.DOM_PISO = Convert.ToInt32(piso);
                    }


                    domicilioInsertar.DOM_DPTO   = dpto;
                    domicilioInsertar.DOM_BARRIO = barrio;
                    domicilioInsertar.DOM_CP     = Convert.ToInt32(cpostal);


                    metDomicilio metDomicilio = new metDomicilio();
                    resultado = metDomicilio.Insertar(domicilioInsertar);

                    //INSERTA GRUPO SALA SOLO SI ES DOCENTE O ALUMNO
                    if ((cbTipoPersona2.SelectedValue.ToString() == "2") || (cbTipoPersona2.SelectedValue.ToString() == "1"))
                    {
                        entGrupoSala grupoSalaInsertar = new entGrupoSala();

                        grupoSalaInsertar.GRS_PER_ID = Convert.ToInt32(id_persona);
                        grupoSalaInsertar.GRS_SAL_ID = Convert.ToInt32(id_sala);

                        metSalas metSalas = new metSalas();
                        resultado = metSalas.insertarGrupoSala(grupoSalaInsertar);
                    }

                    //al terminar de insertar Borra todos los campos
                    if (resultado == "OK")
                    {
                        MessageBox.Show("Se ha ingresado el registro con éxito.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        limpiarCampos();
                    }
                }
            }
            else
            {
                MessageBox.Show("No olvide ingresar " + validacion + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        } // termina el insertar
        /*********************************************************/
        /***************** GUARDAR NUEVO DOCENTE *****************/
        /*********************************************************/

        private void btnguardar_Click(object sender, EventArgs e)
        {
            logPersonas ObjMetOersonas = new logPersonas();

            objlogPersonas.EdadDocente(dtNacimiento.Value);

            string resultado;

            string validacion = validaCampos();

            if (validacion == "OK")
            {
                string   nombre     = txtNombre.Text.Trim();
                string   apellidos  = txtApellidos.Text.Trim();
                string   documento  = txtDocumento.Text.Trim();
                DateTime nacimiento = dtNacimiento.Value.Date;
                string   genero;

                if (cbGenero.SelectedItem == null)
                {
                    genero = "";
                }
                else
                {
                    genero = cbGenero.SelectedItem.ToString();
                }

                string calle    = txtCalle.Text.Trim();
                string numero   = txtNumero.Text.Trim();
                string cpostal  = txtCPostal.Text.Trim();
                string piso     = txtPiso.Text.Trim();
                string dpto     = txtDepto.Text.Trim();
                string barrio   = txtBarrio.Text.Trim();
                string telefono = txtTelefono.Text.Trim();
                string celular  = txtCelular.Text.Trim();
                string email    = txtEmail.Text.Trim();
                string estado   = "S";

                entPersona personaInsert = new entPersona();

                personaInsert.PER_DOCUMENTO  = Convert.ToInt32(documento);
                personaInsert.PER_NOMBRE     = nombre;
                personaInsert.PER_APELLIDO   = apellidos;
                personaInsert.PER_GENERO     = genero;
                personaInsert.PER_FECHA_NAC  = nacimiento;
                personaInsert.PER_TELEFONO   = telefono;
                personaInsert.PER_TELEFONO_2 = celular;
                personaInsert.PER_EMAIL      = email;
                personaInsert.PER_TPE_ID     = "1";
                personaInsert.PER_ESTADO     = estado;

                logPersonas metPersona = new logPersonas();
                resultado = metPersona.Insertar(personaInsert);

                if (resultado == "OK")
                {
                    personaInsert = metPersona.BuscaPersona(nombre, apellidos, documento);
                    Int32 id_persona = personaInsert.PER_ID;

                    entDomicilio domicilioInsertar = new entDomicilio();

                    domicilioInsertar.DOM_PER_ID = id_persona;
                    domicilioInsertar.DOM_CALLE  = calle;
                    domicilioInsertar.DOM_NUMERO = Convert.ToInt32(numero);
                    if (string.IsNullOrWhiteSpace(piso.Trim()) == true)
                    {
                    }
                    else
                    {
                        domicilioInsertar.DOM_PISO = Convert.ToInt32(piso);
                    }

                    domicilioInsertar.DOM_DPTO   = dpto;
                    domicilioInsertar.DOM_BARRIO = barrio;
                    domicilioInsertar.DOM_CP     = Convert.ToInt32(cpostal);

                    logDomicilio logDomicilio = new logDomicilio();
                    resultado = logDomicilio.Insertar(domicilioInsertar);

                    if (resultado == "OK")
                    {
                        string CARGO;

                        if (Cbocargo.SelectedItem == null)
                        {
                            CARGO = "";
                        }
                        else
                        {
                            CARGO = Cbocargo.SelectedItem.ToString();
                            if (CARGO == "TITULAR")
                            {
                                CARGO = "TITULAR";
                            }
                            else
                            {
                                CARGO = "SUPLENTE";
                            }
                        }


                        string turno;


                        if (cbTurno.SelectedItem == null)
                        {
                            turno = "";
                        }
                        else
                        {
                            turno = cbTurno.SelectedItem.ToString();

                            if (turno == "MAÑANA")
                            {
                                turno = "MANANA";
                            }
                            else
                            {
                                turno = "TARDE";
                            }
                        }

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

                        if (turno == "" && id_sala == "")
                        {
                            MessageBox.Show("Se ha ingresado el registro con éxito.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                        }
                        else   //cambiar!!!
                        {
                            if (logSalas.ValidarDocSala(id_sala, turno) == 0)
                            {
                                entGrupoSala grupoSalaInsertar = new entGrupoSala();
                                grupoSalaInsertar.GRS_PER_ID = Convert.ToInt32(id_persona);
                                grupoSalaInsertar.GRS_SAL_ID = Convert.ToInt32(id_sala);
                                grupoSalaInsertar.GRS_CARGO  = CARGO.ToString();
                                resultado = logSalas.insertarGrupoSala(grupoSalaInsertar);

                                if (resultado == "OK")
                                {
                                    MessageBox.Show("Se ha ingresado el registro con éxito.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                    this.Close();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Ya existe un docente en la sala y turno seleccionados");

                                objlogPersonas.EliminarDocenteDomicilio(personaInsert);
                                objlogPersonas.EliminarDocentePersona(personaInsert);

                                MessageBox.Show("NO Se ha ingresado el registro.");
                            }
                        }
                    }
                }
            }

            else
            {
                MessageBox.Show("No olvide ingresar " + validacion + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#9
0
        private void btnEditar_Click(object sender, EventArgs e)
        {
            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 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();

                string id_salaE;

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

                entPersona personaEditar = new entPersona();

                string genero;

                if (cbGenero.SelectedItem == null)
                {
                    genero = "";
                }
                else
                {
                    genero = cbGenero.SelectedItem.ToString();
                }


                personaEditar.PER_ID         = Convert.ToInt32(idPersonaSelect);
                personaEditar.PER_NOMBRE     = nombreE;
                personaEditar.PER_APELLIDO   = apellidosE;
                personaEditar.PER_DOCUMENTO  = Convert.ToInt32(documentoE);
                personaEditar.PER_GENERO     = genero;//cbGenero.SelectedValue.ToString(); //revisar
                personaEditar.PER_FECHA_NAC  = nacimientoE;
                personaEditar.PER_TELEFONO   = telefonoE;
                personaEditar.PER_TELEFONO_2 = celularE;
                personaEditar.PER_EMAIL      = emailE;

                string resultadoE = metPers.editarPersona(personaEditar);

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

                domicilioEditar.DOM_PER_ID = Convert.ToInt32(idPersonaSelect);
                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 = metDomic.editarDomicilio(domicilioEditar);

                //-------- EDITA SALA

                entGrupoSala grupoSalaEditar = new entGrupoSala();

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

                resultadoE = metSala.editarGrupoSala(grupoSalaEditar);

                if (resultadoE == "OK")
                {
                    MessageBox.Show("Se han editado los datos con éxito.", "Ingresado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("No olvide ingresar " + validacionE + ".", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }