コード例 #1
0
        protected void btnCargaExcel_Click(object sender, EventArgs e)
        {
            List <ReporteFinanciero> list        = null;
            List <string>            listAlumnos = null;
            OleDbCommand             command     = null;
            OleDbDataReader          reader      = null;
            int cont = 0; //Comenzara a leer despues de la primera fila (nombre de columna)


            try
            {
                list        = new List <ReporteFinanciero>();
                listAlumnos = new List <string>();

                using (OleDbConnection conn = new OleDbConnection(UtilString.obtenerRutaConexion(fileUp)))
                {
                    conn.Open();
                    command = new OleDbCommand("SELECT * FROM [hh$]", conn);
                    reader  = command.ExecuteReader();



                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            cont++;

                            if (cont > 1)
                            {
                                if (reader[6].ToString().Equals("") && reader[15].ToString().Equals("Arancel"))
                                {
                                    //crea el objeto de reporte
                                    ReporteFinanciero rep = new ReporteFinanciero();

                                    //guarda los valores

                                    rep.nroCuota         = UtilNumero.parseInt(reader[1].ToString());
                                    rep.runAlumno        = reader[4].ToString();
                                    rep.fechaVencimiento = DateTime.Parse(reader[13].ToString());
                                    rep.montoCuota       = UtilNumero.parseDouble(reader[17].ToString());
                                    rep.fechaDocumento   = DateTime.Now;

                                    list.Add(rep);
                                    listAlumnos.Add(rep.runAlumno);
                                }
                            }
                        }
                    }
                }

                var alumnos = ((from usu in listAlumnos select usu).Distinct()).ToList();
                ReporteFinancieroBLL.getInstance.loadExcelList(list, alumnos);
                UtilScript.executeJS("msgSuccessExcel('" + cont.ToString("N0") + " registros cargados');", this.Page, 500);
            }
            catch (Exception ex)
            {
                UtilScript.executeJS("msgRespuesta('" + ex.Message + "','error');", this.Page, 500);
            }
        }
コード例 #2
0
        public static List <ReporteFinanciero> getReporteByRut(string run)
        {
            OracleConnection         con     = null;
            OracleCommand            command = null;
            OracleDataAdapter        adapter = null;
            DataSet                  ds      = null;
            List <ReporteFinanciero> list    = null;

            try
            {
                con = new OracleConnection(Constantes.DATA_SOURCE);
                con.Open();

                command             = new OracleCommand("PKG_REPORTE.SP_REPORTE_ALUMNO", con);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                command.Parameters.Add(":p_run", run);
                command.Parameters.Add(":p_list", OracleDbType.RefCursor).Direction = System.Data.ParameterDirection.Output;
                command.ExecuteNonQuery();

                adapter = new OracleDataAdapter(command);
                ds      = new DataSet();
                adapter.Fill(ds);

                list = new List <ReporteFinanciero>();

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    ReporteFinanciero reporte = new ReporteFinanciero();
                    reporte.nroCuota      = UtilNumero.parseInt(row["nro_cuota"].ToString());
                    reporte.montoCuota    = UtilNumero.parseInt(row["monto_cuota"].ToString());
                    reporte.glosaCuota    = row["glosa_cuota"].ToString();
                    reporte.montoInteres  = UtilNumero.parseInt(row["interes"].ToString());
                    reporte.gastoCobranza = UtilNumero.parseInt(row["gasto_cobranza"].ToString());
                    reporte.totalCuota    = UtilNumero.parseInt(row["total_cuota"].ToString());

                    list.Add(reporte);
                }
            }
            catch (Exception)
            {
                throw new DataAccessException("Error desconocido, contacte al administrador");
            }
            finally
            {
                con.Close();
            }

            return(list);
        }