//BUsqueda en celda void text_KeyUp(object sender, KeyEventArgs e) { rowIndex = ((DataGridViewTextBoxEditingControl)(sender)).EditingControlRowIndex; if (e.KeyCode == Keys.Delete) { this.QuitarElemento(rowIndex); } if (e.Control && e.KeyCode == Keys.B) { this.BuscarElemento(); DataGVProductos.EndEdit(); FlagBusqProd = 1; } if (e.KeyCode == Keys.Tab) { if (FlagBusqProd == 0) { string valueEntered = DataGVProductos.Rows[rowIndex].Cells["Codigo"].Value.ToString(); this.BuscarCodigoProductoby("ProCod", valueEntered.ToString(), rowIndex); FlagBusqProd = 1; DataGVProductos.EndEdit(); //this.AgregarElemento(rowIndex); } } if (FlagBusqProd == 1) { CalculaPreciototalProducto(); } }
private void CalculaPreciototalProducto() { int total = Convert.ToInt32(DataGVProductos.Rows[rowIndex].Cells["Cantidad"].Value) * Convert.ToInt32(DataGVProductos.Rows[rowIndex].Cells["PrecioUnitario"].Value); DataGVProductos.Rows[rowIndex].Cells["Precio"].Value = total.ToString(); DataGVProductos.EndEdit(); }
private void DataGVProductos_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (DataGVProductos.Rows[rowIndex].Cells["Codigo"].Value != null) //x si se apreta cualquier tecla y el codigo esta vacio { if (FlagBusqProd == 0) // Primero Buca { string valueEntered = DataGVProductos.Rows[rowIndex].Cells["Codigo"].Value.ToString(); this.BuscarCodigoProductoby("ProCod", valueEntered.ToString(), rowIndex); FlagBusqProd = 1; DataGVProductos.EndEdit(); //this.AgregarElemento(rowIndex); } } } if (FlagBusqProd == 1)//Luego calcula el precio de lo que busco { CalculaPreciototalProducto(); } }