public void GridLoginCommand(object sender, GridViewCommandEventArgs e) { try { int n = 0; if (int.TryParse(e.CommandArgument.ToString(), out n)) { int index = Convert.ToInt32(e.CommandArgument); string idAcesso = GridViewLogin.DataKeys[index]["IdAcesso"].ToString(); Session["idLogin"] = idAcesso; if (e.CommandName == "Excluir") { Regras.Regras del = new Regras.Regras(); del.DelLoginAcesso(idAcesso); } else if (e.CommandName == "Editar") { Regras.Regras get = new Regras.Regras(); Regras.Dto.DtoAcesso dados = get.GetLoginPorId(int.Parse(idAcesso)); CarregaTela(dados); } CarregarGrid(); } } catch (Exception ex) { AlertVisibleTrue(); AlertError(ex.Message); } }
public void SalvarClick(object sender, EventArgs e) { try { Regras.Dto.DtoAcesso dados = new Regras.Dto.DtoAcesso(); if (!String.IsNullOrWhiteSpace(TextIdAcesso.Text)) { dados.IdAcesso = int.Parse(TextIdAcesso.Text); } dados.Nome = TextNome.Text; dados.Login = TextLogin.Text; dados.Senha = TextSenha.Text; dados.Administrador = CheckBoxAdm.Checked; dados.StatusLogin = CheckBoxStatus.Checked; dados.IdAssociacao = int.Parse(DropDownListAssociacao.SelectedValue); Regras.Regras set = new Regras.Regras(); long idLogin = set.SetAcesso(dados); Session["idLogin"] = idLogin; AlertVisibleTrue(); AlertSucesso(); CarregarGrid(); } catch (Exception ex) { AlertVisibleTrue(); AlertError(ex.Message); } }