/*-----------------------------------------Grid-Command---------------------------------------*/ protected void GridMetas_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Excluir")) { //pegar index int _index = int.Parse((String)e.CommandArgument); //pegar a chave string _chave = GridMetas.DataKeys[_index]["IdMeta"].ToString(); //deletar passando chave //gerar dto MetaDTL _dto = new MetaDTL(); _dto.idUsuario = int.Parse(Session["Id"].ToString()); if (!String.IsNullOrEmpty(_chave)) { _dto.idMeta = int.Parse(_chave); } //acessa a build passando a dto MetaBLL _bll = new MetaBLL(); if (_bll.deleteMeta(_dto)) { preencherGrid(); } } }
/*----------------------------------------Grid-FIll-----------------------------------------*/ private void preencherGrid() { MetaBLL meta = new MetaBLL(); MetaDTL metaDTL = new MetaDTL(); metaDTL.idUsuario = int.Parse(Session["Id"].ToString()); GridMetas.DataSource = meta.buscarTodasMetas(metaDTL); GridMetas.DataBind(); }
/*---------------------------------------Button-Envia---------------------------------------*/ protected void BtnEnviaMeta_Click(object sender, EventArgs e) { MetaBLL metasBLL = new MetaBLL(); MetaDTL metas = new MetaDTL(); metas.idUsuario = int.Parse(Session["Id"].ToString()); metas.valorMeta = double.Parse(TbValorMeta.Text); metas.descMeta = TbDescMeta.Text; metas.dataMeta = CalMeta.SelectedDate; metasBLL.insertMeta(metas); preencherGrid(); }
protected void GridMetas_RowUpdating(object sender, GridViewUpdateEventArgs e) { //pegar index int _index = e.RowIndex; MetaDTL meta = new MetaDTL(); string _chave = GridMetas.DataKeys[_index]["IdMeta"].ToString(); GridViewRow row = GridMetas.Rows[_index]; meta.idUsuario = int.Parse(Session["Id"].ToString()); if (!String.IsNullOrEmpty(_chave)) { meta.idMeta = int.Parse(_chave); } meta.descMeta = ((TextBox)(row.Cells[2].Controls[0])).Text; meta.valorMeta = double.Parse(((TextBox)(row.Cells[3].Controls[0])).Text); meta.dataMeta = (row.FindControl("CalGridMeta") as Calendar).SelectedDate; MetaBLL bll = new MetaBLL(); bll.updateMeta(meta); }