public ActionResult Nuevo(int IdEmpresa = 0)
        {
            #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, "CuentasPorCobrar", "SeguimientoCartera", "Index");
            if (!info.Nuevo)
            {
                return(RedirectToAction("Index"));
            }
            #endregion
            cxc_SeguimientoCartera_Info model = new cxc_SeguimientoCartera_Info
            {
                IdEmpresa            = IdEmpresa,
                Fecha                = DateTime.Now.Date,
                lst_det              = new List <cxc_SeguimientoCartera_Info>(),
                seguimiento_foto     = new byte[0],
                IdTransaccionSession = Convert.ToDecimal(SessionFixed.IdTransaccionSessionActual)
            };

            Lista_Seguimiento_x_Alumno.set_list(model.lst_det, model.IdTransaccionSession);
            return(View(model));
        }
        public ActionResult Nuevo(cxc_SeguimientoCartera_Info model)
        {
            model.IdUsuarioCreacion = SessionFixed.IdUsuario.ToString();
            var ListaDetalle = Lista_Seguimiento_x_Alumno.get_list(model.IdTransaccionSession);

            model.lst_det = ListaDetalle.ToList();

            if (model.seguimiento_foto == null)
            {
                model.seguimiento_foto = new byte[0];
            }

            if (!validar(model, ref mensaje))
            {
                SessionFixed.IdTransaccionSessionActual = model.IdTransaccionSession.ToString();
                Lista_Seguimiento_x_Alumno.set_list(Lista_Seguimiento_x_Alumno.get_list(model.IdTransaccionSession), model.IdTransaccionSession);
                ViewBag.mensaje = mensaje;
                return(View(model));
            }

            if (!bus_seguimiento.guardarDB(model))
            {
                SessionFixed.IdTransaccionSessionActual = model.IdTransaccionSession.ToString();
                Lista_Seguimiento_x_Alumno.set_list(Lista_Seguimiento_x_Alumno.get_list(model.IdTransaccionSession), model.IdTransaccionSession);
                ViewBag.mensaje = "No se ha podido guardar el registro";

                return(View(model));
            }
            ;

            return(RedirectToAction("Consultar", new { IdEmpresa = model.IdEmpresa, IdSeguimiento = model.IdSeguimiento, Exito = true }));
        }
        public bool enviarcorreoDB(cxc_SeguimientoCartera_Info info)
        {
            try
            {
                using (Entities_cuentas_por_cobrar Context = new Entities_cuentas_por_cobrar())
                {
                    cxc_SeguimientoCartera Entity = Context.cxc_SeguimientoCartera.FirstOrDefault(q => q.IdEmpresa == info.IdEmpresa && q.IdSeguimiento == info.IdSeguimiento);
                    if (Entity == null)
                    {
                        return(false);
                    }

                    Entity.CorreoEnviado         = info.CorreoEnviado = true;
                    Entity.IdUsuarioModificacion = info.IdUsuarioModificacion;
                    Entity.FechaModificacion     = info.FechaModificacion = DateTime.Now;

                    Context.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool guardarDB(cxc_SeguimientoCartera_Info info)
        {
            try
            {
                using (Entities_cuentas_por_cobrar Context = new Entities_cuentas_por_cobrar())
                {
                    cxc_SeguimientoCartera Entity = new cxc_SeguimientoCartera
                    {
                        IdEmpresa         = info.IdEmpresa,
                        IdSeguimiento     = info.IdSeguimiento = getId(info.IdEmpresa),
                        IdCliente         = info.IdCliente,
                        CorreoEnviado     = false,
                        Fecha             = info.Fecha,
                        Observacion       = info.Observacion,
                        Estado            = true,
                        IdUsuarioCreacion = info.IdUsuarioCreacion,
                        FechaCreacion     = info.FechaCreacion = DateTime.Now
                    };
                    Context.cxc_SeguimientoCartera.Add(Entity);

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 public cxc_SeguimientoCartera_Info get_info(int IdEmpresa, int IdSeguimiento)
 {
     try
     {
         cxc_SeguimientoCartera_Info info = new cxc_SeguimientoCartera_Info();
         using (Entities_cuentas_por_cobrar Context = new Entities_cuentas_por_cobrar())
         {
             cxc_SeguimientoCartera Entity = Context.cxc_SeguimientoCartera.FirstOrDefault(q => q.IdEmpresa == IdEmpresa && q.IdSeguimiento == IdSeguimiento);
             if (Entity == null)
             {
                 return(null);
             }
             info = new cxc_SeguimientoCartera_Info
             {
                 IdEmpresa     = Entity.IdEmpresa,
                 IdSeguimiento = Entity.IdSeguimiento,
                 Estado        = Entity.Estado,
                 IdCliente     = Entity.IdCliente,
                 Fecha         = Entity.Fecha,
                 Observacion   = Entity.Observacion
             };
         }
         return(info);
     }
     catch (Exception)
     {
         throw;
     }
 }
        private bool validar(cxc_SeguimientoCartera_Info info, ref string msg)
        {
            if (info.IdCliente == 0)
            {
                msg = "Debe seleccionar al estudiante";
                return(false);
            }

            return(true);
        }
Example #7
0
 public bool EnviarCorreoDB(cxc_SeguimientoCartera_Info info)
 {
     try
     {
         return(odata.enviarcorreoDB(info));
     }
     catch (Exception)
     {
         throw;
     }
 }
Example #8
0
 public bool anularDB(cxc_SeguimientoCartera_Info info)
 {
     try
     {
         return(odata.anularDB(info));
     }
     catch (Exception)
     {
         throw;
     }
 }
        public ActionResult Anular(int IdEmpresa = 0, int IdSeguimiento = 0)
        {
            #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
            cxc_SeguimientoCartera_Info model = bus_seguimiento.get_info(IdEmpresa, IdSeguimiento);
            if (model == null)
            {
                return(RedirectToAction("Index"));
            }

            var infoCliente = bus_cliente.get_info(model.IdEmpresa, model.IdCliente);
            var lst_Saldos  = bus_cobros.get_Saldo(model.IdEmpresa, model.IdCliente);
            var Saldo       = (lst_Saldos.Count == 0 ? 0 : Convert.ToDouble(lst_Saldos.Sum(q => q.Saldo)));
            model.Saldo     = Saldo.ToString("C2");
            model.Direccion = (infoCliente == null ? "" : infoCliente.Direccion);
            model.Celular   = (infoCliente == null ? "" : infoCliente.Celular);
            model.Telefono  = (infoCliente == null ? "" : infoCliente.Telefono);
            model.Correo    = (infoCliente == null ? "" : infoCliente.Correo);

            if (model.seguimiento_foto == null)
            {
                model.seguimiento_foto = new byte[0];
            }

            try
            {
                model.seguimiento_foto = System.IO.File.ReadAllBytes(Server.MapPath(UploadDirectory) + model.IdEmpresa.ToString("000") + model.IdSeguimiento.ToString("000000") + ".jpg");
                if (model.seguimiento_foto == null)
                {
                    model.seguimiento_foto = new byte[0];
                }
            }
            catch (Exception)
            {
                model.seguimiento_foto = new byte[0];
            }

            #region Permisos
            seg_Menu_x_Empresa_x_Usuario_Info info = bus_permisos.get_list_menu_accion(Convert.ToInt32(SessionFixed.IdEmpresa), SessionFixed.IdUsuario, "CuentasPorCobrar", "SeguimientoCartera", "Index");
            if (!info.Anular)
            {
                return(RedirectToAction("Index"));
            }
            #endregion

            return(View(model));
        }
        public ActionResult Anular(cxc_SeguimientoCartera_Info model)
        {
            model.IdUsuarioAnulacion = SessionFixed.IdUsuario;

            if (model.seguimiento_foto == null)
            {
                model.seguimiento_foto = new byte[0];
            }

            if (!bus_seguimiento.anularDB(model))
            {
                ViewBag.mensaje = "No se ha podido anular el registro";
                SessionFixed.IdTransaccionSessionActual = model.IdTransaccionSession.ToString();
                return(View(model));
            }
            ;

            return(RedirectToAction("Index"));
        }
        public JsonResult GetInfoCliente(int IdEmpresa = 0, decimal IdCliente = 0)
        {
            var info       = bus_cliente.get_info(IdEmpresa, IdCliente);
            var lst_Saldos = bus_cobros.get_Saldo(IdEmpresa, IdCliente);

            info.Saldo = (lst_Saldos.Count == 0 ? 0 : Convert.ToDouble(lst_Saldos.Sum(q => q.Saldo)));
            var Saldo = (lst_Saldos.Count == 0 ? 0 : Convert.ToDouble(lst_Saldos.Sum(q => q.Saldo)));

            var infoSeguimiento = new cxc_SeguimientoCartera_Info
            {
                IdEmpresa = IdEmpresa,
                IdCliente = IdCliente,
                Saldo     = Saldo.ToString("C2"),
                Direccion = (info == null ? "" : info.Direccion),
                Celular   = (info == null ? "" : info.Celular),
                Telefono  = (info == null ? "" : info.Telefono),
                Correo    = (info == null ? "" : info.Correo)
            };

            return(Json(infoSeguimiento, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Cmb_Cliente()
        {
            cxc_SeguimientoCartera_Info model = new cxc_SeguimientoCartera_Info();

            return(PartialView("_CmbCliente", model));
        }