protected void GridView_Sorting(object sender, GridViewSortEventArgs e)
        {
            ChamadosBLL chamadosBLL = new ChamadosBLL();
            DataTable   dt          = new DataTable();

            Usuario usuario = null;

            usuario = (Usuario)Session["objetoUsuario"];

            dt = chamadosBLL.GetChamados(usuario);

            if (dt.Rows.Count > 0)
            {
                dt.DefaultView.Sort = e.SortExpression + " " + GetDirecaoSort(e.SortExpression);

                GrdChamados.DataSource = dt;

                //Validação para mudança de valores no grid referente a status do chamado
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["StatusChamado"].ToString() == "P ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Pendente";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "A ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Em atendimento";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "F ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Finalizado";
                    }
                }

                //Validação para mudança de valores no grid referente a prioridade do chamado
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Prioridade"].ToString() == "0 ")
                    {
                        dt.Rows[i]["Prioridade"] = "Alta";
                    }

                    if (dt.Rows[i]["Prioridade"].ToString() == "1 ")
                    {
                        dt.Rows[i]["Prioridade"] = "Média";
                    }

                    if (dt.Rows[i]["Prioridade"].ToString() == "2 ")
                    {
                        dt.Rows[i]["Prioridade"] = "Baixa";
                    }
                }

                GrdChamados.DataBind();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <ChamadosModel> listChamados = new List <ChamadosModel>();

            listChamados = cb.ConsultaTodosChamado(cm);

            GrdChamados.DataSource = listChamados;
            GrdChamados.DataBind();
        }
        protected void GrdChamados_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            //Mudar código aqui para melhorar performance

            DataTable   dt          = new DataTable();
            ChamadosBLL chamadosBLL = new ChamadosBLL();

            dt = chamadosBLL.ListaChamadosPorId(Convert.ToInt32(Session["IdUsuario"].ToString()));

            GrdChamados.DataSource = dt;
            GrdChamados.PageIndex  = e.NewPageIndex;

            if (dt.Rows.Count > 0)
            {
                GrdChamados.DataSource = dt;

                //Validação para mudança de valores no grid referente a status do chamado
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["StatusChamado"].ToString() == "P ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Pendente";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "A ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Em atendimento";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "F ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Finalizado";
                    }
                }

                //Validação para mudança de valores no grid referente a prioridade do chamado
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Prioridade"].ToString() == "0 ")
                    {
                        dt.Rows[i]["Prioridade"] = "Alta";
                    }

                    if (dt.Rows[i]["Prioridade"].ToString() == "1 ")
                    {
                        dt.Rows[i]["Prioridade"] = "Média";
                    }

                    if (dt.Rows[i]["Prioridade"].ToString() == "2 ")
                    {
                        dt.Rows[i]["Prioridade"] = "Baixa";
                    }
                }

                GrdChamados.DataBind();
            }
        }
