private void getProjetos(int cod) { agEntities ctx = new agEntities(); projeto gu = ctx.projetoes.First(p => p.id == cod); nome.Text = gu.nome; }
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); } } }
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); } } }
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; } } }
protected void btnExcluir_Click(object sender, EventArgs e) { if (Session["perfil"].ToString() != "Administrador") { ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "acessoNegado();", true); } else { try { usuarioID = int.Parse((sender as LinkButton).CommandArgument); agEntities ctx = new agEntities(); usuario user = ctx.usuarios.First(p => p.id == usuarioID); ctx.usuarios.Remove(user); ctx.SaveChanges(); getUsuarios(); ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true); } catch (Exception) { ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true); //throw; } } }
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; } } }
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); } } }
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; } } }
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")); }
private void GetProjetos() { agEntities ctx = new agEntities(); var resultado = (from a in ctx.projetoes orderby a.nome select new { a.id, a.nome, }); GridView1.DataSource = resultado.ToList(); GridView1.DataBind(); }
private void getAGs() { agEntities ctx = new agEntities(); var resultado = (from a in ctx.ags join b in ctx.projetoes on a.projetoID equals b.id select new { a.id, a.numero, b.nome, }); GridView1.DataSource = resultado.ToList(); GridView1.DataBind(); }
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); } }
private void getUsuarios(int cod) { agEntities ctx = new agEntities(); usuario user = ctx.usuarios.First(p => p.id == cod); nome.Text = user.nome; email.Text = user.emaill; login.Text = user.login; // senha.Text = user.senha; cboxPerfil.SelectedValue = user.perfil; cboxProjeto.SelectedValue = Convert.ToString(user.projetoID); imgSel.ImageUrl = "dist/img/users/" + user.img; lblCaminhoImg.Text = user.img; cargo.Text = user.cargo; }
private void getUsuarios(int cod) { agEntities ctx = new agEntities(); usuario user = ctx.usuarios.First(p => p.id == cod); nome.Text = user.nome; email.Text = user.emaill; login.Text = user.login; senha.Text = user.senha; cboxPerfil.SelectedValue = user.perfil; cargo.Text = user.cargo; // projeto gr = ctx.projetoes.First(p => p.id == user.projetoID); //string gru = gr.nome; //cboxProjeto.Items.Insert(0, new ListItem(gru, "1")); imgSel.ImageUrl = "dist/img/users/" + user.img; }
protected void btnSalvar_Click(object sender, EventArgs e) { if (nome.Text == "") { mensagem = "O Campo Nome é obrigatório"; ClientScript.RegisterStartupScript(GetType(), "Popup", "NotificacaoErro();", true); nome.Focus(); } else { try { string senhaCriptografada = Criptografia.CalculaHash(password); agEntities ctx = new agEntities(); usuario user = new usuario(); user.nome = nome.Text.Trim(); user.emaill = email.Text.Trim(); user.login = login.Text.Trim(); user.senha = senhaCriptografada; user.perfil = cboxPerfil.SelectedValue; user.projetoID = int.Parse(cboxProjeto.SelectedValue); user.img = lblCaminhoImg.Text.Trim(); user.cargo = cargo.Text.Trim(); ctx.usuarios.Add(user); ctx.SaveChanges(); ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true); nome.Text = string.Empty; email.Text = string.Empty; login.Text = string.Empty; senha.Text = string.Empty; cboxPerfil.SelectedIndex = -1; cboxProjeto.SelectedIndex = -1; } catch (Exception ex) { mensagem = "Ocorreu o seguinte erro ao gravar :" + ex.Message; ClientScript.RegisterStartupScript(GetType(), "Popup", "erro();", true); throw; } } }
private void getUsuarios() { agEntities ctx = new agEntities(); var resultado = (from a in ctx.usuarios orderby a.nome ascending join b in ctx.projetoes on a.projetoID equals b.id select new { a.id, a.nome, a.emaill, a.login, a.senha, a.perfil, projeto = b.nome, a.img, }); GridView1.DataSource = resultado.ToList(); GridView1.DataBind(); }
protected void btnSalvar_Click(object sender, EventArgs e) { if (nome.Text == "") { mensagem = "O Campo Nome é obrigatório"; ClientScript.RegisterStartupScript(GetType(), "Popup", "NotificacaoErro();", true); nome.Focus(); } else { try { int cod = int.Parse(usuarioID); string senhaCriptografada = Criptografia.CalculaHash(password); agEntities ctx = new agEntities(); usuario user = ctx.usuarios.First(p => p.id == cod); user.nome = nome.Text.Trim(); user.emaill = email.Text.Trim(); user.login = login.Text.Trim(); if (password != string.Empty) { user.senha = senhaCriptografada; } user.perfil = cboxPerfil.SelectedValue; user.projetoID = int.Parse(cboxProjeto.SelectedValue); user.img = lblCaminhoImg.Text; user.cargo = cargo.Text; ctx.SaveChanges(); ClientScript.RegisterStartupScript(GetType(), "Popup", "sucesso();", true); } catch (System.Exception ex) { mensagem = "Erro ao Editar " + ex.Message; ClientScript.RegisterStartupScript(GetType(), "Popup", "NotificacaoErro();", true); } } }
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"); } }