예제 #1
0
    protected void btnAcao_Click(object sender, System.EventArgs e)
    {
        t24_agenda t24 = new t24_agenda();
        {
            bool result = false;
            bool erro = false;
            string msg = "";
            t24.t03_cd_projeto = pb.cd_projeto();
            t24.nm_agenda = "";
            t24.ds_agenda = pb.ReplaceAspas(txtds_agenda.Text);
            t24.dt_data = DateTime.Parse(txtdt_data.Text);
            t24.dt_cadastro = DateTime.Now;
            t24.dt_alterado = DateTime.Now;

            if (!(erro))
            {
                if (cod.Value != "0")
                {
                    t24.t24_cd_agenda = Int32.Parse(cod.Value);
                    result = t24.Update();
                    msg = pb.Message("Alteração realizada com sucesso!", "ok");
                    pb.saveLog(pb.cd_usuario(), pb.cd_projeto(), "", "t24_agenda", "update", cod.Value);
                }
                else
                {
                    result = t24.Save();
                    msg = pb.Message("Cadastro realizado com sucesso!", "ok");
                    pb.saveLog(pb.cd_usuario(), pb.cd_projeto(), "", "t24_agenda", "insert", t24.ds_agenda);
                }

                if (result)
                {
                    Ocultar();
                    GridBind();
                    cod.Value = "0";
                }
            }
            lblMsg.Text = msg;
            lblMsg.Visible = true;
        }
    }
예제 #2
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            GridView gv = (GridView)sender;
            if (e.CommandName != "Sort")
            {
                int cd = Int32.Parse(gv.DataKeys[Int32.Parse(e.CommandArgument.ToString())].Value.ToString());
                switch (e.CommandName)
                {
                    case "Selecionar":
                        t24_agenda t24 = new t24_agenda();
                        {
                            t24.t24_cd_agenda = cd;
                            t24.Retrieve();
                            if (t24.Found)
                            {
                                Session["cd_projeto"] = t24.t03_cd_projeto;
                                Response.Redirect("Arvore.aspx");
                            }
                        }
                        break;
                    case "Editar":
                        Exibir();
                        this.lblHeader.Text = "Alteração";
                        this.btnAcao.Text = "Alterar";
                        cod.Value = cd.ToString();
                        Retrieve();

                        break;
                    case "Deletar":
                        t24 = new t24_agenda();
                        {
                            t24.t24_cd_agenda = cd;
                            t24.Delete();
                            pb.saveLog(pb.cd_usuario(), pb.cd_projeto(), "", "t24_agenda", "delete", t24.t24_cd_agenda.ToString());
                        }
                        GridBind();
                        lblMsg.Text = pb.Message("Exclusão realizada com sucesso!", "ok");
                        lblMsg.Visible = true;
                        break;
                }
            }
        }
        catch { }
    }
예제 #3
0
 private void Retrieve()
 {
     t24_agenda t24 = new t24_agenda();
     {
         t24.t24_cd_agenda = Int32.Parse(cod.Value);
         t24.Retrieve();
         if (t24.Found)
         {
             txtds_agenda.Text = t24.ds_agenda;
             txtdt_data.Text = t24.dt_data.ToShortDateString();
         }
     }
 }
예제 #4
0
    private void GridBind()
    {
        t24_agenda t24 = new t24_agenda();
        {
            string query = "";
            if (pb.fl_admin() || pb.fl_visitante() || pb.fl_estrategico())
            {
                //query = " where t04_cd_tipologia=" + dr["t04_cd_tipologia"].ToString() + " and fl_ativa=1";
            }
            else //se usuário sem perfil e diferente de visitante
            {
                if (pb.cd_parceiro() != 0) //parceiro
                {
                    query = " and t03_cd_projeto in " +
                        "(select t03_cd_projeto from t03_projeto where fl_ativa=1 and t01_cd_entidade in " +
                        "(select t01_cd_entidade from t05_parceiro where t05_cd_parceiro=" + pb.cd_parceiro() + ")) ";
                }
                else //administrador parceiro
                {
                    query = " and t03_cd_projeto in (select t03_cd_projeto from t03_projeto where fl_ativa=1 and t01_cd_entidade=" + pb.cd_entidade() + ")";
                }

            }
            if (projetos)
            {
                t24.order = query + " order by " + ViewState["campo"].ToString() + " " + ViewState["sentido"].ToString();
                GridView1.DataSource = t24.ListProjetos();
                PanelAdd.Visible = false;
                GridView1.Columns[0].Visible = false;
                GridView1.Columns[1].Visible = false;
            }
            else
            {
                t24.t03_cd_projeto = pb.cd_projeto();
                t24.order = "order by " + ViewState["campo"].ToString() + " " + ViewState["sentido"].ToString();
                GridView1.DataSource = t24.List();
            }
            GridView1.DataBind();
        }
    }