Example #1
0
 protected void btnExcluir_Click(object sender, EventArgs e)
 {
     if (Session["perfil"].ToString() != "Administrador")
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "acessoNegado();", true);
     }
     else
     {
         try
         {
             agID = Convert.ToInt32((sender as LinkButton).CommandArgument);
             agEntities ctx = new agEntities();
             ag         gr  = ctx.ags.First(p => p.id == agID);
             ctx.ags.Remove(gr);
             ctx.SaveChanges();
             getAGs();
             ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true);
         }
         catch (Exception ex)
         {
             mensagem = "Não é possível deletar esse registro, pois esta sendo utilizado no cadastro de um ou mais Itens. " + ex.Message;
             ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true);
             //throw;
         }
     }
 }
Example #2
0
 protected void btnSalvar_Click(object sender, EventArgs e)
 {
     if (numeroAG.Text == "")
     {
         mensagem = "Campo Nnumero é obrigatorio";
         ClientScript.RegisterStartupScript(GetType(), "Popup", "erroGeral();", true);
         numeroAG.Focus();
     }
     else
     {
         try
         {
             agEntities ctx     = new agEntities();
             ag         gtronco = new ag();
             gtronco.numero    = numeroAG.Text.Trim();
             gtronco.projetoID = int.Parse(cboxProjeto.SelectedValue);
             ctx.ags.Add(gtronco);
             ctx.SaveChanges();
             numeroAG.Text = "";
             ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true);
         }
         catch (Exception)
         {
             ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true);
         }
     }
 }
Example #3
0
 protected void btnSalvar_Click(object sender, EventArgs e)
 {
     if (numeroAG.Text == "")
     {
         mensagem = "Campo Numero é obrigatorio";
         ClientScript.RegisterStartupScript(GetType(), "Popup", "erroGeral();", true);
         numeroAG.Focus();
     }
     else
     {
         try
         {
             agEntities ctx = new agEntities();
             ag         gr  = ctx.ags.First(g => g.id == agID);
             gr.numero    = numeroAG.Text.Trim();
             gr.projetoID = Convert.ToInt32(cboxProjeto.SelectedValue);
             ctx.SaveChanges();
             ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true);
         }
         catch (Exception)
         {
             ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true);
         }
     }
 }
Example #4
0
        private void buscaAG(int cod)
        {
            agEntities ctx = new agEntities();
            ag         gr  = ctx.ags.First(p => p.id == cod);

            numeroAG.Text = gr.numero;
            string  op = Convert.ToString(gr.projetoID);
            int     pr = int.Parse(op);
            projeto oo = ctx.projetoes.First(p => p.id == pr);
            string  du = oo.nome;

            cboxProjeto.Items.Insert(0, new ListItem(du, "1"));
        }
Example #5
0
 private void buscarAG(int cod)
 {
     try
     {
         agEntities ctx = new agEntities();
         ag         gr  = ctx.ags.First(g => g.id == cod);
         numeroAG.Text             = gr.numero.ToString();
         cboxProjeto.SelectedValue = Convert.ToString(gr.projetoID);
     }
     catch (Exception ex)
     {
         mensagem = "Ocorreu o seguinte erro: " + ex.Message;
         ClientScript.RegisterStartupScript(GetType(), "Popup", "erroGeral();", true);
     }
 }