Example #1
0
    protected void btnGravarProblema_Click(object sender, EventArgs e)
    {
        String titulo    = txtTitulo.Value;
        String descricao = txtDescricao.Value;
        bool   liberado  = true;

        if (txtTitulo.Value.Equals(""))
        {
            formTitulo.Attributes["class"] = "form-group has-error";
            helpBlockTitulo.InnerText      = "Título é preenchimento obrigatório";
            liberado = false;
        }


        if (txtDescricao.Value.Equals(""))
        {
            formDescricao.Attributes["class"] = "form-group has-error";
            helpBlockDescricao.InnerText      = "Descrição é preenchimento obrigatório";
            liberado = false;
        }

        if (liberado)
        {
            Problema problema = new Problema();

            problema.TituloProblema      = txtTitulo.Value;
            problema.DescricaoProblema   = txtDescricao.Value;
            problema.id_usuario_problema = ((Usuario)Session["UsuarioOnline"]).IdUsuario;

            //decide se vai gravar novo problema ou alterar problema já existent
            if (txtCodigoProblema.Value.Equals(""))
            {
                if (problema.Inserir())
                {
                    alerta.Attributes["class"] = "alert alert-success bottom20"; alerta.InnerText = "Problema Cadastrado com Sucesso."; txtTitulo.Value = ""; txtDescricao.Value = ""; txtCodigoProblema.Value = "";
                }
                else
                {
                    alerta.Attributes["class"] = "alert alert-danger bottom20"; alerta.InnerText = problema.message;
                }
            }
            else
            {
                problema.IdProblema = int.Parse(txtCodigoProblema.Value);
                if (problema.Alterar())
                {
                    alerta.Attributes["class"] = "alert alert-success bottom20"; alerta.InnerText = "Problema Alterado com Sucesso."; txtTitulo.Value = ""; txtDescricao.Value = ""; txtCodigoProblema.Value = "";
                }
                else
                {
                    alerta.Attributes["class"] = "alert alert-danger bottom20"; alerta.InnerText = problema.message;
                }
            }

            carregarProblemas();
        }
    }
Example #2
0
    protected void btnGravarProblema_Click(object sender, EventArgs e)
    {
        String titulo    = txtTitulo.Value;
        String descricao = txtDescricao.Value;
        bool   liberado  = true;

        if (txtTitulo.Value.Equals(""))
        {
            formTitulo.Attributes["class"] = "form-group has-error";
            helpBlockTitulo.InnerText      = "Título é preenchimento obrigatório";
            liberado = false;
        }


        if (txtDescricao.Value.Equals(""))
        {
            formDescricao.Attributes["class"] = "form-group has-error";
            helpBlockDescricao.InnerText      = "Descrição é preenchimento obrigatório";
            liberado = false;
        }

        if (liberado)
        {
            Problema problema = new Problema();

            problema.TituloProblema    = txtTitulo.Value;
            problema.DescricaoProblema = txtDescricao.Value;
            Usuario user = (Usuario)Session["UsuarioOnline"];
            problema.id_usuario_problema = user.IdUsuario;

            if (problema.Inserir())
            {
                alerta.Attributes["class"] = "alert alert-success bottom20"; alerta.InnerText = "Problema Cadastrado com Sucesso."; txtTitulo.Value = ""; txtDescricao.Value = "";
            }
            else
            {
                alerta.Attributes["class"] = "alert alert-danger bottom20"; alerta.InnerText = problema.message;
            }
        }
    }