private void dgv_OTproductosPadres_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgv_OTproductosPadres.CurrentCell is DataGridViewButtonCell) { if (dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].DefaultCellStyle.BackColor != Color.LightGreen) { if (tieneHijosFinalizados() == true) { try { double cant = (double)dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["cantidad"].Value; if (dgv_OTproductosPadres.CurrentRow.Cells["cantiReal"].Value != String.Empty) { double cantidadPlan = 0; double cantidadPedido = DetallePlanProduccionDAO.GetCantidadPedidosParaOT((int)dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["idProducto"].Value, Convert.ToDateTime(dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["fechaCreacion"].Value)); cantidadPlan = cant - cantidadPedido; DateTime fecha = Convert.ToDateTime(dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["fechaCreacion"].Value); OrdenDeTrabajo orden = new OrdenDeTrabajo(); orden.idOrdenTrabajo = int.Parse(dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["idOrden"].Value.ToString()); Producto prod = new Producto(); prod.idProducto = int.Parse(dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["idProducto"].Value.ToString()); prod.Nombre = dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["nomProducto"].Value.ToString(); UnidadMedida unidad = new UnidadMedida(); unidad.Nombre = dgv_OTproductosPadres.Rows[dgv_OTproductosPadres.CurrentRow.Index].Cells["unidad"].Value.ToString(); prod.Unidad = unidad; orden.fechaCreacion = fecha; orden.producto = prod; orden.cantidad = cant; ActualizarStock act = new ActualizarStock(orden, cantidadPedido, cantidadPlan); act.ShowDialog(); if (orden.estado != null) { if (orden.estado.Nombre == "LISTO") { MessageBox.Show("Finalizado con éxito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); dgv_OTproductosPadres.CurrentRow.DefaultCellStyle.BackColor = Color.LightGreen; dgv_OTproductosPadres.CurrentRow.Cells["cantiReal"].Value = orden.cantidadReal; cargarGrilla(); } } } } catch (FormatException ex) { MessageBox.Show("Ingrese solo números", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { MessageBox.Show("Primero debe Finalizar las Ordenes de Trabajo de los Productos Intermedios", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } } }