public ActionResult Rpt01(int?index) { ViewBag.drpOrdenacao = BindDropDownListFactory.BindEnum <drpOrdenacao>("A"); using (PinheiroSereniContext db = new PinheiroSereniContext()) ViewBag.drpEmpreendimentos = BindDropDownListFactory.Bind <drpEmpreedimentos>(db, "1"); return(Rpt01List(index, DateTime.Today.AddDays(-30).ToString("dd/MM/yyyy"), DateTime.Today.ToString("dd/MM/yyyy"), "A", "1", "40")); }
public ActionResult Rpt02(int?index) { using (PinheiroSereniContext db = new PinheiroSereniContext()) { ViewBag.drpCorretores = BindDropDownListFactory.Bind <drpCorretores>(db, "", "Todos..."); ViewBag.drpEmpreendimentos = BindDropDownListFactory.Bind <drpEmpreedimentos>(db, "1"); } return(Rpt02List(index, DateTime.Today.AddDays(-30).ToString("dd/MM/yyyy"), DateTime.Today.ToString("dd/MM/yyyy"), null, "1", "15")); }
public ActionResult Create(string sucesso = "") { if (AccessDenied(System.Web.HttpContext.Current.Session.SessionID)) { return(RedirectToAction("Index", "Home")); } using (PinheiroSereniContext db = new PinheiroSereniContext()) ViewBag.drpCorretoras = BindDropDownListFactory.Bind <drpCorretoras>(db, "", "Selecione..."); ViewBag.drpSituacao = BindDropDownListFactory.BindEnum <PinheiroSereni.Dominio.Enumeracoes.drpSituacao>("A"); if (sucesso != null) { if (sucesso.Trim() != "") { ViewBag.Sucesso = sucesso; } } return(View()); }
public ActionResult Create(CorretorRepository value) { if (AccessDenied(System.Web.HttpContext.Current.Session.SessionID)) { return(RedirectToAction("Index", "Home")); } value.mensagem = new Validate(); if (ModelState.IsValid) { try { var fileName = "CorretorNulo.png"; // Se for informado o arquivo da foto para upload if (this.Request.Files.Count > 0) { if (this.Request.Files [0].FileName.Trim() != "") { #region verifica o tamanho da foto if (this.Request.Files[0].ContentLength < 15360 || this.Request.Files[0].ContentLength > 71680) // entre 15 kb e 70 kb { value.mensagem.Code = 100; value.mensagem.Field = "foto"; value.mensagem.Message = "Tamanho da foto do corretor inválido. Arquivo fora das dimensões permitida."; value.mensagem.MessageBase = "O tamanho do arquivo da foto deve estar entre 15kb e 70kb"; throw new PinheiroSereniException(value.mensagem); } #endregion #region Verifica o formato do arquivo System.IO.FileInfo f = new FileInfo(Request.Files[0].FileName); if (f.Extension.ToLower() != ".png") { value.mensagem.Field = "foto"; value.mensagem.Code = 101; value.mensagem.Message = "O arquivo deve ser no formato PNG."; value.mensagem.MessageBase = "A extensão do arquivo da foto deve ser .PNG"; throw new PinheiroSereniException(value.mensagem); } #endregion #region Enviar a foto do corretor fileName = String.Format("{0}.png", Guid.NewGuid().ToString()); var imagePath = Path.Combine(Server.MapPath(Url.Content("~/Content/themes/base/images/uploads")), fileName); this.Request.Files[0].SaveAs(imagePath); #endregion } } #region gravar os dados do corretor value.mensagem = new Validate(); value.corretor.nome = value.corretor.nome.ToUpper(); value.corretor.setor = value.corretor.setor.ToUpper(); value.corretor.telefone = value.corretor.telefone.Replace("(", "").Replace(")", "").Replace("-", ""); value.corretor.foto = fileName; value.corretor.email = value.corretor.email.ToLower(); ControllerFactory <CorretorCrud> factory = new ControllerFactory <CorretorCrud>(); value = (CorretorRepository)factory.Insert(value); if (value.mensagem.Code > 0) { throw new PinheiroSereniException(value.mensagem); } #endregion return(RedirectToAction("Create", new { sucesso = MensagemPadrao.Message(0).ToString() + ". ID do corretor = " + value.corretor.corretorId.ToString() })); } catch (PinheiroSereniException ex) { ModelState.AddModelError(value.mensagem.Field, ex.Result.Message); using (PinheiroSereniContext db = new PinheiroSereniContext()) ViewBag.drpCorretoras = BindDropDownListFactory.Bind <drpCorretoras>(db, value.corretor.corretoraId.ToString(), "Selecione..."); ViewBag.drpSituacao = BindDropDownListFactory.BindEnum <PinheiroSereni.Dominio.Enumeracoes.drpSituacao>(value.corretor.situacao); return(View(value)); } }