private void btn_imprimir_Click(object sender, EventArgs e) { if (dgv_detalle.Rows.Count >= 1) { if (res == null && chk_Venta_Rapida.Checked == true || res != null && chk_Venta_Rapida.Checked == false) { List <DetalleFactura> detalle = new List <DetalleFactura>(); Factura fact = new Factura(); Persona per = new Persona(); Estado est = new Estado(); if (chk_Venta_Rapida.Checked == true) { per.idPersona = 17; } else { per.idPersona = res.idPersona; } fact.cliente = per; fact.fechaCreacion = DateTime.Now.Date; est.idEstado = 27; fact.estado = est; fact.importeTotal = int.Parse(txt_monto_total.Text); fact.tipoFactura = char.Parse(cmb_tipo_factura.Text); fact.totalIVA = double.Parse(txt_totalIva.Text); for (int c = 0; c < dgv_detalle.RowCount; c++) { DetalleFactura de = new DetalleFactura(); Producto p = new Producto(); p.idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value; de.subTotal = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value; de.cantidad = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value); de.iva = Convert.ToDouble(dgv_detalle.Rows[c].Cells["iva"].Value); de.producto = p; detalle.Add(de); } fact.detalleFactura = detalle; try { //iniciador.idFactura = FacturaDAO.InsertFacturaDirecta(fact); MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); btn_guardar.Enabled = false; } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } Emitir_Factura factura = new Emitir_Factura(); factura.ShowDialog(); btn_nuevo_Click(sender, e); } } EmitirPresupuesto emitir = new EmitirPresupuesto(); emitir.ShowDialog(); }
private void dgv_pedidos_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgv_pedidos.CurrentCell is DataGridViewButtonCell) { int idPedido = Convert.ToInt32(dgv_pedidos.Rows[dgv_pedidos.CurrentRow.Index].Cells["idPedido"].Value); int estadoDesde = Convert.ToInt32(dgv_pedidos.Rows[dgv_pedidos.CurrentRow.Index].Cells["idestado"].Value); int estadoHasta = estadoDesde; switch (estadoDesde) { case 2: estadoHasta = 5; if (tieneProductosFinalizados()) { try { PedidoDAO.UpdateEstados(idPedido, estadoHasta); MessageBox.Show("Fin Preparación ", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); cargarGrilla(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { MessageBox.Show("Faltan Productos Por Preparar ", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } break; case 5: estadoHasta = 6; //Abrir Interface de Factura int idPed = (int)dgv_pedidos.CurrentRow.Cells["idPedido"].Value; RegistrarFactura factura = new RegistrarFactura(); factura._idPedido = idPed; factura.ShowDialog(); //Si se registro la factura hacer if (factura._estado==estados.guardado) { try { //PedidoDAO.UpdateEstados(idPedido, estadoHasta); MessageBox.Show("Factura Registrada", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); cargarGrilla(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } Emitir_Factura fact = new Emitir_Factura(); fact.ShowDialog(); } break; case 6: estadoHasta = 7; if (pagaronLaFactura(idPedido)) { try { for (int i = 0; i < dgv_detalle_pedido.Rows.Count; i++) { DetallePedido det = new DetallePedido(); det.producto = new Producto() { idProducto = (int)dgv_detalle_pedido.Rows[i].Cells["idProd"].Value }; det.cantidad = (double)dgv_detalle_pedido.Rows[i].Cells["cant"].Value; ProductoDAO.UpdateStockReservadoYActualdePedidoEntregado(det, idPedido, estadoHasta); } MessageBox.Show("Registro de Entrega Completado ", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); cargarGrilla(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { MessageBox.Show("Falta el Pago de la Factura ", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } break; } } }
private void dgv_pedidos_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgv_pedidos.CurrentCell is DataGridViewButtonCell) { int idPedido = Convert.ToInt32(dgv_pedidos.Rows[dgv_pedidos.CurrentRow.Index].Cells["idPedido"].Value); int estadoDesde = Convert.ToInt32(dgv_pedidos.Rows[dgv_pedidos.CurrentRow.Index].Cells["idestado"].Value); int estadoHasta = estadoDesde; switch (estadoDesde) { case 2: estadoHasta = 5; if (tieneProductosFinalizados()) { try { PedidoDAO.UpdateEstados(idPedido, estadoHasta); MessageBox.Show("Fin Preparación ", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); cargarGrilla(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { MessageBox.Show("Faltan Productos Por Preparar ", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } break; case 5: estadoHasta = 6; //Abrir Interface de Factura int idPed = (int)dgv_pedidos.CurrentRow.Cells["idPedido"].Value; RegistrarFactura factura = new RegistrarFactura(); factura._idPedido = idPed; factura.ShowDialog(); //Si se registro la factura hacer if (factura._estado == estados.guardado) { try { //PedidoDAO.UpdateEstados(idPedido, estadoHasta); MessageBox.Show("Factura Registrada", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); cargarGrilla(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } Emitir_Factura fact = new Emitir_Factura(); fact.ShowDialog(); } break; case 6: estadoHasta = 7; if (pagaronLaFactura(idPedido)) { try { for (int i = 0; i < dgv_detalle_pedido.Rows.Count; i++) { DetallePedido det = new DetallePedido(); det.producto = new Producto() { idProducto = (int)dgv_detalle_pedido.Rows[i].Cells["idProd"].Value }; det.cantidad = (double)dgv_detalle_pedido.Rows[i].Cells["cant"].Value; ProductoDAO.UpdateStockReservadoYActualdePedidoEntregado(det, idPedido, estadoHasta); } MessageBox.Show("Registro de Entrega Completado ", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); cargarGrilla(); } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } else { MessageBox.Show("Falta el Pago de la Factura ", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); } break; } } }
private void btn_imprimir_Click(object sender, EventArgs e) { if (dgv_detalle.Rows.Count >= 1) { if (res == null && chk_Venta_Rapida.Checked == true || res != null && chk_Venta_Rapida.Checked == false) { List<DetalleFactura> detalle = new List<DetalleFactura>(); Factura fact = new Factura(); Persona per = new Persona(); Estado est = new Estado(); if (chk_Venta_Rapida.Checked == true) { per.idPersona = 17; } else { per.idPersona = res.idPersona; } fact.cliente = per; fact.fechaCreacion = DateTime.Now.Date; est.idEstado = 27; fact.estado = est; fact.importeTotal = int.Parse(txt_monto_total.Text); fact.tipoFactura = char.Parse(cmb_tipo_factura.Text); fact.totalIVA = double.Parse(txt_totalIva.Text); for (int c = 0; c < dgv_detalle.RowCount; c++) { DetalleFactura de = new DetalleFactura(); Producto p = new Producto(); p.idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value; de.subTotal = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value; de.cantidad = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value); de.iva = Convert.ToDouble(dgv_detalle.Rows[c].Cells["iva"].Value); de.producto = p; detalle.Add(de); } fact.detalleFactura = detalle; try { //iniciador.idFactura = FacturaDAO.InsertFacturaDirecta(fact); MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1); btn_guardar.Enabled = false; } catch (ApplicationException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } Emitir_Factura factura = new Emitir_Factura(); factura.ShowDialog(); btn_nuevo_Click(sender, e); } } EmitirPresupuesto emitir = new EmitirPresupuesto(); emitir.ShowDialog(); }