private void BtnNuevoArt_Click(object sender, EventArgs e) { AddArticulo frm = new AddArticulo(dataGridView1, editar); frm.ShowDialog(); dataGridView1.Rows.Clear(); ListaArticulos(); }
/* * private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) * { * editar = true; * if (dataGridView1.SelectedRows.Count > 0) * { * * * AddArticulo frm = new AddArticulo(dataGridView1, editar); //Instanciamos el Form que abriremos * * * frm.txtId.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); * frm.txtCodigo.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString(); * frm.txtDescripcion.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); * frm.txtCosto.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString(); * frm.txtRentabilidad.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString(); * frm.txtPrecio.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString(); * frm.txtL2.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString(); * frm.txtL3.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString(); * frm.cbxIva.Text = dataGridView1.CurrentRow.Cells[8].Value.ToString(); * frm.txtPunto.Text = dataGridView1.CurrentRow.Cells[9].Value.ToString(); * frm.txtStock.Text = dataGridView1.CurrentRow.Cells[10].Value.ToString(); * frm.cbxGrupos.SelectedValue = 2; * frm.cbxMarca.Text = dataGridView1.CurrentRow.Cells[12].Value.ToString(); * frm.cbxProveedor.Text = dataGridView1.CurrentRow.Cells[13].Value.ToString(); * * * frm.ShowDialog(); //Mostramos el Form que deseamos abrir. * * * //ListaArticulos(); * } * else * MessageBox.Show("Seleccione una fila para editar"); * } */ private void BtnNuevoArt_Click(object sender, EventArgs e) { editar = false; AddArticulo frm = new AddArticulo(dataGridView1, editar); frm.ShowDialog(); //Mostramos el Form que deseamos abrir. dataGridView1.Rows.Clear(); dataGridView1.Refresh(); ListaArticulos(); }
private void BtnEditar_Click(object sender, EventArgs e) { editar = true; AddArticulo frm = new AddArticulo(dataGridView1, editar); //Instanciamos el Form que abriremos if (dataGridView1.CurrentCell.RowIndex >= 0) { //id = dataGridView1.CurrentRow.Cells[1].Value.ToString(); frm.txtId.Text = dataGridView1.CurrentRow.Cells[0].Value.ToString(); frm.txtCodigo.Text = dataGridView1.CurrentRow.Cells[1].Value.ToString(); frm.txtDescripcion.Text = dataGridView1.CurrentRow.Cells[2].Value.ToString(); frm.txtCosto.Text = dataGridView1.CurrentRow.Cells[3].Value.ToString(); frm.txtRentabilidad.Text = dataGridView1.CurrentRow.Cells[4].Value.ToString(); frm.txtPrecio.Text = dataGridView1.CurrentRow.Cells[5].Value.ToString(); frm.txtL2.Text = dataGridView1.CurrentRow.Cells[6].Value.ToString(); frm.txtL3.Text = dataGridView1.CurrentRow.Cells[7].Value.ToString(); //frm.cbxIva.SelectedValue = Articulo.IvaEntity.Id; frm.txtPunto.Text = dataGridView1.CurrentRow.Cells[9].Value.ToString(); frm.txtCantidadM.Text = dataGridView1.CurrentRow.Cells[10].Value.ToString(); frm.txtStock.Text = dataGridView1.CurrentRow.Cells[11].Value.ToString(); //frm.cbxGrupos.SelectedValue = Articulo.Grupo.Id; //frm.cbxMarca.SelectedValue = Articulo.Marca.Id; //frm.cbxProveedor.SelectedValue = Articulo.Proveedor.Id; frm.ShowDialog(); //Mostramos el Form que deseamos abrir. dataGridView1.Rows.Clear(); ListaArticulos(); } else { MessageBox.Show("Debe seleccionar una celda"); } }