示例#1
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);
            }
        }
示例#2
0
        private void dtNacimiento_Leave(object sender, EventArgs e)
        {
            string   salas;
            string   turno;
            DateTime fecha_nacimineto = dtNacimiento.Value;
            string   color;


            if (cbSala.SelectedValue == null)
            {
                lblSala.Visible = true;
                lblSala.Text    = "Por favor, seleccione una sala";
            }
            else
            {
                salas = cbSala.SelectedValue.ToString();
                turno = cbTurno.SelectedItem.ToString();

                color = cbSala.SelectedIndex.ToString();

                if (color == "0")
                {
                    lblSala.Visible   = true;
                    lblSala.Font      = new Font(lblSala.Font.Name, 12);
                    lblSala.ForeColor = Color.Gainsboro;
                    lblSala.Text      = " 1 a 2 años ";
                }
                else if (color == "1")
                {
                    lblSala.Visible   = true;
                    lblSala.Font      = new Font(lblSala.Font.Name, 12);
                    lblSala.ForeColor = Color.Gainsboro;
                    lblSala.Text      = " 3 a 4 años ";
                }

                else if (color == "2")

                {
                    lblSala.Visible   = true;
                    lblSala.Text      = " 4 a 5 años ";
                    lblSala.Font      = new Font(lblSala.Font.Name, 12);
                    lblSala.ForeColor = Color.Gainsboro;
                    lblSala.ForeColor = Color.Gainsboro;
                }
                else
                {
                    lblSala.Visible = false;
                }

                logPersonas objlogpersonas = new logPersonas();
                string      resultado      = objlogpersonas.Validar_Salas(fecha_nacimineto, salas, turno);


                if (resultado != "OK")

                {
                    MessageBox.Show(resultado);
                    cbSala.SelectedIndex = -1;
                    cbSala.Style         = MetroFramework.MetroColorStyle.Red;
                    cbSala.Focus();
                    lblSala.Text      = "Por favor, seleccione una sala";
                    lblSala.ForeColor = Color.Red;
                }
            }
        }
示例#3
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);
            }
        }