Пример #1
0
 protected void btnExcluir_Click(object sender, EventArgs e)
 {
     if (Session["perfil"].ToString() != "Administrador")
     {
         ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "acessoNegado();", true);
     }
     else
     {
         try
         {
             int        cod = Convert.ToInt32((sender as LinkButton).CommandArgument);
             agEntities ctx = new agEntities();
             projeto    gu  = ctx.projetoes.First(p => p.id == cod);
             ctx.projetoes.Remove(gu);
             ctx.SaveChanges();
             ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true);
             GetProjetos();
         }
         catch (Exception)
         {
             ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true);
             //throw;
         }
     }
 }
Пример #2
0
        private void getProjetos(int cod)
        {
            agEntities ctx = new agEntities();
            projeto    gu  = ctx.projetoes.First(p => p.id == cod);

            nome.Text = gu.nome;
        }
Пример #3
0
 protected void btnSalvar_Click(object sender, EventArgs e)
 {
     if (nome.Text == "")
     {
         mensagem = "Campo Nome é obrigatorio";
         ClientScript.RegisterStartupScript(GetType(), "Popup", "erroGeral();", true);
         nome.Focus();
     }
     else
     {
         try
         {
             agEntities ctx = new agEntities();
             projeto    gu  = new projeto();
             gu.nome = nome.Text.Trim();
             ctx.projetoes.Add(gu);
             ctx.SaveChanges();
             ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true);
         }
         catch (Exception ex)
         {
             mensagem = "Ocorreu o seguinte erro ao tentar gravar: " + ex.Message;
             ClientScript.RegisterStartupScript(GetType(), "Popup", "erroGeral();", true);
         }
     }
 }
Пример #4
0
 protected void btnEditar_Click(object sender, EventArgs e)
 {
     if (nome.Text == "")
     {
         mensagem = "Campo Nome é obrigatorio";
         ClientScript.RegisterStartupScript(GetType(), "Popup", "erroGeral();", true);
         nome.Focus();
     }
     else
     {
         try
         {
             int        cod = int.Parse(projetoID);
             agEntities ctx = new agEntities();
             projeto    gu  = ctx.projetoes.First(p => p.id == cod);
             gu.nome = nome.Text.Trim();
             ctx.SaveChanges();
             ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true);
         }
         catch (Exception)
         {
             ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true);
             throw;
         }
     }
 }
Пример #5
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"));
        }
Пример #6
0
        protected void btnEntrar_Click(object sender, EventArgs e)
        {
            MySqlConnection con = new MySqlConnection(conecLocal);

            con.Open();
            if (usuario.Text.Trim() == "" || senha.Text.Trim() == "" || senha.Text == string.Empty)
            {
                mensagem = "Favor informar Usuário e senha para login!!";
                ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true);
            }
            else
            {
                try
                {
                    string           senhaCriptografada = Criptografia.CalculaHash(password);
                    string           sql = "Select * from ag.usuario where login='******' and senha='" + senhaCriptografada + "'";
                    MySqlCommand     cmd;
                    DataTable        dt = new DataTable();
                    MySqlDataAdapter da = new MySqlDataAdapter();
                    cmd = new MySqlCommand(sql, con);
                    da.SelectCommand = cmd;
                    da.Fill(dt);

                    if (dt.Rows.Count != 0)
                    {
                        Session.Count.ToString();
                        Session.Timeout      = 10;
                        Session["logado"]    = "SIM";
                        Session["nome"]      = dt.Rows[0][1].ToString();
                        Session["perfil"]    = dt.Rows[0][5].ToString();
                        Session["img"]       = dt.Rows[0][6].ToString();
                        Session["cargo"]     = dt.Rows[0][7].ToString();
                        Session["id"]        = dt.Rows[0][0].ToString();
                        Session["projetoID"] = dt.Rows[0][8].ToString();
                        int projetoID = Convert.ToInt32(dt.Rows[0][8].ToString());
                        dt.Dispose();
                        logado = 1;
                        Session.Count.ToString();

                        agEntities ctx = new agEntities();
                        projeto    pr  = ctx.projetoes.First(p => p.id == projetoID);
                        Session["projetoNome"] = pr.nome;
                    }
                    else
                    {
                        Session["logado"] = "NAO";
                        mensagem          = "Usuário ou senha Inválidos!!";
                        logado            = 0;
                        ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true);
                    }
                }
                catch (Exception ex)
                {
                    mensagem = "Ocorreu o seguinte erro: " + ex.Message;
                    ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true);
                }
                finally
                {
                    con.Close();
                }
            }
            if (logado == 1)
            {
                Response.Redirect("home.aspx");
            }
        }