Ejemplo n.º 1
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            int      sala        = Convert.ToInt32(cbSala.SelectedValue.ToString());
            logCuota objLogCuota = new logCuota();
            decimal  monto_cuota = objLogCuota.Monto_Cuota(sala);
            int      id_alumno;



            for (int i = 0; i < dgvAlumnos.Rows.Count; i++)
            {
                id_alumno = Convert.ToInt32(dgvAlumnos.Rows[i].Cells[0].Value);
                int cuo_id     = Convert.ToInt32(objLogCuota.GeneraraCuota(monto_cuota, id_alumno));
                int idConcepto = objLogCuota.ExtraerId_concepto_Cuotas(sala);
                objLogCuota.InsertarCuotaDetalle(cuo_id, idConcepto, monto_cuota);

                DataTable alu = new DataTable();
                alu = objLogCuota.traerAlumnosSala(sala);
                dgvAlumnos.DataSource = alu;
            }
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        private void btnGenerar_Click(object sender, EventArgs e)
        {
            //FOR inserta una cuota_final por cada persona
            //      FOR por cada cuota_final inserta un detalle por cada concepto seleccionado
            //      UPDATE la cuota con el monto suma de los detalles agregados.
            if (via == 0)
            {
                if (conceptos.Rows.Count > 0)
                {
                    foreach (DataRow persona in colPersona.Rows)
                    {
                        DataRow dr2           = persona;
                        int     montoTotalM   = 0;
                        string  legajoM       = Convert.ToString(dr2.ItemArray[6]);
                        int     periodoCuotaM = Convert.ToInt32(cbPeriodo.SelectedItem.ToString());
                        int     anoCuotaM     = Convert.ToInt32(cbAnoEjercicio.SelectedItem.ToString());;
                        string  estadoCuotaM  = "ADEUDADA";

                        logCuota objMetCuota = new logCuota();

                        int cuentaValida = objMetCuota.CuentaCuotasValidacion(legajoM, periodoCuotaM, anoCuotaM);

                        if (cuentaValida == 0)
                        {
                            string resultado = objMetCuota.insertaCuotaFinal(legajoM, periodoCuotaM, anoCuotaM, estadoCuotaM);

                            if (resultado == "OK")
                            {
                                ListView.SelectedListViewItemCollection conceptosSelected = listConceptos.SelectedItems;
                                foreach (ListViewItem item in conceptosSelected)
                                {
                                    string  index = item.Text;
                                    int     idConcepto;
                                    int     importeConcepto;
                                    DataRow drConcepto; //= conceptos.Rows[Convert.ToInt32(index)];
                                    foreach (DataRow dr in conceptos.Rows)
                                    {
                                        if (dr["ID"].ToString() == index)
                                        {
                                            drConcepto = dr;

                                            idConcepto      = Convert.ToInt32(drConcepto.ItemArray[0]);
                                            importeConcepto = Convert.ToInt32(drConcepto.ItemArray[2]);

                                            string resultado2 = objMetCuota.InsertarCuotaDetalle(legajoM, periodoCuotaM, anoCuotaM, idConcepto, importeConcepto);

                                            montoTotalM += importeConcepto;

                                            string resultado3 = objMetCuota.ActualizaMontoCuotaFinal(legajoM, periodoCuotaM, anoCuotaM, montoTotalM);
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("El matriculado " + legajoM + " ya tiene cuotas generadas para ese periodo.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    MessageBox.Show("Se han generado las cuotas exitosamente.", "Cuotas generadas", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Debe seleccionar al menos un Concepto.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else if (via == 1)
            {
                //nombreB.ToString();
                //apellidoB.ToString();
                //documentoB.ToString();
                //legajo.ToString();

                if (conceptos.Rows.Count > 0)
                {
                    int montoTotal = 0;
                    int periodoCuota;

                    if (cbPeriodo.SelectedItem.ToString() == "MATRICULA")
                    {
                        periodoCuota = 00;
                    }
                    else if (cbPeriodo.SelectedItem.ToString() == "ESPECIAL")
                    {
                        periodoCuota = 99;
                    }
                    else
                    {
                        periodoCuota = Convert.ToInt32(cbPeriodo.SelectedItem.ToString());
                    }
                    int    anoCuota    = Convert.ToInt32(cbAnoEjercicio.SelectedItem.ToString());;
                    string estadoCuota = "ADEUDADA";

                    logCuota objMetCuota = new logCuota();

                    int cuentaValida = objMetCuota.CuentaCuotasValidacion(legajo, periodoCuota, anoCuota);

                    if (cuentaValida == 0)
                    {
                        string resultado = objMetCuota.insertaCuotaFinal(legajo, periodoCuota, anoCuota, estadoCuota);

                        if (resultado == "OK")
                        {
                            ListView.SelectedListViewItemCollection conceptosSelected = listConceptos.SelectedItems;
                            foreach (ListViewItem item in conceptosSelected)
                            {
                                string  index = item.Text;
                                int     idConcepto;
                                int     importeConcepto;
                                DataRow drConcepto; //= conceptos.Rows[Convert.ToInt32(index)];
                                foreach (DataRow dr in conceptos.Rows)
                                {
                                    if (dr["ID"].ToString() == index)
                                    {
                                        drConcepto = dr;

                                        idConcepto      = Convert.ToInt32(drConcepto.ItemArray[0]);
                                        importeConcepto = Convert.ToInt32(drConcepto.ItemArray[2]);

                                        string resultado2 = objMetCuota.InsertarCuotaDetalle(legajo, periodoCuota, anoCuota, idConcepto, importeConcepto);

                                        montoTotal += importeConcepto;

                                        string resultado3 = objMetCuota.ActualizaMontoCuotaFinal(legajo, periodoCuota, anoCuota, montoTotal);
                                    }
                                }
                            }
                        }

                        txtMatriculados_ButtonClick(sender, e);
                        MessageBox.Show("Se ha generado la cuota exitosamente.", "Cuotas generadas", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("El matriculado " + legajo + " ya tiene cuotas generadas para ese periodo.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Debe seleccionar al menos un Concepto.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }