public void cargarModificacion() { PlanMaestroProduccion plan = PlanMaestroProduccionDAO.GetById(planModificar.IDPlanProduccion); dtp_creacion_plan.Value = plan.fechaCreacion; dtp_fecha_inicio.Value = plan.fechaInicio; dtp_fecha_final.Value = plan.fechaFin; txt_observaciones.Text = plan.observaciones; cargarGrillaDetalle(planModificar.IDPlanProduccion); }
private void cargarGrilla() { try { PlanMaestroProduccionDAO.actualizarEstado(); List <PlanMaestroProduccion> planes = PlanMaestroProduccionDAO.GetAll(); dgv_planes.Rows.Clear(); foreach (PlanMaestroProduccion plan in planes) { dgv_planes.Rows.Add(plan.IDPlanProduccion, plan.fechaCreacion, plan.estado.Nombre, plan.fechaInicio, plan.fechaFin); } } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void cargaGrillaFiltros() { DateTime fFdesde = dtp_desde_fin.Value; DateTime fFhasta = dtp_hasta_fin.Value; try { List <PlanMaestroProduccion> planes = PlanMaestroProduccionDAO.GetByFiltros((int)cmb_estado_plan.SelectedValue, fFdesde, fFhasta); dgv_planes.Rows.Clear(); foreach (PlanMaestroProduccion plan in planes) { dgv_planes.Rows.Add(plan.IDPlanProduccion, plan.fechaCreacion, plan.estado.Nombre, plan.fechaInicio, plan.fechaFin); } } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } }
private void btn_guardar_Click(object sender, EventArgs e) { if (estadoFormulario == estados.nuevo) { if (PlanMaestroProduccionDAO.verificarExistenciaPlanParaPeriodo(dtp_fecha_inicio.Value.Date, dtp_fecha_final.Value.Date) == false) { PlanMaestroProduccion plan = new PlanMaestroProduccion() { detallePlan = crearDetalle(), fechaCreacion = dtp_creacion_plan.Value.Date, fechaInicio = dtp_fecha_inicio.Value.Date, fechaFin = dtp_fecha_final.Value.Date, observaciones = txt_observaciones.Text, estado = new Estado() { idEstado = 17 } }; try { List <Producto> productosConPocaMP = new List <Producto>(); PlanMaestroProduccionDAO.Insert(plan, productosConPocaMP); ////////////// MOSTRAR LOS PRODUCTOS CON BAJO STOCK if (productosConPocaMP.Count > 0) { string mensaje = ""; List <Producto> prodConPocoStock = new List <Producto>(); Boolean MPRepetida = false; foreach (Producto Prod in productosConPocaMP) { foreach (Producto P in prodConPocoStock) { if (P.idProducto == Prod.idProducto) { MPRepetida = true; break; } } if (MPRepetida == false) { mensaje += Environment.NewLine + Prod.Nombre.ToString(); prodConPocoStock.Add(Prod); } } MessageBox.Show("Los siguientes productos estan con bajo stock: " + mensaje, "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information); } ///////////////////////////////////////////////////////////// MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); limpiar(); _estado = estados.guardado; } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { MessageBox.Show("Ya Existe un Plan Para ese Periodo", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } } else { PlanMaestroProduccion plan = new PlanMaestroProduccion() { IDPlanProduccion = planModificar.IDPlanProduccion, detallePlan = crearDetalle(), fechaCreacion = dtp_creacion_plan.Value.Date, fechaInicio = dtp_fecha_inicio.Value.Date, fechaFin = dtp_fecha_final.Value.Date, observaciones = txt_observaciones.Text, estado = new Estado() { idEstado = 17 } }; if (estadoFormulario == estados.modificar) { try { List <Producto> productosConPocaMP = new List <Producto>(); PlanMaestroProduccionDAO.Update(plan, desreservar, productosConPocaMP); ////////////// MOSTRAR LOS PRODUCTOS CON BAJO STOCK if (productosConPocaMP.Count > 0) { string mensaje = ""; List <Producto> prodConPocoStock = new List <Producto>(); Boolean MPRepetida = false; foreach (Producto Prod in productosConPocaMP) { foreach (Producto P in prodConPocoStock) { if (P.idProducto == Prod.idProducto) { MPRepetida = true; break; } } if (MPRepetida == false) { mensaje += Environment.NewLine + Prod.Nombre.ToString(); prodConPocoStock.Add(Prod); } } MessageBox.Show("Los siguientes productos estan con bajo stock: " + mensaje, "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information); } ///////////////////////////////////////////////////////////// MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); limpiar(); _estado = estados.guardado; dtp_fecha_inicio.Enabled = true; } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } }