private void btn_Modificar_Click(object sender, EventArgs e) { grd_componentes.Rows.Clear(); grp_componentes.Visible = true; if (this.grid01.Rows.Count == 0) { MessageBox.Show("No selecciono ningun registro de la grilla", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { this.codigo = grid01.CurrentRow.Cells[0].Value.ToString(); DataTable Verificacion = new DataTable(); Verificacion = Producto.Buscar_ProductoPorCodigo(this.codigo); if (Verificacion.Rows.Count > 0) { Panel_BorrarProducto.Visible = true; DataTable tabla = new DataTable(); tabla = Producto.Buscar_ProductoPorCodigo(codigo); txt_codigo.Text = tabla.Rows[0]["codProducto"].ToString(); txt_nombre.Text = tabla.Rows[0]["nombre"].ToString(); txt_Descripcion.Text = tabla.Rows[0]["descripcion"].ToString(); txt_precio.Text = tabla.Rows[0]["precio"].ToString(); txt_stock.Text = tabla.Rows[0]["cantStock"].ToString(); cmb_cuitProveedor.SelectedValue = tabla.Rows[0]["cuitProveedor"].ToString(); txt_productoEq.Text = tabla.Rows[0]["codProductoEq"].ToString(); DataTable tabla_Detalle = new DataTable(); tabla_Detalle = Detalle.RecuperarDetallesProducto(int.Parse(txt_codigo.Text)); if (tabla_Detalle.Rows.Count > 0) { DataTable tabla2 = new DataTable(); for (int i = 0; i < tabla_Detalle.Rows.Count; i++) { tabla2 = Producto.Buscar_ProductoPorCodigo(tabla_Detalle.Rows[i]["codProductoComponente"].ToString()); grd_componentes.Rows.Add(); grd_componentes.Rows[i].Cells[0].Value = tabla_Detalle.Rows[i]["codProductoComponente"].ToString(); grd_componentes.Rows[i].Cells[1].Value = tabla2.Rows[0]["nombre"].ToString(); grd_componentes.Rows[i].Cells[2].Value = tabla_Detalle.Rows[i]["cantidad"].ToString(); grd_componentes.Rows[i].Cells[3].Value = tabla2.Rows[0]["precio"].ToString(); grd_componentes.Rows[i].Cells[4].Value = tabla_Detalle.Rows[i]["precio"].ToString(); } } else { grp_componentes.Visible = false; } } } }
private void Cargar_grilla_Detalle(DataTable tabla) { grd_Detalles.Rows.Clear(); for (int i = 0; i < tabla.Rows.Count; i++) { grd_Detalles.Rows.Add(); grd_Detalles.Rows[i].Cells[0].Value = tabla.Rows[i]["numeroPedido"].ToString(); grd_Detalles.Rows[i].Cells[1].Value = tabla.Rows[i]["codigoProducto"].ToString(); DataTable tabla2 = new DataTable(); tabla2 = Producto.Buscar_ProductoPorCodigo(tabla.Rows[i]["codigoProducto"].ToString()); grd_Detalles.Rows[i].Cells[2].Value = tabla2.Rows[0]["nombre"].ToString(); grd_Detalles.Rows[i].Cells[4].Value = tabla.Rows[i]["cantidad"].ToString(); grd_Detalles.Rows[i].Cells[5].Value = tabla.Rows[i]["precio"].ToString(); } }
private void Cargar_grilla(DataTable tabla) { DataTable tabla2 = new DataTable(); grid01.Rows.Clear(); for (int i = 0; i < tabla.Rows.Count; i++) { tabla2 = Productos.Buscar_ProductoPorCodigo(tabla.Rows[i]["codProductoComponente"].ToString()); grid01.Rows.Add(); grid01.Rows[i].Cells[0].Value = tabla.Rows[i]["codProductoGenerico"].ToString(); grid01.Rows[i].Cells[1].Value = tabla.Rows[i]["codProductoComponente"].ToString(); grid01.Rows[i].Cells[2].Value = tabla2.Rows[0]["nombre"].ToString(); grid01.Rows[i].Cells[3].Value = tabla.Rows[i]["cantidad"].ToString(); grid01.Rows[i].Cells[4].Value = tabla.Rows[i]["precio"].ToString(); } }
private void btn_Modificar_Click(object sender, EventArgs e) { if (this.grid01.Rows.Count == 0) { MessageBox.Show("No selecciono ningun registro de la grilla", "Importante", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } else { Panel_ModificarProducto.Visible = true; this.codigo = grid01.CurrentRow.Cells[0].Value.ToString(); DataTable tabla = new DataTable(); DataTable tabla2 = new DataTable(); tabla = Productos.Buscar_ProductoPorCodigo(codigo); tabla2 = Detalle.RecuperarDetallesProducto(int.Parse(codigo)); if (tabla2.Rows.Count > 0) { btn_ModificarDetalle.Visible = true; } else { btn_ModificarDetalle.Visible = false; } txt_codigo.Text = tabla.Rows[0]["codProducto"].ToString(); txt_nombre.Text = tabla.Rows[0]["nombre"].ToString(); txt_descripcion.Text = tabla.Rows[0]["descripcion"].ToString(); txt_precio.Text = tabla.Rows[0]["precio"].ToString(); txt_cantStock.Text = tabla.Rows[0]["cantStock"].ToString(); cmb_cuitProveedor.SelectedValue = tabla.Rows[0]["cuitProveedor"].ToString(); if (tabla.Rows[0]["codProductoEq"].ToString() == "") { cmb_codProductoEq.SelectedIndex = -1; } else { cmb_codProductoEq.SelectedValue = int.Parse(tabla.Rows[0]["codProductoEq"].ToString()); } } }
private void grid01_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { txt_agregar.Enabled = true; txt_agregar.Text = ""; this.num = grid01.CurrentRow.Cells[0].Value.ToString(); DataTable tabla = new DataTable(); tabla = Producto.Buscar_ProductoPorCodigo(num); txt_codigo.Text = tabla.Rows[0]["codProducto"].ToString(); txt_cantStock.Text = tabla.Rows[0]["cantStock"].ToString(); txt_nombre.Text = tabla.Rows[0]["nombre"].ToString(); }
private void button1_Click_1(object sender, EventArgs e) { DataTable Consulta = new DataTable(); Consulta = Producto.Buscar_ProductoPorCodigo(txt_codProd.Text); if (Consulta.Rows.Count > 0) { Es_DetalleProducto _ED = new Es_DetalleProducto(); _ED.codigoProducto = txt_codProd.Text; _ED.CodigoComponente = cmb_Componente.SelectedValue.ToString(); _ED.cantidad = txt_CantComp.Text; _ED.precio = txt_Subtotal.Text; Detalle.Insertar(_ED); Cargar_grilla(Detalle.RecuperarDetallesProducto(int.Parse(txt_codProd.Text))); txt_CantComp.Text = ""; txt_Precio.Text = ""; txt_Subtotal.Text = ""; } else { MessageBox.Show("Primero debe crear al producto", "Atencion"); } }