Beispiel #1
0
        public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            int cont = 0;
            ro_rubro_tipo_Bus                 bus_rubro                   = new ro_rubro_tipo_Bus();
            ro_empleado_info_list             empleado_info_list          = new ro_empleado_info_list();
            ro_PrestamoMasivo_Det_List        ListaDetalle_PrestamoMasivo = new ro_PrestamoMasivo_Det_List();
            List <ro_PrestamoMasivo_Det_Info> PrestamoMasivo_Det          = new List <ro_PrestamoMasivo_Det_Info>();
            var    IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession);
            int    Secuencia            = 1;
            Stream stream = new MemoryStream(e.UploadedFile.FileBytes);

            if (stream.Length > 0)
            {
                IExcelDataReader reader = null;
                reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                while (reader.Read())
                {
                    if (!reader.IsDBNull(0))
                    {
                        if (cont != 0)
                        {
                            int    IdEmpresa  = Convert.ToInt32(SessionFixed.IdEmpresa);
                            string cedula     = reader.GetString(0);
                            var    empleado   = empleado_info_list.get_list(IdTransaccionSession).Where(v => v.pe_cedulaRuc == cedula).FirstOrDefault();
                            var    CodRubro   = Convert.ToString(reader.GetValue(2));
                            var    info_rubro = bus_rubro.get_info_x_codigo(IdEmpresa, CodRubro);
                            if (empleado != null)
                            {
                                ro_PrestamoMasivo_Det_Info info = new ro_PrestamoMasivo_Det_Info
                                {
                                    Secuencia         = Secuencia++,
                                    IdEmpleado        = (empleado == null ? 0 : empleado.IdEmpleado),
                                    IdRubro           = (info_rubro == null ? null : info_rubro.IdRubro),
                                    Monto             = Convert.ToDouble(reader.GetValue(3)),
                                    NumCuotas         = Convert.ToInt32(reader.GetValue(4)),
                                    ru_descripcion    = (info_rubro == null ? "" : info_rubro.ru_descripcion),
                                    pe_nombreCompleto = (empleado == null ? "" : empleado.Empleado)
                                };
                                PrestamoMasivo_Det.Add(info);
                            }
                        }
                        cont++;
                    }
                }
                ListaDetalle_PrestamoMasivo.set_list(PrestamoMasivo_Det, IdTransaccionSession);
            }
        }