// GET: Recibos public ActionResult Start() { if ((sesion = SessionDB.start(Request, Response, false, db)) == null) { return(Content("-1")); } DepositoModel model = new DepositoModel(); model.sesion = sesion; model.clean(); Main view = new Main(); ViewBag.MainUser = view.CreateMenuInfoUser(sesion); ViewBag.Main = view.createMenu("Pagos", "Gestión de Pagos", sesion); ViewBag.sedes = view.createSelectSedes("Sedes", sesion); ViewBag.DataTable = CreateDataTable(10, 1, null, "ID_DEPOSITO", "ASC", sesion); //Intercom ViewBag.User = sesion.nickName.ToString(); ViewBag.Email = sesion.nickName.ToString(); ViewBag.FechaReg = DateTime.Today; ViewBag.Scripts = Scripts.addScript() + Scripts.setPrivileges(Privileges, sesion); if (!sesion.permisos.havePermission(Privileges[0].Permiso)) { return(View(Factory.View.NotAccess)); } Log.write(this, "Gestión de Pagos Start", LOG.CONSULTA, "Ingresa Pantalla Deposito", sesion); return(View(Factory.View.Access + "Pagos/GestiondePagos/Deposito/Start.cshtml")); }
public bool ValidarExcel(string fileName, SessionDB sesion, out List <DepositoModel> listModels, string sedes) { listModels = new List <DepositoModel>(); DepositoModel auxModel = new DepositoModel(); auxModel.sesion = sesion; auxModel.cargaListas(sedes); // Cargar el excel en los modelos. try { Debug.WriteLine(fileName + " exists: " + (System.IO.File.Exists(fileName) ? "Yes" : "No")); using (ExcelPackage xlPackage = new ExcelPackage(new FileInfo(fileName))) { // 1.- Get the first worksheet in the workbook ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1]; Dictionary <string, int> col = new Dictionary <string, int>(); int start = worksheet.Dimension.Start.Column; int end = worksheet.Dimension.End.Column; int y = worksheet.Dimension.Start.Row; int y2 = y + 1; for (int x = start; x <= end; x++) { string head = RemoveDiacritics( (worksheet.Cells[y, x].Text.Replace("/", "").Trim() + " " + worksheet.Cells[y2, x].Text.Replace("/", "").Trim()).Trim() ).Replace(" ", "_").ToUpper(); if (col.Keys.Contains(head) == false) { col.Add(head, x); } } start = 2 + worksheet.Dimension.Start.Row; // se le suma 2 por las cabeceras end = worksheet.Dimension.End.Row; int errores = 0; for (int row = start; row <= end; row++) { try { // ------------------- Parche para excluir las lineas vacias ------------------- bool emptyLine = true; for (int i = 1; i <= 15; i++) { if (string.IsNullOrWhiteSpace(worksheet.Cells[row, i].Text) == false) { emptyLine = false; break; } } if (emptyLine) { continue; } // ----------------------------------------------------------------------------- DepositoModel model = new DepositoModel(); model.ReadWorkSheetRow(worksheet, row, col); model.sesion = sesion; model.CopiaListasDesde(auxModel); listModels.Add(model); } catch (Exception) { errores++; } } } // the using statement calls Dispose() which closes the package. sesion.vdata.Remove("DepositosExcelError"); sesion.saveSession(); auxModel.clean(); return(true); } catch (Exception) { return(false); } }