public ActionResult Create(string button, [Bind(Include = "CreditoId,Fecha,ClienteId,Valor,Interes,Meses,TipoCuotaId,PrimCuota,DivisionCreditoId,InteresPrimCuota,CapitalFinalCredito,Observacion,Estado,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion,EmpresaId,UsuarioId")] credito credito) { if (button.Equals("Cancelar")) { return(RedirectToAction("Index")); } if (ModelState.IsValid) { credito.CalcularCuotas(); if (button.Equals("Crear Credito")) { int empresaId = 0; if (Session["EmpresaId"] != null) { Int32.TryParse(Session["EmpresaId"].ToString(), out empresaId); } consecutivo c = db.consecutivo.Find(empresaId); c.CreditoNro = c.CreditoNro + 1; credito.CreditoNro = c.CreditoNro; db.credito.Add(credito); db.SaveChanges(); return(RedirectToAction("Index")); } } ViewBag.ClienteId = new SelectList(db.cliente.Where(c => c.Estado == true && c.EmpresaId == credito.EmpresaId).OrderBy(e => e.Nit), "ClienteId", "Nombre", credito.ClienteId); ViewBag.TipoCuotaId = new SelectList(db.tipocuota.Where(c => c.Estado == true).OrderBy(e => e.Nombre), "TipoCuotaId", "Nombre", credito.TipoCuotaId); ViewBag.DivisionCreditoId = new SelectList(db.divisioncredito.Where(c => c.Estado == true).OrderBy(e => e.Nombre), "DivisionCreditoId", "Nombre", credito.DivisionCreditoId); ViewBag.UsuarioId = new SelectList(db.usuario.Where(c => c.Estado == true && c.EmpresaId == credito.EmpresaId).OrderBy(e => e.UsuNombre), "UsuarioId", "UsuNombre"); return(View(credito)); }
public ActionResult Create(abonocapital abonocapital, string empresaId, string creditoId) { ModelState.Clear(); abonocapital.CreditoId = Convert.ToInt32(MiUtil.desEncriptar(HttpUtility.UrlDecode(creditoId))); TryValidateModel(abonocapital); if (ModelState.IsValid) { string ok = ""; consecutivo consec = db.consecutivo.Find(Convert.ToInt32(MiUtil.desEncriptar(HttpUtility.UrlDecode(empresaId)))); consec.AbonoCapitalNro = consec.AbonoCapitalNro + 1; abonocapital.AbonoCapitalNro = consec.AbonoCapitalNro; credito cre = db.credito.Find(Convert.ToInt32(MiUtil.desEncriptar(HttpUtility.UrlDecode(creditoId)))); List <cuota> cuotas = db.cuota.Where(c => c.CreditoId == abonocapital.CreditoId).ToList(); backup_cuota(abonocapital, cuotas); ok = cre.abonoACapital(abonocapital.Fecha, abonocapital.Valor); if (ok == "") { db.abonocapital.Add(abonocapital); db.SaveChanges(); return(RedirectToAction("Index", new { creditoId = creditoId })); } else { ModelState.AddModelError("", ok); } } ViewBag.empresaId = empresaId; ViewBag.creditoId = creditoId; //ViewBag.CreditoId = new SelectList(db.credito.Where(c=>c.Estado==true).OrderBy(e=>e.TipoCuotaId), "CreditoId", "TipoCuotaId", abonocapital.CreditoId); return(View(abonocapital)); }
public ActionResult Create([Bind(Include = "EmpresaId,Nit,Nombre,Direccion,Telefono,Estado,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion,LogoUrl,EmpEmail")] empresa empresa, HttpPostedFileBase LogoUrl, string controlador) { if (ModelState.IsValid) { if (this.validarImagen(LogoUrl, "AlcLogo")) { db.empresa.Add(empresa); db.SaveChanges(); this.guardarImagen(empresa, "LogoUrl", LogoUrl); if (controlador.Equals("Home")) { ViewBag.tipo = "bg-primary"; ViewBag.mensaje = "La Empresa " + empresa.Nombre + " fue creada exisotamente. Recibira al correo electronico las credenciales de autenticación para ingresar a nuestra Plataforma"; return(View("../Shared/Mensaje")); } return(RedirectToAction("Index")); } } if (controlador.Equals("Home")) { return(RedirectToAction("Index", "Home")); } return(View(empresa)); }
// [FindRefreshDetectFilter] public ActionResult Index(int?saliendo) { string urlPrevia = ""; string urlActual = System.Web.HttpContext.Current.Request.Url.ToString(); if (System.Web.HttpContext.Current.Request.UrlReferrer != null) { urlPrevia = System.Web.HttpContext.Current.Request.UrlReferrer.ToString(); } if (!Request.IsAuthenticated && saliendo == null && !urlPrevia.Equals("") && !urlPrevia.Equals(urlActual)) { loghome log = db.loghome.Find(1); log.Visitantes = log.Visitantes + 1; db.SaveChanges(); } if (Session["EmpresaId"] == null) { try { Request.GetOwinContext().Authentication.SignOut(); //var accountController = new AccountController(); //accountController.LogOff(); } catch (Exception ex) { } } // RouteData.Values["IsRefreshed"] = false; ViewBag.controlador = "Home"; ViewBag.Login = new LoginViewModel(); empresa e = new empresa(); return(View(e)); }
public ActionResult Create([Bind(Include = "UsuarioId,UsuDocumento,UsuNombre,UsuEmail,UsuTelefono,aspnetusersId,EmpresaId,Estado,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion")] usuario usuario, string RoleId) { if (RoleId.Equals("")) { ModelState.AddModelError("RoleId", String.Format("Debe seleccionar un Roll")); } if (db.aspnetusers.Any(c => c.UserName.Trim().ToUpper() == usuario.UsuEmail)) { ModelState.AddModelError("", String.Format("Este correo ya se encuentra registrado")); } if (ModelState.IsValid) { HomeController home = new HomeController(); string[] arr1 = home.crearUsuario(RoleId, usuario.UsuEmail, UserManager).Split(','); string AspUserId = arr1[0]; string AspUserPasswd = arr1[1]; if (!AspUserId.Equals("")) { string mensaje = "<p <span style=\"font-size: 10pt;\">Apreciado " + usuario.UsuNombre + "</span></p>"; mensaje = mensaje + "<p <span style=\"font-size: 10pt;\">Ingresando a <a style=\"font-family: Calibri, sans-serif; font-size: 11pt;\" href=\"http://google.com\">CrediAdmin.com</a><span style=\"color: #1f497d; font-family: Calibri, sans-serif;\">, </span><span style=\"color: #1f497d; font-family: Calibri, sans-serif;\"> </span>podrás utilizar nuestra plataforma.</span></p>"; mensaje = mensaje + "<p <span style=\"font-size: 10pt;\">Nombre de Usuario: " + usuario.UsuEmail + "</span></p>"; mensaje = mensaje + "<p <span style=\"font-size: 10pt;\">Clave: " + AspUserPasswd + "</span></p>"; mensaje = mensaje + "<p><span style=\"font-size: 10pt;\"> </span></p>"; //Nombre + "" + AspUserPasswd; if (EnviarCorreoController.enviarCorreo(1, usuario.UsuEmail, "Bienvenido a CrediAdmin", mensaje)) { usuario.aspnetusersId = AspUserId; db.usuario.Add(usuario); db.SaveChanges(); return(RedirectToAction("Index")); } else { home.eliminarUsuarioAspNet(AspUserId); ModelState.AddModelError("UsuEmail", String.Format("No fue posible enviar correo electronico con credenciales")); } } else { ModelState.AddModelError("RoleId", String.Format("No fue posible crear usuario, vuelva a intentarlo")); } } if (usuario.EmpresaId == 1) { ViewBag.RoleId = new SelectList(context.Roles.OrderBy(r => r.Name).ToList(), "Name", "Name"); } else { ViewBag.RoleId = new SelectList(context.Roles.Where(r => r.Name != "Master").OrderBy(r => r.Name).ToList(), "Name", "Name"); } ViewBag.EmpresaId = new SelectList(db.empresa.Where(c => c.Estado == true).OrderBy(e => e.Nit), "EmpresaId", "Nit", usuario.EmpresaId); return(View(usuario)); }
public ActionResult Create([Bind(Include = "ContactoId,ConNombre,ConTelefono,ConEmail,ConObserva,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion,Estado")] contacto contacto) { if (ModelState.IsValid) { db.contacto.Add(contacto); db.SaveChanges(); //ViewBag.mensajeRegistroContacto = "Se registro su observacion o sugerencia exitosamente."; return(RedirectToAction("Contact", "Home", new { mensaje = "Se registro su observacion o sugerencia exitosamente." })); } //return RedirectToAction("Contact", "Home"); return(View(contacto)); }
public ActionResult Create([Bind(Include = "CiudadId,Nombre,EmpresaId,Estado,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion")] ciudad ciudad) { //int empresaId = 0; //if (Session["EmpresaId"] != null) // Int32.TryParse(Session["EmpresaId"].ToString(), out empresaId); //ciudad.EmpresaId = empresaId; if (ModelState.IsValid) { db.ciudad.Add(ciudad); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmpresaId = new SelectList(db.empresa.Where(c => c.Estado == true).OrderBy(e => e.Nit), "EmpresaId", "Nit", ciudad.EmpresaId); return(View(ciudad)); }
public ActionResult Create([Bind(Include = "RetiroInteresId,Valor,Fecha,EmpresaId,Observacion,CreadoPor,FechaCreacion,ModificadoPor,FechaModificacion,Estado")] retirointeres retirointeres) { if (ModelState.IsValid) { //int empresaId = 0; //if (Session["EmpresaId"] != null) // Int32.TryParse(Session["EmpresaId"].ToString(), out empresaId); consecutivo c = db.consecutivo.Find(retirointeres.EmpresaId); c.RetiroInteresNro = c.RetiroInteresNro + 1; retirointeres.RetiroInteresNro = c.RetiroInteresNro; db.retirointeres.Add(retirointeres); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmpresaId = retirointeres.EmpresaId; //ViewBag.EmpresaId = new SelectList(db.empresa.Where(c=>c.Estado==true).OrderBy(e=>e.Nit), "EmpresaId", "Nit", retirointeres.EmpresaId); return(View(retirointeres)); }
public void eliminarUsuarioAspNet(string userId) { CrediAdminContext storeContext = new CrediAdminContext(); var item = storeContext.aspnetusers.Find(userId); if (item != null) { storeContext.aspnetusers.Remove(item); storeContext.SaveChanges(); } }
public ActionResult Create(abono abono, string controlador, int EmpresaId, string fechaActual) { ViewBag.EmpresaId = EmpresaId; if (ModelState.IsValid) { if (abono.Paga > abono.Valor) { abono.Devolucion = abono.Paga - abono.Valor; } else { abono.Valor = abono.Paga; abono.Devolucion = 0; } consecutivo c = db.consecutivo.Find(EmpresaId); c.AbonoNro = c.AbonoNro + 1; abono.AbonoNro = c.AbonoNro; db.abono.Add(abono); db.SaveChanges(); // return RedirectToAction("EnviarCorreoFromAWS", new { abonoId = MiUtil.encriptar(abono.AbonoId.ToString()), abonoNro = abono.AbonoNro }); //return RedirectToAction("Index", controlador, new { id = MiUtil.encriptar(abono.CuotaId.ToString()), controlador = controlador, fechaActual=fechaActual }); return(RedirectToAction("Index", new { id = MiUtil.encriptar(abono.CuotaId.ToString()), controlador = controlador, fechaActual = fechaActual })); } ViewBag.CuotaId = abono.CuotaId; cuota cuota = db.cuota.Find(abono.CuotaId); abono.cuota = cuota; ViewBag.cuotaId = abono.CuotaId; ViewBag.CreditoId = cuota.CreditoId; ViewBag.CreditoNro = cuota.credito.CreditoNro; ViewBag.cuotaNumero = cuota.Numero; ViewBag.saldo = cuota.calcularSaldoxCapital() + cuota.calcularSaldoxInteres(); ViewBag.controlador = controlador; //ViewBag.CuotaId = new SelectList(db.Cuotas, "CuotaId", "CuotaId", abono.CuotaId); return(View(abono)); }
public ActionResult Create(paramcorreo paramcorreo) { int empresaId = 0; if (Session["EmpresaId"] != null) { Int32.TryParse(Session["EmpresaId"].ToString(), out empresaId); } paramcorreo.EmpresaId = empresaId; if (ModelState.IsValid) { db.paramcorreo.Add(paramcorreo); db.SaveChanges(); return(RedirectToAction("Index")); } var e = db.empresa.Where(u => u.Estado == true); // int empresaId = Convert.ToInt32(Session["EmpresaId"]); ViewBag.EmpresaId = new SelectList(e.Where(u => u.EmpresaId == empresaId), "EmpresaId", "Nombre", empresaId); //ViewBag.EmpresaId = new SelectList(db.Empresas, "EmpresaId", "Nombre", paramcorreo.EmpresaId); return(View(paramcorreo)); }
//[HttpPost] //public ActionResult EnviarCorreo(EnviarCorreo enviarcorreo, string button, string urlPapa, string abonoId) //{ // //if (button.Equals("Cancelar")) // // return RedirectToAction("Index", "CuotasxCobrar", new { controlador = controlador }); // if (ModelState.IsValid) // { // var fromAddress = new MailAddress(enviarcorreo.Usuario,enviarcorreo.Empresa); // var toAddress = new MailAddress(enviarcorreo.Destinatario,""); // string fromPassword = enviarcorreo.Password; // string subject = enviarcorreo.Asunto; // string body = enviarcorreo.Mensaje; // System.Net.Mail.Attachment attachment; // attachment = new System.Net.Mail.Attachment(enviarcorreo.Adjunto); // var smtp = new SmtpClient // { // Host = enviarcorreo.Servidor, // Port = enviarcorreo.Puerto, // EnableSsl = true, // DeliveryMethod = SmtpDeliveryMethod.Network, // // UseDefaultCredentials = true, // UseDefaultCredentials = false, // Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword) // }; // MailMessage message = new MailMessage(fromAddress, toAddress); // message.Subject = subject; // message.Body = body; // message.Attachments.Add(attachment); // try // { // smtp.Send(message); // Response.Redirect(urlPapa, true); // } // catch (Exception ex) // { // ViewBag.mensaje = "Exception caught in CreateTestMessage2(): {0}"+ ex.ToString(); // Console.WriteLine("Exception caught in CreateTestMessage2(): {0}",ex.ToString()); // } // } // //return View("../Shared/Mensaje"); // // return View(""); // return RedirectToAction("EnviarAbono", new { abonoId = abonoId, urlPapa = urlPapa }); //} public JsonResult EnviarAbono(string Servidor, int Puerto, string Usuario, string Empresa, string Destinatario, string Password, string Asunto, string Mensaje, string Adjunto, string AbonoId) { EnviarCorreo c = new EnviarCorreo(); c.Servidor = Servidor; c.Puerto = Puerto; c.Usuario = Usuario; c.Empresa = Empresa; c.Destinatario = Destinatario; c.Password = Password; c.Asunto = Asunto; c.Mensaje = Mensaje; c.Adjunto = Adjunto; //FechaCreacion=new DateTime(DateTime.Now.Year, DateTime.Now.Month,DateTime.Now.Day) string s = ""; bool ok = false; if (TryValidateModel(c)) { if (ModelState.IsValid) { var fromAddress = new MailAddress(Usuario, Empresa); var toAddress = new MailAddress(Destinatario, ""); string fromPassword = Password; string subject = Asunto; string body = Mensaje; System.Net.Mail.Attachment attachment; attachment = new System.Net.Mail.Attachment(Adjunto); var smtp = new SmtpClient { Host = Servidor, Port = Puerto, EnableSsl = true, DeliveryMethod = SmtpDeliveryMethod.Network, // UseDefaultCredentials = true, UseDefaultCredentials = false, Credentials = new System.Net.NetworkCredential(fromAddress.Address, fromPassword) }; MailMessage message = new MailMessage(fromAddress, toAddress); message.Subject = subject; message.Body = body; message.Attachments.Add(attachment); try { smtp.Send(message); //Response.Redirect(urlPapa, true); ok = true; //string idDecrypted = MiUtil.desEncriptar(AbonoId); int intAbonoId = 0; Int32.TryParse(AbonoId, out intAbonoId); abono ab = db.abono.Find(intAbonoId); //abono ab = db.abono.Find(AbonoId); if (ab != null) { ab.FechaEnvio = DateTime.Now; db.SaveChanges(); } } catch (Exception ex) { s = ex.ToString().Substring(0, 200); ViewBag.mensaje = "Exception caught in CreateTestMessage2(): {0}" + ex.ToString(); Console.WriteLine("Exception caught in CreateTestMessage2(): {0}", ex.ToString()); } } } if (!ok) { foreach (ModelState modelState in ViewData.ModelState.Values) { foreach (ModelError error in modelState.Errors) { s = s + error.ErrorMessage; } } } // return Json(new { success = false }); return(Json(new { success = ok, Error = s }, JsonRequestBehavior.AllowGet)); }