Example #4
0
        protected void GrdChamados_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            DataTable   dt          = new DataTable();
            ChamadosBLL chamadosBLL = new ChamadosBLL();
            Usuario     usuario     = null;

            usuario = (Usuario)Session["objetoUsuario"];

            dt = chamadosBLL.GetChamados(usuario);
            GrdChamados.DataSource = dt;
            GrdChamados.PageIndex  = e.NewPageIndex;

            if (dt.Rows.Count > 0)
            {
                GrdChamados.DataSource = dt;

                //Validação para mudança de valores no grid referente a status do chamado
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["StatusChamado"].ToString() == "P ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Pendente";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "A ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Em atendimento";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "F ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Finalizado";
                    }
                }

                //Validação para mudança de valores no grid referente a prioridade do chamado
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Prioridade"].ToString() == "A ")
                    {
                        dt.Rows[i]["Prioridade"] = "Alta";
                    }

                    if (dt.Rows[i]["Prioridade"].ToString() == "M ")
                    {
                        dt.Rows[i]["Prioridade"] = "Média";
                    }

                    if (dt.Rows[i]["Prioridade"].ToString() == "B ")
                    {
                        dt.Rows[i]["Prioridade"] = "Baixa";
                    }
                }

                GrdChamados.DataBind();
            }
        }
        protected void btnCarregar_Click(object sender, EventArgs e)
        {
            cm.IdChamado = Convert.ToInt32(txtIdCha.Text);

            List <ChamadosModel> listChamados = new List <ChamadosModel>();

            listChamados = cb.ConsultaChamado(cm);

            GrdChamados.DataSource = listChamados;
            GrdChamados.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Session["IdUsuario"] != null)
                {
                    if (Session["StatusChamadoFA"] != null)
                    {
                        ScriptManager.RegisterClientScriptBlock(GrdChamados, GrdChamados.GetType(), "msgSucesso", "alert('Chamado enviado com sucesso aguarde a aprovação.');", true);
                        Session.Remove("StatusChamadoFA");
                    }

                    CarregaChamados(Convert.ToInt32(Session["IdUsuario"].ToString()));
                }

                else
                {
                    Session.RemoveAll();
                    Response.Redirect("~/Conta");
                }
            }
        }
        protected void CarregaChamados(int IdUsuario)
        {
            DataTable   dt          = new DataTable();
            ChamadosBLL chamadosBLL = new ChamadosBLL();

            dt = chamadosBLL.ListaChamadosPorId(Convert.ToInt32(Session["IdUsuario"].ToString()));

            GrdChamados.DataSource = dt;

            //Validação para mudança de valores no grid referente a status do chamado

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["StatusChamado"].ToString() == "P ")
                {
                    dt.Rows[i]["StatusChamado"] = "Pendente";
                }

                if (dt.Rows[i]["StatusChamado"].ToString() == "A ")
                {
                    dt.Rows[i]["StatusChamado"] = "Em atendimento";
                }

                if (dt.Rows[i]["StatusChamado"].ToString() == "FA")
                {
                    dt.Rows[i]["StatusChamado"] = "Aguardando Aprovação";
                }

                if (dt.Rows[i]["StatusChamado"].ToString() == "F ")
                {
                    dt.Rows[i]["StatusChamado"] = "Finalizado";
                }
            }

            //Validação para mudança de valores no grid referente a prioridade do chamado

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (dt.Rows[i]["Prioridade"].ToString() == "A ")
                {
                    dt.Rows[i]["Prioridade"] = "Alta";
                }

                if (dt.Rows[i]["Prioridade"].ToString() == "M ")
                {
                    dt.Rows[i]["Prioridade"] = "Média";
                }

                if (dt.Rows[i]["Prioridade"].ToString() == "B ")
                {
                    dt.Rows[i]["Prioridade"] = "Baixa";
                }
            }

            GrdChamados.DataBind();

            if (dt.Rows.Count < 1)
            {
                //Oculta filtro de chamados
                Label lblOrdenar = (Label)Master.FindControl("LblOrdenar");
                lblOrdenar.Visible = false;

                DropDownList drpFiltro = (DropDownList)Master.FindControl("drpPrioridade");
                drpFiltro.Visible = false;

                //Exibe mensagem
                LblMsgmChamados.Text    = "Você não possui chamados em atendimento no momento";
                LblMsgmChamados.Visible = true;
            }

            else
            {
                //Exibe mensagem
                LblMsgmChamados.Text    = "Existem" + " " + Convert.ToString(dt.Rows.Count.ToString()) + " " + "chamados abertos no momento";
                LblMsgmChamados.Visible = true;
            }
        }
        protected void CarregaChamadosPorPalavraChave(string palavraChave)
        {
            DataTable   dt          = new DataTable();
            ChamadosBLL chamadosBLL = new ChamadosBLL();

            dt = chamadosBLL.GetChamadosPorPalavra(palavraChave);

            if (dt.Rows.Count > 0)
            {
                GrdChamados.DataSource = dt;

                //Validação para mudança de valores no grid referente a status do chamado
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["StatusChamado"].ToString() == "P ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Pendente";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "A ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Em atendimento";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "FA")
                    {
                        dt.Rows[i]["StatusChamado"] = "Aguardando Aprovação";
                    }

                    if (dt.Rows[i]["StatusChamado"].ToString() == "F ")
                    {
                        dt.Rows[i]["StatusChamado"] = "Finalizado";
                    }
                }

                //Validação para mudança de valores no grid referente a prioridade do chamado
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["Prioridade"].ToString() == "A ")
                    {
                        dt.Rows[i]["Prioridade"] = "Alta";
                    }

                    if (dt.Rows[i]["Prioridade"].ToString() == "M ")
                    {
                        dt.Rows[i]["Prioridade"] = "Média";
                    }

                    if (dt.Rows[i]["Prioridade"].ToString() == "B ")
                    {
                        dt.Rows[i]["Prioridade"] = "Baixa";
                    }
                }

                GrdChamados.DataBind();
            }

            else
            {
                //Oculta filtro de chamados
                Label lblOrdenar = (Label)Master.FindControl("LblOrdenar");
                lblOrdenar.Visible = false;

                DropDownList drpFiltro = (DropDownList)Master.FindControl("drpPrioridade");
                drpFiltro.Visible = false;
            }

            //Exibe mensagem com número de resultados encontrados
            LblMsgmChamados.Text = "Sua pesquisa retornou" + " " + Convert.ToString(dt.Rows.Count.ToString()) + " " + "resultados";
            //Exibe mensagem
            LblMsgmChamados.Visible = true;
        }