public JsonResult EditarAgendaOnChange(Int32 id, DateTime data)
        {
            try
            {
                USUARIO usu  = (USUARIO)Session["UserCredentials"];
                AGENDA  obj  = baseApp.GetById(id);
                AGENDA  item = new AGENDA();
                item.AGEN_CD_ID          = id;
                item.USUA_CD_ID          = obj.USUA_CD_ID;
                item.ASSI_CD_ID          = obj.ASSI_CD_ID;
                item.CAAG_CD_ID          = obj.CAAG_CD_ID;
                item.AGEN_HR_HORA        = data.TimeOfDay;
                item.AGEN_DT_DATA        = data.Date;
                item.AGEN_IN_ATIVO       = 1;
                item.AGEN_NM_TITULO      = obj.AGEN_NM_TITULO;
                item.AGEN_DS_DESCRICAO   = obj.AGEN_DS_DESCRICAO;
                item.AGEN_CD_USUARIO     = obj.AGEN_CD_USUARIO;
                item.AGEN_TX_OBSERVACOES = obj.AGEN_TX_OBSERVACOES;
                item.AGEN_IN_STATUS      = obj.AGEN_IN_STATUS;

                Int32 volta = baseApp.ValidateEdit(item, obj, usu);

                if (volta == 0)
                {
                    ((List <AGENDA>)Session["ListaAgenda"]).Where(x => x.AGEN_CD_ID == id).First().AGEN_DT_DATA = data;
                }

                return(Json(volta));
            }
            catch (Exception ex)
            {
                return(Json(ex.Message));
            }
        }
        public ActionResult IncluirAgenda()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            // Prepara listas
            Int32 idAss = (Int32)Session["IdAssinante"];

            ViewBag.Tipos    = new SelectList(baseApp.GetAllTipos(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");
            ViewBag.Usuarios = new SelectList(usuApp.GetAllItens(idAss), "USUA_CD_ID", "USUA_NM_NOME");

            // Prepara view
            USUARIO usuario = (USUARIO)Session["UserCredentials"];

            AGENDA          item = new AGENDA();
            AgendaViewModel vm   = Mapper.Map <AGENDA, AgendaViewModel>(item);

            vm.AGEN_DT_DATA   = DateTime.Today.Date;
            vm.ASSI_CD_ID     = usuario.ASSI_CD_ID;
            vm.AGEN_IN_ATIVO  = 1;
            vm.USUA_CD_ID     = usuario.USUA_CD_ID;
            vm.AGEN_IN_STATUS = 1;
            return(View(vm));
        }
        public ActionResult MontarTelaAgendaCalendario()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Session["VoltaAgenda"]            = 3;
            Session["FiltroAgendaCalendario"] = 2;
            var   usuario = (USUARIO)Session["UserCredentials"];
            Int32 idAss   = (Int32)Session["IdAssinante"];

            ViewBag.Tipos    = new SelectList(baseApp.GetAllTipos(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");
            ViewBag.Usuarios = new SelectList(usuApp.GetAllItens(idAss), "USUA_CD_ID", "USUA_NM_NOME");

            AGENDA          item = new AGENDA();
            AgendaViewModel vm   = Mapper.Map <AGENDA, AgendaViewModel>(item);

            vm.ASSI_CD_ID     = usuario.ASSI_CD_ID;
            vm.AGEN_DT_DATA   = DateTime.Today.Date;
            vm.AGEN_IN_ATIVO  = 1;
            vm.USUA_CD_ID     = usuario.USUA_CD_ID;
            vm.AGEN_IN_STATUS = 1;

            if (Session["FiltroAgendaCalendario"] == null)
            {
                listaMasterCalendario             = baseApp.GetByUser(usuario.USUA_CD_ID, idAss);
                Session["FiltroAgendaCalendario"] = listaMaster;
            }

            ViewBag.Title = "Agenda";
            return(View(vm));
        }
        public ActionResult VerTimelineAgenda()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            ViewBag.Title = "Agenda";
            Int32 idAss = (Int32)Session["IdAssinante"];

            ViewBag.Tipos = new SelectList(caApp.GetAllItens(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");
            List <AGENDA> lista       = (List <AGENDA>)Session["ListaAgenda"];
            var           listaAgenda = lista.Where(x => x.AGEN_DT_DATA.Date == DateTime.Now.Date || x.AGEN_DT_DATA.Date == DateTime.Now.AddDays(1).Date).ToList();

            // Carrega listas
            USUARIO usuario = (USUARIO)Session["UserCredentials"];

            listaMaster            = baseApp.GetByUser(usuario.USUA_CD_ID, idAss);
            Session["ListaAgenda"] = listaMaster;
            ViewBag.Listas         = listaAgenda;
            ViewBag.Agenda         = listaAgenda.Count;

            objeto = new AGENDA();
            objeto.AGEN_DT_DATA    = DateTime.Today.Date;
            Session["VoltaAgenda"] = 2;
            return(View(objeto));
        }
Example #5
0
 private void dgAgendamento_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try {
         if (dgAgendamento.SelectedItems.Count > 0)
         {
             agendamento = dgAgendamento.SelectedItem as AGENDA;
             if (agendamento != null)
             {
                 cbClientes.ItemsSource = null;
                 txtCodCliente.Text     = agendamento.codcliente.ToString();
                 txtCodigo.Text         = agendamento.codigo.ToString();
                 cbClientes.Items.Add(agendamento.cliente);
                 cbClientes.Text     = agendamento.cliente;
                 txtDescricao.Text   = agendamento.descricao;
                 MtxtHinicio.Text    = DateTime.Parse(agendamento.hora_inicio.ToString()).ToShortTimeString();
                 MtxtHfim.Text       = DateTime.Parse(agendamento.hora_fim.ToString()).ToShortTimeString();
                 dpData.Text         = agendamento.data.ToString();
                 txtCodBarbeiro.Text = agendamento.codbarbeiro.ToString();
                 cbBarbeiro.Text     = agendamento.nome_barbeiro;
             }
         }
     }
     catch (Exception ex) {
         MessageBox.Show("Selecione um registro!" + "\n" + ex.Message, "Aviso",
                         MessageBoxButton.OK, MessageBoxImage.Hand);
     }
 }
        public ActionResult FiltrarTimelineAgenda(AGENDA item)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            try
            {
                // Executa a operação
                List <AGENDA> listaObj = new List <AGENDA>();
                USUARIO       usuario  = (USUARIO)Session["UserCredentials"];
                Int32         idAss    = (Int32)Session["IdAssinante"];
                Session["FiltroAgenda"] = item;
                Int32 volta = baseApp.ExecuteFilter(item.AGEN_DT_DATA, item.CAAG_CD_ID, item.AGEN_NM_TITULO, item.AGEN_DS_DESCRICAO, idAss, usuario.USUA_CD_ID, out listaObj);

                // Verifica retorno
                if (volta == 1)
                {
                    Session["MensAgendaTimeline"] = 1;
                }

                // Sucesso
                listaMaster = listaObj;
                Session["ListaAgendaTimeLine"] = listaObj;
                return(RedirectToAction("VerTimelineAgenda"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(RedirectToAction("VerTimelineAgenda"));
            }
        }
Example #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            AGENDA agenda = db.AGENDA.Find(id);

            db.AGENDA.Remove(agenda);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        //[ValidateAntiForgeryToken]
        public ActionResult IncluirAgenda(AgendaViewModel vm)
        {
            var result = new Hashtable();

            Int32 idAss = (Int32)Session["IdAssinante"];

            ViewBag.Tipos    = new SelectList(caApp.GetAllItens(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");
            ViewBag.Usuarios = new SelectList(usuApp.GetAllItens(idAss), "USUA_CD_ID", "USUA_NM_NOME");
            if (ModelState.IsValid)
            {
                try
                {
                    // Executa a operação
                    AGENDA  item          = Mapper.Map <AgendaViewModel, AGENDA>(vm);
                    USUARIO usuarioLogado = (USUARIO)Session["UserCredentials"];
                    Int32   volta         = baseApp.ValidateCreate(item, usuarioLogado);

                    // Cria pastas
                    String caminho = "/Imagens/Agenda/" + idAss.ToString() + "/" + item.AGEN_CD_ID.ToString() + "/Anexos/";
                    Directory.CreateDirectory(Server.MapPath(caminho));

                    // Sucesso
                    listaMaster            = new List <AGENDA>();
                    Session["ListaAgenda"] = null;

                    Session["IdVolta"] = item.AGEN_CD_ID;

                    //if (SessionMocks.idAtendimentoAgenda != null)
                    //{
                    //    ATENDIMENTO_AGENDA aa = new ATENDIMENTO_AGENDA();
                    //    aa.AGEN_CD_ID = item.AGEN_CD_ID;
                    //    aa.ATEN_CD_ID = (Int32)SessionMocks.idAtendimentoAgenda;
                    //    aa.ATAG_IN_ATIVO = 1;

                    //    Int32 voltaAA = atenAgenApp.ValidateCreate(aa, usuarioLogado);

                    //    result.Add("idAtendimento", SessionMocks.idAtendimentoAgenda);
                    //    return Json(result);
                    //}
                    //else
                    //{
                    result.Add("id", item.AGEN_CD_ID);
                    return(Json(result));
                    //}
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    result.Add("error", ex.Message);
                    return(Json(result));
                }
            }
            else
            {
                return(View(vm));
            }
        }
Example #9
0
        //
        // GET: /Agenda/Details/5

        public ActionResult Details(int id = 0)
        {
            AGENDA agenda = db.AGENDA.Find(id);

            if (agenda == null)
            {
                return(HttpNotFound());
            }
            return(View(agenda));
        }
Example #10
0
 public ActionResult Edit([Bind(Include = "Id,name,description")] AGENDA aGENDA)
 {
     if (ModelState.IsValid)
     {
         db.Entry(aGENDA).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(aGENDA));
 }
        public ActionResult MontarTelaAgenda()
        {
            // Verifica se tem usuario logado
            USUARIO usuario = new USUARIO();

            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if ((USUARIO)Session["UserCredentials"] != null)
            {
                usuario = (USUARIO)Session["UserCredentials"];

                // Verfifica permissão
            }
            else
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Int32 idAss = (Int32)Session["IdAssinante"];

            Session["FiltroAgendaCalendario"] = 1;

            // Carrega listas
            if (Session["ListaAgenda"] == null)
            {
                listaMaster            = baseApp.GetByUser(usuario.USUA_CD_ID, idAss);
                Session["ListaAgenda"] = listaMaster;
            }
            if (((List <AGENDA>)Session["ListaAgenda"]).Count == 0)
            {
                listaMaster            = baseApp.GetByUser(usuario.USUA_CD_ID, idAss);
                Session["ListaAgenda"] = listaMaster;
            }
            ViewBag.Listas = ((List <AGENDA>)Session["ListaAgenda"]).OrderBy(x => x.AGEN_DT_DATA.Date).ThenBy(x => x.AGEN_HR_HORA).ToList <AGENDA>();
            ViewBag.Itens  = ((List <AGENDA>)Session["ListaAgenda"]).Count;
            ViewBag.Title  = "Agenda";
            ViewBag.Tipos  = new SelectList(baseApp.GetAllTipos(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");

            // Indicadores
            ViewBag.Perfil = usuario.PERFIL.PERF_SG_SIGLA;

            // Mensagem
            if ((Int32)Session["MensAgenda"] == 1)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
            }

            // Abre view
            Session["MensAgenda"] = 0;
            objeto = new AGENDA();
            objeto.AGEN_DT_DATA    = DateTime.Today.Date;
            Session["VoltaAgenda"] = 1;
            return(View(objeto));
        }
Example #12
0
        public ActionResult Create([Bind(Include = "Id,name,description")] AGENDA aGENDA)
        {
            if (ModelState.IsValid)
            {
                db.AGENDA.Add(aGENDA);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aGENDA));
        }
Example #13
0
        //
        // GET: /Agenda/Edit/5

        public ActionResult Edit(int id = 0)
        {
            AGENDA agenda = db.AGENDA.Find(id);

            if (agenda == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DESTINOFINAL_DESTINOID = new SelectList(db.DESTINO, "ID", "ENDERECO", agenda.DESTINOFINAL_DESTINOID);
            ViewBag.USUARIOPROPRIETARIO_ID = new SelectList(db.USUARIOS, "ID", "NOME", agenda.USUARIOPROPRIETARIO_ID);
            ViewBag.CARRO_CARROID          = new SelectList(db.VEICULO, "ID", "MODELO", agenda.CARRO_CARROID);
            return(View(agenda));
        }
Example #14
0
 public ActionResult Edit(AGENDA agenda)
 {
     if (ModelState.IsValid)
     {
         db.Entry(agenda).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DESTINOFINAL_DESTINOID = new SelectList(db.DESTINO, "ID", "ENDERECO", agenda.DESTINOFINAL_DESTINOID);
     ViewBag.USUARIOPROPRIETARIO_ID = new SelectList(db.USUARIOS, "ID", "NOME", agenda.USUARIOPROPRIETARIO_ID);
     ViewBag.CARRO_CARROID          = new SelectList(db.VEICULO, "ID", "MODELO", agenda.CARRO_CARROID);
     return(View(agenda));
 }
Example #15
0
        // GET: AGENDA/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AGENDA aGENDA = db.AGENDA.Find(id);

            if (aGENDA == null)
            {
                return(HttpNotFound());
            }
            return(View(aGENDA));
        }
        public ActionResult VerTimelineAgenda()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            USUARIO usuario = (USUARIO)Session["UserCredentials"];
            Int32   idAss   = (Int32)Session["IdAssinante"];

            ViewBag.Title = "Agenda";
            ViewBag.Tipos = new SelectList(baseApp.GetAllTipos(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");
            if (Session["ListaAgendaTimeLine"] == null)
            {
                Session["ListaAgendaTimeLine"] = baseApp.GetByUser(usuario.USUA_CD_ID, idAss).Where(x => x.AGEN_DT_DATA.Date == DateTime.Now.Date).ToList <AGENDA>();
            }
            if (((List <AGENDA>)Session["ListaAgendaTimeLine"]).Count == 0)
            {
                Session["ListaAgendaTimeLine"] = baseApp.GetByUser(usuario.USUA_CD_ID, idAss).Where(x => x.AGEN_DT_DATA.Date == DateTime.Now.Date).ToList <AGENDA>();
            }

            if (Session["ListaAgendaTimeLine"] == null || ((List <AGENDA>)Session["ListaAgendaTimeLine"]).Count == 0)
            {
                Session["MensAgendaTimeline"] = 1;
            }

            // Carrega listas
            ViewBag.Listas = ((List <AGENDA>)Session["ListaAgendaTimeLine"]).OrderBy(x => x.AGEN_DT_DATA).ThenBy(x => x.AGEN_HR_HORA).ToList <AGENDA>();
            ViewBag.Agenda = ((List <AGENDA>)Session["ListaAgendaTimeLine"]).Count;

            if (Session["MensAgendaTimeline"] != null)
            {
                if ((Int32)Session["MensAgendaTimeline"] == 1)
                {
                    ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
                    Session["MensAgendaTimeline"] = 0;
                }
            }

            objeto = new AGENDA();
            if (Session["FiltroAgenda"] != null && ((AGENDA)Session["FiltroAgenda"]).AGEN_DT_DATA != null)
            {
                objeto.AGEN_DT_DATA = ((AGENDA)Session["FiltroAgenda"]).AGEN_DT_DATA;
            }
            else
            {
                objeto.AGEN_DT_DATA = DateTime.Now.Date;
            }
            Session["VoltaAgenda"] = 2;
            return(View(objeto));
        }
Example #17
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AGENDA = await _context.AGENDA.FirstOrDefaultAsync(m => m.ID == id);

            if (AGENDA == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public ActionResult EditarAgenda(AgendaViewModel vm)
        {
            Int32 idAss = (Int32)Session["IdAssinante"];

            ViewBag.Tipos    = new SelectList(caApp.GetAllItens(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");
            ViewBag.Usuarios = new SelectList(usuApp.GetAllItens(idAss), "USUA_CD_ID", "USUA_NM_NOME");
            List <SelectListItem> status = new List <SelectListItem>();

            status.Add(new SelectListItem()
            {
                Text = "Ativo", Value = "1"
            });
            status.Add(new SelectListItem()
            {
                Text = "Suspenso", Value = "2"
            });
            status.Add(new SelectListItem()
            {
                Text = "Encerrado", Value = "3"
            });
            ViewBag.Status = new SelectList(status, "Value", "Text");
            if (ModelState.IsValid)
            {
                try
                {
                    // Executa a operação
                    USUARIO usuarioLogado = (USUARIO)Session["UserCredentials"];
                    AGENDA  item          = Mapper.Map <AgendaViewModel, AGENDA>(vm);
                    Int32   volta         = baseApp.ValidateEdit(item, objetoAntes, usuarioLogado);

                    // Verifica retorno

                    // Sucesso
                    listaMaster            = new List <AGENDA>();
                    Session["ListaAgenda"] = null;
                    return(RedirectToAction("MontarTelaAgenda"));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View(vm));
                }
            }
            else
            {
                return(View(vm));
            }
        }
Example #19
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            AGENDA = await _context.AGENDA.FindAsync(id);

            if (AGENDA != null)
            {
                _context.AGENDA.Remove(AGENDA);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
Example #20
0
        public IHttpActionResult GetAGENDA_DTO(int id)
        {
            //AGENDA_DTO aGENDA_DTO = db.AGENDA_DTO.Find(id);
            AGENDA_DTO aGENDA_DTO = null;
            AGENDA     aAGENDA    = db.AGENDA.Find(id);

            //.Select(x => new AGENDA_DTO {
            //    x.Id,
            //    x.name,
            //    x.description
            //});
            if (aGENDA_DTO == null)
            {
                return(NotFound());
            }

            return(Ok(aGENDA_DTO));
        }
        public ActionResult ReativarAgenda(Int32 id)
        {
            // Verifica se tem usuario logado
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            USUARIO usu = (USUARIO)Session["UserCredentials"];
            // Executar
            AGENDA item = baseApp.GetItemById(id);

            objetoAntes        = (AGENDA)Session["Agenda"];
            item.AGEN_IN_ATIVO = 1;
            Int32 volta = baseApp.ValidateReativar(item, usu);

            listaMaster            = new List <AGENDA>();
            Session["ListaAgenda"] = null;
            return(RedirectToAction("MontarTelaAgenda"));
        }
        public ActionResult MontarTelaAgenda()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            Session["FiltroAgendaCalendario"] = 1;
            var   usuario = (USUARIO)Session["UserCredentials"];
            Int32 idAss   = (Int32)Session["IdAssinante"];

            // Carrega listas
            if (Session["ListaAgenda"] == null)
            {
                listaMaster            = baseApp.GetByUser(usuario.USUA_CD_ID, idAss);
                Session["ListaAgenda"] = listaMaster;
            }
            ViewBag.Listas = (List <AGENDA>)Session["ListaAgenda"];
            ViewBag.Itens  = ((List <AGENDA>)Session["ListaAgenda"]).Count;
            ViewBag.Title  = "Agenda";
            ViewBag.Tipos  = new SelectList(caApp.GetAllItens(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");

            // Indicadores
            ViewBag.Perfil = usuario.PERFIL.PERF_SG_SIGLA;

            // Mensagem
            if ((Int32)Session["MensAgenda"] == 1)
            {
                ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
            }

            // Abre view
            objeto = new AGENDA();
            objeto.AGEN_DT_DATA    = DateTime.Today.Date;
            Session["VoltaAgenda"] = 1;
            Session["MensAgenda"]  = 0;
            return(View(objeto));
        }
        public ActionResult EditarAgenda(Int32 id)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }

            // Prepara view
            Int32 idAss = (Int32)Session["IdAssinante"];

            ViewBag.Tipos    = new SelectList(baseApp.GetAllTipos(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");
            ViewBag.Usuarios = new SelectList(usuApp.GetAllItens(idAss), "USUA_CD_ID", "USUA_NM_NOME");
            List <SelectListItem> status = new List <SelectListItem>();

            status.Add(new SelectListItem()
            {
                Text = "Ativo", Value = "1"
            });
            status.Add(new SelectListItem()
            {
                Text = "Suspenso", Value = "2"
            });
            status.Add(new SelectListItem()
            {
                Text = "Encerrado", Value = "3"
            });
            ViewBag.Status = new SelectList(status, "Value", "Text");

            AGENDA item = baseApp.GetItemById(id);

            objetoAntes        = item;
            Session["Agenda"]  = item;
            Session["IdVolta"] = id;
            AgendaViewModel vm = Mapper.Map <AGENDA, AgendaViewModel>(item);

            return(View(vm));
        }
        public ActionResult FiltrarAgenda(AGENDA item)
        {
            try
            {
                if ((String)Session["Ativa"] == null)
                {
                    return(RedirectToAction("Login", "ControleAcesso"));
                }
                // Executa a operação
                Int32         idAss    = (Int32)Session["IdAssinante"];
                var           usuario  = (USUARIO)Session["UserCredentials"];
                List <AGENDA> listaObj = new List <AGENDA>();
                Int32         volta    = baseApp.ExecuteFilter(item.AGEN_DT_DATA, item.CAAG_CD_ID, item.AGEN_NM_TITULO, item.AGEN_DS_DESCRICAO, idAss, out listaObj);

                // Verifica retorno
                if (volta == 1)
                {
                    Session["MensAgenda"] = 1;
                    ModelState.AddModelError("", ERP_Condominio_Resources.ResourceManager.GetString("M0016", CultureInfo.CurrentCulture));
                }

                // Sucesso
                listaMaster            = listaObj;
                Session["ListaAgenda"] = listaObj;
                if ((Int32)Session["VoltaAgenda"] == 2)
                {
                    return(RedirectToAction("VerTimelineAgenda"));
                }
                return(RedirectToAction("MontarTelaAgenda"));
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(RedirectToAction("MontarTelaAgenda"));
            }
        }
        public ActionResult UploadFileAgenda(HttpPostedFileBase file)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            if (file == null)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0019", CultureInfo.CurrentCulture));
                return(RedirectToAction("VoltarAnexoAgenda"));
            }

            AGENDA  item     = baseApp.GetById((Int32)Session["IdVolta"]);
            USUARIO usu      = (USUARIO)Session["UserCredentials"];
            var     fileName = Path.GetFileName(file.FileName);

            if (fileName.Length > 250)
            {
                ModelState.AddModelError("", OdontoWeb_Resources.ResourceManager.GetString("M0024", CultureInfo.CurrentCulture));
                return(RedirectToAction("VoltarAnexoAgenda"));
            }

            String caminho = "/Imagens/" + ((Int32)Session["IdVolta"]).ToString() + "/Agenda/" + item.AGEN_CD_ID.ToString() + "/Anexos/";
            String path    = Path.Combine(Server.MapPath(caminho), fileName);

            file.SaveAs(path);

            //Recupera tipo de arquivo
            extensao = Path.GetExtension(fileName);
            String a = extensao;

            // Gravar registro
            AGENDA_ANEXO foto = new AGENDA_ANEXO();

            foto.AGAN_AQ_ARQUIVO = "~" + caminho + fileName;
            foto.AGAN_DT_ANEXO   = DateTime.Today;
            foto.AGAN_IN_ATIVO   = 1;
            Int32 tipo = 3;

            if (extensao.ToUpper() == ".JPG" || extensao.ToUpper() == ".GIF" || extensao.ToUpper() == ".PNG" || extensao.ToUpper() == ".JPEG")
            {
                tipo = 1;
            }
            if (extensao.ToUpper() == ".MP4" || extensao.ToUpper() == ".AVI" || extensao.ToUpper() == ".MPEG")
            {
                tipo = 2;
            }
            if (extensao.ToUpper() == ".PDF")
            {
                tipo = 3;
            }
            foto.AGAN_IN_TIPO   = tipo;
            foto.AGAN_NM_TITULO = fileName;
            foto.AGEN_CD_ID     = item.AGEN_CD_ID;

            item.AGENDA_ANEXO.Add(foto);
            objetoAntes = item;
            Int32 volta = baseApp.ValidateEdit(item, objetoAntes, usu);

            return(RedirectToAction("VoltarAnexoAgenda"));
        }
        //[ValidateAntiForgeryToken]
        public ActionResult IncluirAgenda(AgendaViewModel vm)
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            var   result = new Hashtable();
            Int32 idAss  = (Int32)Session["IdAssinante"];

            ViewBag.Tipos    = new SelectList(baseApp.GetAllTipos(idAss), "CAAG_CD_ID", "CAAG_NM_NOME");
            ViewBag.Usuarios = new SelectList(usuApp.GetAllItens(idAss), "USUA_CD_ID", "USUA_NM_NOME");
            if (ModelState.IsValid)
            {
                try
                {
                    // Executa a operação
                    AGENDA  item          = Mapper.Map <AgendaViewModel, AGENDA>(vm);
                    USUARIO usuarioLogado = (USUARIO)Session["UserCredentials"];
                    Int32   volta         = baseApp.ValidateCreate(item, usuarioLogado);

                    // Verifica retorno

                    // Cria pastas
                    String caminho = "/Imagens/" + usuarioLogado.ASSI_CD_ID.ToString() + "/Agenda/" + item.AGEN_CD_ID.ToString() + "/Anexos/";
                    Directory.CreateDirectory(Server.MapPath(caminho));

                    // Sucesso
                    listaMaster            = new List <AGENDA>();
                    Session["ListaAgenda"] = null;
                    Session["IdVolta"]     = item.AGEN_CD_ID;

                    if (Session["FileQueueAgenda"] != null)
                    {
                        List <FileQueue> fq = (List <FileQueue>)Session["FileQueueAgenda"];

                        foreach (var file in fq)
                        {
                            UploadFileQueueAgenda(file);
                        }

                        Session["FileQueueAgenda"] = null;
                    }

                    if ((Int32)Session["VoltaAgenda"] == 3)
                    {
                        return(RedirectToAction("MontarTelaAgendaCalendario"));
                    }

                    return(RedirectToAction("MontarTelaAgenda"));
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return(View(vm));
                }
            }
            else
            {
                return(View(vm));
            }
        }
        public ActionResult GerarRelatorioLista()
        {
            if ((String)Session["Ativa"] == null)
            {
                return(RedirectToAction("Login", "ControleAcesso"));
            }
            // Prepara geração
            String data = DateTime.Today.Date.ToShortDateString();

            data = data.Substring(0, 2) + data.Substring(3, 2) + data.Substring(6, 4);
            String        nomeRel  = "AgendaLista" + "_" + data + ".pdf";
            List <AGENDA> lista    = (List <AGENDA>)Session["ListaAgenda"];
            AGENDA        filtro   = (AGENDA)Session["FiltroAgenda"];
            Font          meuFont  = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
            Font          meuFont1 = FontFactory.GetFont("Arial", 9, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);
            Font          meuFont2 = FontFactory.GetFont("Arial", 12, iTextSharp.text.Font.NORMAL, BaseColor.BLACK);

            // Cria documento
            Document  pdfDoc    = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10);
            PdfWriter pdfWriter = PdfWriter.GetInstance(pdfDoc, Response.OutputStream);

            pdfDoc.Open();

            // Linha horizontal
            Paragraph line = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLUE, Element.ALIGN_LEFT, 1)));

            pdfDoc.Add(line);

            // Cabeçalho
            PdfPTable table = new PdfPTable(5);

            table.WidthPercentage     = 100;
            table.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right
            table.SpacingBefore       = 1f;
            table.SpacingAfter        = 1f;

            PdfPCell cell = new PdfPCell();

            cell.Border = 0;
            Image image = Image.GetInstance(Server.MapPath("~/Images/5.png"));

            image.ScaleAbsolute(50, 50);
            cell.AddElement(image);
            table.AddCell(cell);

            cell = new PdfPCell(new Paragraph("Agenda - Listagem", meuFont2))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_CENTER
            };
            cell.Border  = 0;
            cell.Colspan = 4;
            table.AddCell(cell);
            pdfDoc.Add(table);

            // Linha Horizontal
            Paragraph line1 = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLUE, Element.ALIGN_LEFT, 1)));

            pdfDoc.Add(line1);
            line1 = new Paragraph("  ");
            pdfDoc.Add(line1);

            // Grid
            table = new PdfPTable(new float[] { 60f, 60f, 90f, 200f, 120f, 70f, 50f });
            table.WidthPercentage     = 100;
            table.HorizontalAlignment = 0;
            table.SpacingBefore       = 1f;
            table.SpacingAfter        = 1f;

            cell = new PdfPCell(new Paragraph("Itens de Agenda selecionados pelos parametros de filtro abaixo", meuFont1))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_LEFT
            };
            cell.Colspan         = 8;
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            table.AddCell(cell);

            cell = new PdfPCell(new Paragraph("Data", meuFont))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_LEFT
            };
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            table.AddCell(cell);
            cell = new PdfPCell(new Paragraph("Hora", meuFont))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_LEFT
            };
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            table.AddCell(cell);
            cell = new PdfPCell(new Paragraph("Categoria", meuFont))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_LEFT
            };
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            table.AddCell(cell);
            cell = new PdfPCell(new Paragraph("Título", meuFont))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_LEFT
            };
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            table.AddCell(cell);
            cell = new PdfPCell(new Paragraph("Contato", meuFont))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_LEFT
            };
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            table.AddCell(cell);
            cell = new PdfPCell(new Paragraph("Status", meuFont))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_LEFT
            };
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            table.AddCell(cell);
            cell = new PdfPCell(new Paragraph("Anexos", meuFont))
            {
                VerticalAlignment   = Element.ALIGN_MIDDLE,
                HorizontalAlignment = Element.ALIGN_LEFT
            };
            cell.BackgroundColor = BaseColor.LIGHT_GRAY;
            table.AddCell(cell);

            foreach (AGENDA item in lista)
            {
                cell = new PdfPCell(new Paragraph(item.AGEN_DT_DATA.ToShortDateString(), meuFont))
                {
                    VerticalAlignment   = Element.ALIGN_MIDDLE,
                    HorizontalAlignment = Element.ALIGN_LEFT
                };
                table.AddCell(cell);
                cell = new PdfPCell(new Paragraph(item.AGEN_HR_HORA.ToString(), meuFont))
                {
                    VerticalAlignment   = Element.ALIGN_MIDDLE,
                    HorizontalAlignment = Element.ALIGN_LEFT
                };
                table.AddCell(cell);
                cell = new PdfPCell(new Paragraph(item.CATEGORIA_AGENDA.CAAG_NM_NOME, meuFont))
                {
                    VerticalAlignment   = Element.ALIGN_MIDDLE,
                    HorizontalAlignment = Element.ALIGN_LEFT
                };
                table.AddCell(cell);
                cell = new PdfPCell(new Paragraph(item.AGEN_NM_TITULO, meuFont))
                {
                    VerticalAlignment   = Element.ALIGN_MIDDLE,
                    HorizontalAlignment = Element.ALIGN_LEFT
                };
                table.AddCell(cell);
                if (item.USUARIO1 != null)
                {
                    cell = new PdfPCell(new Paragraph(item.USUARIO1.USUA_NM_NOME, meuFont))
                    {
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        HorizontalAlignment = Element.ALIGN_LEFT
                    };
                    table.AddCell(cell);
                }
                else
                {
                    cell = new PdfPCell(new Paragraph("-", meuFont))
                    {
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        HorizontalAlignment = Element.ALIGN_LEFT
                    };
                    table.AddCell(cell);
                }
                if (item.AGEN_IN_STATUS == 1)
                {
                    cell = new PdfPCell(new Paragraph("Ativo", meuFont))
                    {
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        HorizontalAlignment = Element.ALIGN_LEFT
                    };
                    table.AddCell(cell);
                }
                else if (item.AGEN_IN_STATUS == 2)
                {
                    cell = new PdfPCell(new Paragraph("Suspenso", meuFont))
                    {
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        HorizontalAlignment = Element.ALIGN_LEFT
                    };
                    table.AddCell(cell);
                }
                else
                {
                    cell = new PdfPCell(new Paragraph("Encerrado", meuFont))
                    {
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        HorizontalAlignment = Element.ALIGN_LEFT
                    };
                    table.AddCell(cell);
                }
                if (item.AGENDA_ANEXO.Count > 0)
                {
                    cell = new PdfPCell(new Paragraph(item.AGENDA_ANEXO.Count.ToString(), meuFont))
                    {
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        HorizontalAlignment = Element.ALIGN_LEFT
                    };
                    table.AddCell(cell);
                }
                else
                {
                    cell = new PdfPCell(new Paragraph("0", meuFont))
                    {
                        VerticalAlignment   = Element.ALIGN_MIDDLE,
                        HorizontalAlignment = Element.ALIGN_LEFT
                    };
                    table.AddCell(cell);
                }
            }
            pdfDoc.Add(table);

            // Linha Horizontal
            Paragraph line2 = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLUE, Element.ALIGN_LEFT, 1)));

            pdfDoc.Add(line2);

            // Rodapé
            Chunk chunk1 = new Chunk("Parâmetros de filtro: ", FontFactory.GetFont("Arial", 10, Font.NORMAL, BaseColor.BLACK));

            pdfDoc.Add(chunk1);

            String parametros = String.Empty;
            Int32  ja         = 0;

            if (filtro != null)
            {
                if (filtro.CAAG_CD_ID > 0)
                {
                    parametros += "Categoria: " + filtro.CAAG_CD_ID;
                    ja          = 1;
                }
                if (filtro.AGEN_DT_DATA != null)
                {
                    if (ja == 0)
                    {
                        parametros += "Data: " + filtro.AGEN_DT_DATA.ToShortDateString();
                        ja          = 1;
                    }
                    else
                    {
                        parametros += " e Data: " + filtro.AGEN_DT_DATA.ToShortDateString();
                    }
                }
                if (filtro.AGEN_NM_TITULO != null)
                {
                    if (ja == 0)
                    {
                        parametros += "Título: " + filtro.AGEN_NM_TITULO;
                        ja          = 1;
                    }
                    else
                    {
                        parametros += " e Título: " + filtro.AGEN_NM_TITULO;
                    }
                }
                if (filtro.AGEN_DS_DESCRICAO != null)
                {
                    if (ja == 0)
                    {
                        parametros += "Descrição: " + filtro.AGEN_DS_DESCRICAO;
                        ja          = 1;
                    }
                    else
                    {
                        parametros += " e Descrição: " + filtro.AGEN_DS_DESCRICAO;
                    }
                }
                if (ja == 0)
                {
                    parametros = "Nenhum filtro definido.";
                }
            }
            else
            {
                parametros = "Nenhum filtro definido.";
            }
            Chunk chunk = new Chunk(parametros, FontFactory.GetFont("Arial", 9, Font.NORMAL, BaseColor.BLACK));

            pdfDoc.Add(chunk);

            // Linha Horizontal
            Paragraph line3 = new Paragraph(new Chunk(new iTextSharp.text.pdf.draw.LineSeparator(0.0F, 100.0F, BaseColor.BLUE, Element.ALIGN_LEFT, 1)));

            pdfDoc.Add(line3);

            // Finaliza
            pdfWriter.CloseStream = false;
            pdfDoc.Close();
            Response.Buffer      = true;
            Response.ContentType = "application/pdf";
            Response.AddHeader("content-disposition", "attachment;filename=" + nomeRel);
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Write(pdfDoc);
            Response.End();

            return(RedirectToAction("MontarTelaAgenda"));
        }
