public ActionResult Index() { #region Validar Session if (string.IsNullOrEmpty(SessionFixed.IdTransaccionSession)) { return(RedirectToAction("Login", new { Area = "", Controller = "Account" })); } SessionFixed.IdTransaccionSession = (Convert.ToDecimal(SessionFixed.IdTransaccionSession) + 1).ToString(); SessionFixed.IdTransaccionSessionActual = SessionFixed.IdTransaccionSession; #endregion #region Permisos seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "Contabilidad", "PlanDeCuentas", "Index"); ViewBag.Nuevo = info.Nuevo; ViewBag.Modificar = info.Modificar; ViewBag.Anular = info.Anular; #endregion ct_plancta_Info model = new ct_plancta_Info { IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSession), IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa), }; var lst = bus_plancta.get_list(model.IdEmpresa, true, false); ListaPlancta.set_list(lst, model.IdTransaccionSession); return(View(model)); }
public static void FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e) { #region Variables ct_anio_fiscal_List ListaAnioFiscal = new ct_anio_fiscal_List(); ct_plancta_List ListaPlancta = new ct_plancta_List(); List <ct_plancta_Info> ListaPlan = new List <ct_plancta_Info>(); List <ct_anio_fiscal_Info> ListaAnio = new List <ct_anio_fiscal_Info>(); int cont = 0; decimal IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual); int IdEmpresa = Convert.ToInt32(SessionFixed.IdEmpresa); #endregion Stream stream = new MemoryStream(e.UploadedFile.FileBytes); if (stream.Length > 0) { IExcelDataReader reader = null; reader = ExcelReaderFactory.CreateOpenXmlReader(stream); #region Plan de cuentas while (reader.Read()) { if (!reader.IsDBNull(0) && cont > 0) { //var IdCtaCble = Convert.ToString(reader.GetValue(0)); //var pc_clave_corta = reader.GetValue(1) == null || string.IsNullOrEmpty(reader.GetString(1)) ? "" : reader.GetString(1); //var pc_Cuenta = reader.GetString(2); //var IdCtaCIdCtaCblePadreble = reader.GetValue(3) == null || string.IsNullOrEmpty(Convert.ToString(reader.GetValue(3))) ? null : Convert.ToString(reader.GetValue(3)); //var pc_Naturaleza = Convert.ToString(reader.GetValue(4)); //var IdNivelCta = Convert.ToInt32(reader.GetValue(5)); //var pc_EsMovimiento_bool = Convert.ToString(reader.GetValue(6)) == "SI" ? true : false; //var pc_EsMovimiento = Convert.ToString(reader.GetValue(6)) == "SI" ? "S" : "N"; //var IdGrupoCble = Convert.ToString(reader.GetValue(7)); ct_plancta_Info info = new ct_plancta_Info { IdEmpresa = IdEmpresa, IdCtaCble = Convert.ToString(reader.GetValue(0)), pc_clave_corta = reader.GetValue(1) == null || string.IsNullOrEmpty(reader.GetString(1)) ? "" : reader.GetString(1), pc_Cuenta = reader.GetString(2), IdCtaCblePadre = reader.GetValue(3) == null || string.IsNullOrEmpty(Convert.ToString(reader.GetValue(3))) ? null : Convert.ToString(reader.GetValue(3)), pc_Naturaleza = Convert.ToString(reader.GetValue(4)), IdNivelCta = Convert.ToInt32(reader.GetValue(5)), pc_EsMovimiento_bool = Convert.ToString(reader.GetValue(6)) == "SI" ? true : false, pc_EsMovimiento = Convert.ToString(reader.GetValue(6)) == "SI" ? "S" : "N", IdGrupoCble = Convert.ToString(reader.GetValue(7)) }; ListaPlan.Add(info); } else { cont++; } } #endregion cont = 0; //Para avanzar a la siguiente hoja de excel reader.NextResult(); #region Cuentas contables por anio while (reader.Read()) { if (!reader.IsDBNull(0) && cont > 0) { int Anio = Convert.ToInt32(reader.GetValue(0)); string IdCtaCble = reader.GetValue(1).ToString(); ct_anio_fiscal_Info info = new ct_anio_fiscal_Info { IdanioFiscal = Anio, af_fechaIni = new DateTime(Anio, 1, 1), af_fechaFin = new DateTime(Anio, 12, 31), info_anio_ctautil = new ct_anio_fiscal_x_cuenta_utilidad_Info { IdEmpresa = IdEmpresa, IdCtaCble = IdCtaCble, IdanioFiscal = Anio, }, }; ListaAnio.Add(info); } else { cont++; } } #endregion ListaPlancta.set_list(ListaPlan, IdTransaccionSession); ListaAnioFiscal.set_list(ListaAnio, IdTransaccionSession); } }