private void dgvDetalleNota_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { // Verificando la existencia de datos en el datagridview if (dgvDetalleNota.Rows.Count == 0) { MessageBox.Show("No hay un registro seleccionado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } indice = dgvDetalleNota.CurrentRow.Index; // Identificando la fila actual del datagridview int idPresentacion = Convert.ToInt32(dgvDetalleNota.Rows[indice].Cells[3].Value); int idCombinacion = Convert.ToInt32(dgvDetalleNota.Rows[indice].Cells[4].Value); // obteniedo el idRegistro del datagridview currentDetalleNEntrada = buscarElemento(idPresentacion, idCombinacion); // Buscando la registro especifico en la lista de registros cbxCodigoProducto.SelectedValue = currentDetalleNEntrada.idProducto; cbxDescripcion.SelectedValue = currentDetalleNEntrada.idPresentacion; cbxVariacion.Text = currentDetalleNEntrada.nombreCombinacion; txtCantidad.Text = Convert.ToInt32(currentDetalleNEntrada.cantidad).ToString(); txtCantidadRecibida.Text = Convert.ToInt32(currentDetalleNEntrada.cantidadRecibida).ToString(); btnModificar.Enabled = true; btnAgregar.Enabled = false; btnEliminar.Enabled = true; cbxCodigoProducto.Enabled = false; cbxDescripcion.Enabled = false; }
private void btnEliminar_Click(object sender, EventArgs e) { if (dgvDetalleNota.Rows.Count == 0) { MessageBox.Show("No hay un registro seleccionado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } int index = dgvDetalleNota.CurrentRow.Index; // Identificando la fila actual del datagridview int idPresentacion = Convert.ToInt32(dgvDetalleNota.Rows[index].Cells[3].Value); // obteniedo el idRegistro del datagridview CargaCompraSinNota aux = listcargaCompraSinNota.Find(x => x.idPresentacion == idPresentacion); btnAgregar.Enabled = true; btnModificar.Enabled = false; btnEliminar.Enabled = false; dgvDetalleNota.Rows.RemoveAt(index); listcargaCompraSinNota.Remove(aux); limpiarCamposProducto(); }
private void btnModificar_Click(object sender, EventArgs e) { if (dgvDetalleNota.Rows.Count == 0) { MessageBox.Show("No hay un registro seleccionado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } int index = dgvDetalleNota.CurrentRow.Index; // Identificando la fila actual del datagridview int idPresentacion = Convert.ToInt32(dgvDetalleNota.Rows[index].Cells[3].Value); // obteniedo el idRegistro del datagridview CargaCompraSinNota aux = listcargaCompraSinNota.Find(x => x.idPresentacion == idPresentacion); aux.cantidad = toDouble(txtCantidad.Text); aux.cantidadUnitaria = toDouble(txtCantidad.Text); aux.cantidadRecibida = toDouble(txtCantidadRecibida.Text); detalleCompraBindingSource.DataSource = null; detalleCompraBindingSource.DataSource = listcargaCompraSinNota; dgvDetalleNota.Refresh(); btnAgregar.Enabled = true; btnModificar.Enabled = false; btnEliminar.Enabled = false; limpiarCamposProducto(); }
private void btnAgregar_Click(object sender, EventArgs e) { //validando campos if (txtCantidad.Text == "") { txtCantidad.Text = "0"; } if (txtCantidadRecibida.Text == "") { txtCantidadRecibida.Text = "0"; } bool seleccionado = false; if (cbxCodigoProducto.SelectedValue != null) { seleccionado = true; } if (cbxDescripcion.SelectedValue != null) { seleccionado = true; } if (seleccionado) { if (listcargaCompraSinNota == null) { listcargaCompraSinNota = new List <CargaCompraSinNota>(); } CargaCompraSinNota detalleNota = new CargaCompraSinNota(); currentPresentacion = listPresentacion.Find(x => x.idPresentacion == Convert.ToInt32(cbxDescripcion.SelectedValue)); currentDetalleNEntrada = buscarElemento(Convert.ToInt32(cbxDescripcion.SelectedValue), (int)cbxVariacion.SelectedValue); if (currentDetalleNEntrada != null) { MessageBox.Show("Este dato ya fue agregado", "presentacion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } currentProducto = listProducto.Find(x => x.idProducto == currentPresentacion.idProducto); // Creando la lista detalleNota.cantidad = toDouble(txtCantidad.Text.Trim()); /// Busqueda presentacion detalleNota.cantidadUnitaria = toDouble(txtCantidad.Text.Trim()); detalleNota.codigoProducto = currentProducto.codigoProducto; detalleNota.descripcion = cbxDescripcion.Text.Trim(); detalleNota.idCombinacionAlternativa = Convert.ToInt32(cbxVariacion.SelectedValue); detalleNota.idNotaEntrada = 0; detalleNota.idDetalleNotaEntrada = 0; detalleNota.idPresentacion = Convert.ToInt32(cbxDescripcion.SelectedValue); detalleNota.idProducto = Convert.ToInt32(cbxCodigoProducto.SelectedValue); detalleNota.nombreCombinacion = cbxVariacion.Text; detalleNota.nombreMarca = currentProducto.nombreMarca; detalleNota.nombrePresentacion = currentPresentacion.nombrePresentacion; detalleNota.cantidadRecibida = toDouble(txtCantidadRecibida.Text.Trim()); detalleNota.estado = currentPresentacion.estado; // agrgando un nuevo item a la lista listcargaCompraSinNota.Add(detalleNota); // Refrescando la tabla cargaCompraSinNotaBindingSource.DataSource = null; cargaCompraSinNotaBindingSource.DataSource = listcargaCompraSinNota; dgvDetalleNota.Refresh(); // Calculo de totales y subtotales e impuestos limpiarCamposProducto(); } else { MessageBox.Show("Error: elemento no seleccionado", "agregar Elemento", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }