示例#1
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            Peca peca = getDataPeca();
            var  db   = new PecaDB();

            if (db.Insert(peca))
            {
                lblMSG1.Text = "Registro inserido!";
            }
            LoadGrid();
        }
示例#2
0
        protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            int         index = Convert.ToInt32(e.CommandArgument);
            GridViewRow row   = GridView1.Rows[index];

            int    id         = Convert.ToInt32(row.Cells[0].Text);
            String ididstring = Convert.ToString(row.Cells[0].Text);
            var    db         = new PecaDB();

            if (e.CommandName == "EXCLUIR")
            {
                db.Delete(id);
                LoadGrid();
            }
            else if (e.CommandName == "ALTERAR")
            {
                Peca peca = db.SelectById(id);

                txtID.Text        = ididstring;
                txtTipo.Text      = peca.Tipo;
                txtMarca.Text     = peca.Marca;
                txtDescricao.Text = peca.Descricao;
            }
        }