private void llenarDatagrid() { ServicioPedido servicio = new ServicioPedido(); pedidosPendientes = servicio.ConsultarPorEstado("Pendiente"); TablaPendientes.AutoGenerateColumns = false; if (pedidosPendientes == null || pedidosPendientes.Count == 0) { MessageBox.Show("Por el momento no hay pedidos pendientes", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { limpiarDatagridView(TablaPendientes); foreach (Pedido p in pedidosPendientes) { TablaPendientes.Rows.Add(p.Codigo, p.FechaGeneracion.Date.ToString("dd/MM/yyyy"), p.FechaEntrega.Date.ToString("dd/MM/yyyy"), p.Cliente, p.Total.ToString("C"), p.descuento.ToString("C"), p.Adelanto.ToString("C"), p.Pendiente.ToString("C")); } } }
private void btnEntregar_Click(object sender, EventArgs e) { ServicioPedido servicio = new ServicioPedido(); for (int i = 0; i < TablaPendientes.Rows.Count; i++) { bool entregado = Convert.ToBoolean(TablaPendientes["Entregar", i].Value); if (entregado == true) { Pedido pedido = new Pedido(); pedido = pedidosPendientes.Find(x => x.Codigo == Convert.ToInt16(TablaPendientes.CurrentRow.Cells["Codigo"].Value.ToString())); pedido.Estado = "Entregado"; string respuesta = servicio.ConfirmarPedido(pedido); if (respuesta == "Existencias") { MessageBox.Show("Hay inconvenientes con los productos del pedido\n" + "No hay productos suficientes", "Cuidado", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (respuesta == "Error") { MessageBox.Show("Ha ocurrido un error interno del sistema", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { llenarDatagrid(); MessageBox.Show("El pedido se ha entregado con exito", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } }