コード例 #1
0
ファイル: AdminController.cs プロジェクト: EvertNube/nbLibros
        public ActionResult AddLibro(CuentaBancariaDTO dto)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            if (getCurrentUser().IdRol == 4) { return RedirectToAction("Libros", "Admin"); }
            try
            {
                string sTipoLibro = dto.IdTipoCuenta == 1 ? "Bancarios" : "Administrativos";
                int TipoCuenta = 1; //Por defecto tipo de comprobante Ingreso
                if (dto != null) { TipoCuenta = dto.IdTipoCuenta.GetValueOrDefault(); }

                CuentaBancariaBL objBL = new CuentaBancariaBL();
                if (dto.IdCuentaBancaria == 0)
                {
                    if (objBL.add(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Libros" + sTipoLibro, "Admin");
                    }
                }
                else if (dto.IdCuentaBancaria != 0)
                {
                    if (objBL.update(dto))
                    {
                        createResponseMessage(CONSTANTES.SUCCESS);
                        return RedirectToAction("Libros" + sTipoLibro, "Admin");
                    }
                    else
                    {
                        createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                    }

                }
                else
                {
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
                }
            }
            catch (Exception e)
            {
                if (dto.IdCuentaBancaria != 0)
                    createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_UPDATE_MESSAGE);
                else createResponseMessage(CONSTANTES.ERROR, CONSTANTES.ERROR_INSERT_MESSAGE);
            }
            TempData["Libro"] = dto;
            return RedirectToAction("Libro");
        }
コード例 #2
0
        public bool update(CuentaBancariaDTO CuentaBancaria)
        {
            using (var context = getContext())
            {
                try
                {
                    //var miSaldoDisponible = context.SP_GetTotalIngresos(CuentaBancaria.IdCuentaBancaria).AsQueryable().First() as Decimal?;
                    var datoRow = context.CuentaBancaria.Where(x => x.IdCuentaBancaria == CuentaBancaria.IdCuentaBancaria).SingleOrDefault();
                    datoRow.NombreCuenta = CuentaBancaria.NombreCuenta;
                    datoRow.FechaConciliacion = CuentaBancaria.FechaConciliacion;
                    //datoRow.FechaConciliacion = Convert.ToDateTime(CuentaBancaria.FechaConciliacion.ToString("yyyy-MM-dd hh:mm:ss tt"));
                    datoRow.SaldoDisponible = CuentaBancaria.SaldoDisponible;
                    datoRow.SaldoBancario = CuentaBancaria.SaldoBancario;
                    datoRow.Estado = CuentaBancaria.Estado;
                    datoRow.IdMoneda = CuentaBancaria.IdMoneda;
                    datoRow.IdEmpresa = CuentaBancaria.IdEmpresa;
                    datoRow.IdTipoCuenta = CuentaBancaria.IdTipoCuenta;
                    context.SaveChanges();
                    //Solo hacer la conciliacion de Libros BANCARIOS
                    if ((int)datoRow.IdTipoCuenta == 1)
                    { ActualizarFechaConciliacionEnEmpresa(datoRow.IdCuentaBancaria); }

                    return true;
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: EvertNube/nbLibros
        //public ActionResult Libro(int? id = null, int? idTipoCuenta = null, string sortOrder = null, string currentFilter = null, string searchString = null, int? page = null)
        public ActionResult Libro(int? id = null, int? idTipoCuenta = null)
        {
            if (!this.currentUser()) { return RedirectToAction("Ingresar"); }
            ViewBag.Title = "Libro";

            int tipoCuenta = 2;
            if (idTipoCuenta != null) { tipoCuenta = idTipoCuenta.GetValueOrDefault(); }
            MenuNavBarSelected(2, tipoCuenta - 1);

            UsuarioDTO miUsuario = getCurrentUser();

            CuentaBancariaBL objBL = new CuentaBancariaBL();
            ViewBag.IdCuentaBancaria = id;
            ViewBag.Monedas = objBL.getMonedasBag(false);
            var objSent = TempData["Libro"];
            if (objSent != null) { TempData["Libro"] = null; return View(objSent); }

            CuentaBancariaDTO obj;
            if (id != null && id != 0)
            {
                //Actualizar Saldo Disponible
                objBL.updateSaldos((int)id);
                obj = objBL.getCuentaBancariaEnEmpresa(miUsuario.IdEmpresa, (int)id);
                if (obj == null) return RedirectToAction("Index");
                if (obj.IdEmpresa != miUsuario.IdEmpresa) return RedirectToAction("Index");

                //obj.listaMovimientoPL = BusquedaYPaginado_Movimiento(obj.listaMovimiento, sortOrder, currentFilter, searchString, page);
                return View(obj);
            }

            obj = new CuentaBancariaDTO();
            obj.FechaConciliacion = DateTime.Now;
            obj.IdEmpresa = miUsuario.IdEmpresa;
            if (idTipoCuenta != null && idTipoCuenta != 0) obj.IdTipoCuenta = idTipoCuenta.GetValueOrDefault();

            return View(obj);
        }
コード例 #4
0
        public bool add(CuentaBancariaDTO CuentaBancaria)
        {
            using (var context = getContext())
            {
                try
                {
                    CuentaBancaria nuevo = new CuentaBancaria();
                    nuevo.NombreCuenta = CuentaBancaria.NombreCuenta;
                    nuevo.FechaConciliacion = CuentaBancaria.FechaConciliacion;
                    //nuevo.FechaConciliacion = Convert.ToDateTime(CuentaBancaria.FechaConciliacion.ToString("yyyy-MM-dd hh:mm:ss tt"));
                    nuevo.SaldoDisponible = CuentaBancaria.SaldoDisponible;
                    nuevo.SaldoBancario = CuentaBancaria.SaldoBancario;
                    nuevo.Estado = true;
                    nuevo.IdMoneda = CuentaBancaria.IdMoneda;
                    nuevo.IdEmpresa = CuentaBancaria.IdEmpresa;
                    nuevo.IdTipoCuenta = CuentaBancaria.IdTipoCuenta;
                    context.CuentaBancaria.Add(nuevo);
                    context.SaveChanges();
                    //Solo hacer la conciliacion de Libros BANCARIOS
                    if ((int)nuevo.IdTipoCuenta == 1)
                    { ActualizarFechaConciliacionEnEmpresa(nuevo.IdCuentaBancaria); }

                    return true;
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
        }