Example #28
0
        //insere os dados no banco
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            AGENDAMENTOEntities db = new AGENDAMENTOEntities();

            try
            {
                AGENDA agen = new AGENDA();
                //Atribui em variaveis osc campo do nome de contato e o telefone principal
                string nomeContato      = txtNomeContato.Text;
                string tipoTelPrincipal = "";
                if (cbxTipoTelPrincipal.SelectedIndex == 2)
                {
                    tipoTelPrincipal = txtTipoTelPrincipal.Text;
                }
                if (cbxTipoTelPrincipal.SelectedIndex != 2)
                {
                    tipoTelPrincipal = cbxTipoTelPrincipal.SelectedItem.ToString();
                }
                string telPrincipal = txtTelPrincipal.Text;

                //passa os obrigatorios para a tabela
                agen.NOME               = nomeContato;
                agen.TEL_PRINCIPAL      = telPrincipal;
                agen.TIPO_TEL_PRINCIPAL = tipoTelPrincipal;

                //Caso a checkbox de inserir dados de endereço residencial estiver selecionada sera incluido tambem no banco
                if (chkResidencial.Checked)
                {
                    //passa todos os campos de texto para as variaveis
                    string cepResidencial         = txtCepResidencial.Text;
                    string UFResidencial          = txtUFResidencial.Text;
                    string localidadeResidencial  = txtLocalidadeResidencial.Text;
                    string logradouroResidencial  = txtLogradouroResidencial.Text;
                    string numeroResidencial      = txtNumeroResidencial.Text;
                    string complementoResidencial = txtComplementoResidencial.Text;
                    string bairroResidencial      = txtBairroResidencial.Text;

                    //insere os dados na tabela
                    agen.CEP_RESIDENCIAL         = cepResidencial;
                    agen.UF_RESIDENCIAL          = UFResidencial;
                    agen.LOCALIDADE_RESIDENCIAL  = localidadeResidencial;
                    agen.LOGRADOURO_RESIDENCIAL  = logradouroResidencial;
                    agen.NUMERO_RESIDENCIAL      = numeroResidencial;
                    agen.COMPLEMENTO_RESIDENCIAL = complementoResidencial;
                    agen.BAIRRO_RESIDENCIAL      = bairroResidencial;
                }

                //Caso a checkbox de inserir dados de endereço da empresa estiver selecionada sera incluido tambem no banco
                if (chkEmpresa.Checked)
                {
                    //passa todos os campos de texto para as variaveis
                    string nomeEmpresa        = txtNomeEmpresa.Text;
                    string cargo              = txtCargo.Text;
                    string cepEmpresa         = txtCepEmpresa.Text;
                    string UFEmpresa          = txtUFEmpresa.Text;
                    string localidadeEmpresa  = txtLocalidadeEmpresa.Text;
                    string logradouroEmpresa  = txtLogradouroEmpresa.Text;
                    string numeroEmpresa      = txtNumeroEmpresa.Text;
                    string complementoEmpresa = txtComplementoEmpresa.Text;
                    string bairroEmpresa      = txtBairroEmpresa.Text;

                    //insere os dados na tabela
                    agen.NOME_EMPRESA        = nomeEmpresa;
                    agen.CARGO_EMPRESA       = cargo;
                    agen.CEP_EMPRESA         = cepEmpresa;
                    agen.UF_EMPRESA          = UFEmpresa;
                    agen.LOCALIDADE_EMPRESA  = localidadeEmpresa;
                    agen.LOGRADOURO_EMPRESA  = logradouroEmpresa;
                    agen.NUMERO_EMPRESA      = numeroEmpresa;
                    agen.COMPLEMENTO_EMPRESA = complementoEmpresa;
                    agen.BAIRRO_EMPRESA      = bairroEmpresa;
                }
                //adciona na agenda
                db.AGENDA.Add(agen);
                db.SaveChanges();
                //busca o contato que foi cadastrado para relacionar o contato com a lista de telefones e emails opcionais
                var ContatoCadastrado = db.AGENDA.OrderByDescending(s => s.ID_AGENDA).FirstOrDefault();

                //Cria variaveis list para atribuir todos os telefones e emails cadastrados nas listbox
                List <TELEFONE> telOp   = new List <TELEFONE>();
                List <EMAIL>    emailOp = new List <EMAIL>();

                if (listTelOpcional.Items.Count > 0 || ListEmail.Items.Count > 0)
                {
                    //se a lista de telefones Opcionais possui a quantidade de registros maior que 0 sera atribuido a lista
                    if (listTelOpcional.Items.Count > 0)
                    {
                        //percorre pela listbox e insere cada um no banco
                        foreach (var item in listTelOpcional.Items)
                        {
                            //Salva os dados do telefone na string
                            string teletipo = item.ToString();
                            //separa a string de acordo com a quantidade de char que possui
                            string[] teletipoSep = teletipo.Split(new char[1] {
                                ';'
                            });
                            string tipoTel = teletipoSep[0];
                            string Tel     = teletipoSep[1];
                            telOp.Add(new TELEFONE
                            {
                                AGENDA_ID_AGENDA = ContatoCadastrado.ID_AGENDA,
                                TIPO_TEL         = tipoTel,
                                TEL = Tel
                            });
                        }
                        db.TELEFONE.AddRange(telOp);
                    }
                    //Caso se a lista com os emails for > 0 ira entrar no if
                    if (ListEmail.Items.Count > 0)
                    {
                        //percorre toda listBox para inserir na lista de emails
                        foreach (var item in ListEmail.Items)
                        {
                            string   emailTipo    = item.ToString();
                            string[] emailtipoSep = emailTipo.Split(new char[1] {
                                ';'
                            });
                            string tipoEmail = emailtipoSep[0];
                            string email     = emailtipoSep[1];
                            //insere na lista o email
                            emailOp.Add(new EMAIL
                            {
                                AGENDA_ID_AGENDA = ContatoCadastrado.ID_AGENDA,
                                TIPO_EMAIL       = tipoEmail,
                                EMAIL1           = email
                            });
                        }
                        //Adiciona todos os email na tabela de email
                        db.EMAIL.AddRange(emailOp);
                    }
                    //adiciona os telefones e emails opcionais no banco
                    db.SaveChanges();
                }
                MessageBox.Show("Cadastro Efetuado com sucesso", "SUCESSO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
            finally
            {
                db.Dispose();
            }
        }