private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult opcion;
                opcion = MessageBox.Show("Está seguro de anular el comprobante?", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

                if (opcion == DialogResult.OK)
                {
                    if (this.lblComprobante.Text == "TICKETS")
                    {
                        string rpta = "";
                        rpta = NComprobante.AnularComprobante(Convert.ToInt32(this.lblIdComprobante.Text));
                        if (rpta.Equals("OK"))
                        {
                            MessageBox.Show("Se anuló correctamente");
                            this.MostrarTodo();
                            this.btnEliminar.Enabled = false;
                            this.btnCancelar.Enabled = false;
                        }
                    }
                    else
                    {
                        frmAnularComprobante frm = new frmAnularComprobante();
                        frm.lblBandera.Text = "0";
                        frm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Exemplo n.º 2
0
        private void btnAnular_Click(object sender, EventArgs e)
        {
            frmAnularComprobante frm = new frmAnularComprobante();

            frm.lblBandera.Text = "5";
            frm.Show();
        }
Exemplo n.º 3
0
        private void btnAnular_Click(object sender, EventArgs e)
        {
            try
            {
                string rpta = "";
                if (this.lblEstado.Text == "Pedido Delivery")
                {
                    this.dataDetalle.DataSource = NVenta.mostrarDetalleVenta(Convert.ToInt32(this.lblIdVenta.Text));
                    for (int i = 0; i < dataDetalle.Rows.Count; i++)
                    {
                        if (Convert.ToString(dataDetalle.Rows[i].Cells[8].Value) == "C")
                        {
                            DataTable dtDetalleProducto = new DataTable();
                            dtDetalleProducto = NProducto.mostrarDetalleProducto_Venta(Convert.ToInt32(Convert.ToInt32(dataDetalle.Rows[i].Cells[0].Value)));

                            for (int j = 0; j < dtDetalleProducto.Rows.Count; j++)
                            {
                                int idProducto_Com = Convert.ToInt32(dtDetalleProducto.Rows[j][0].ToString());
                                int cantRequerida  = Convert.ToInt32(dtDetalleProducto.Rows[j][1].ToString());

                                rpta = NProducto.EditarStock(idProducto_Com, ((cantRequerida * Convert.ToInt32(dataDetalle.Rows[i].Cells[2].Value) * -1)));

                                DataTable dtRecetaC = NReceta.Mostrar(Convert.ToInt32(idProducto_Com));
                                if (dtRecetaC.Rows.Count > 0)
                                {
                                    int     cantInsumo = Convert.ToInt32(dataDetalle.Rows[i].Cells["Cant"].Value.ToString());
                                    decimal cantTotal;
                                    for (int k = 0; k < dtRecetaC.Rows.Count; k++)
                                    {
                                        cantTotal = cantInsumo * Convert.ToDecimal(dtRecetaC.Rows[k][3].ToString());
                                        NInsumo.EditarStock(Convert.ToInt32(dtRecetaC.Rows[k][0].ToString()), cantTotal * -1);
                                    }
                                }
                            }
                        }
                        int idProd = Convert.ToInt32(dataDetalle.Rows[i].Cells["idDetalleVenta"].Value.ToString());

                        rpta = NDetalleVenta.ActualizarStockProd_Anulada(idProd);
                        DataTable dtReceta = NReceta.Mostrar(Convert.ToInt32(dataDetalle.Rows[i].Cells[0].Value));

                        if (dtReceta.Rows.Count > 0)
                        {
                            int     cantInsumo = Convert.ToInt32(dataDetalle.Rows[i].Cells["Cant"].Value);
                            decimal cantTotal;
                            for (int k = 0; k < dtReceta.Rows.Count; k++)
                            {
                                cantTotal = cantInsumo * Convert.ToDecimal(dtReceta.Rows[k][3].ToString());
                                NInsumo.EditarStock(Convert.ToInt32(dtReceta.Rows[k][0].ToString()), ((-1) * cantTotal));
                            }
                        }
                        dataCocina.Rows.Add(dataDetalle.Rows[i].Cells[1].Value, dataDetalle.Rows[i].Cells[2].Value, "");
                        //rpta = NDetalleVenta.Eliminar(Convert.ToInt32(dataDetalle.Rows[i].Cells[7].Value));
                    }
                    if (rpta == "OK")
                    {
                        rpta = NDelivery.Eliminar(Convert.ToInt32(this.lblIdVenta.Text));
                        if (rpta == "OK")
                        {
                            MessageBox.Show("Se anuló correctamente");
                            NImprimirComanda.imprimirCom(this.lblRepartidos.Text, "DELIVERY", "DELIVERY", dataCocina, "COMANDA ANULACION");
                            this.Close();
                        }
                    }
                }
                else if (this.lblEstado.Text == "Enviado")
                {
                    this.dataDetalle.DataSource = NVenta.mostrarDetalleVenta(Convert.ToInt32(this.lblIdVenta.Text));
                    for (int i = 0; i < dataDetalle.Rows.Count; i++)
                    {
                        if (Convert.ToString(dataDetalle.Rows[i].Cells[8].Value) == "C")
                        {
                            DataTable dtDetalleProducto = new DataTable();
                            dtDetalleProducto = NProducto.mostrarDetalleProducto_Venta(Convert.ToInt32(Convert.ToInt32(dataDetalle.Rows[i].Cells[0].Value)));

                            for (int j = 0; j < dtDetalleProducto.Rows.Count; j++)
                            {
                                int idProducto_Com = Convert.ToInt32(dtDetalleProducto.Rows[j][0].ToString());
                                int cantRequerida  = Convert.ToInt32(dtDetalleProducto.Rows[j][1].ToString());

                                rpta = NProducto.EditarStock(idProducto_Com, ((cantRequerida * Convert.ToInt32(dataDetalle.Rows[i].Cells[2].Value) * -1)));
                            }
                        }
                        dataCocina.Rows.Add(dataDetalle.Rows[i].Cells[1].Value, dataDetalle.Rows[i].Cells[2].Value, "");
                        rpta = NDetalleVenta.Eliminar(Convert.ToInt32(dataDetalle.Rows[i].Cells[7].Value));
                    }
                    if (rpta == "OK")
                    {
                        DataTable dtIdCompr = new DataTable();
                        dtIdCompr = NComprobante.mostrarIdComprobante(Convert.ToInt32(this.lblIdVenta.Text));
                        frmAnularComprobante frm = new frmAnularComprobante();
                        frm.lblBandera.Text     = "1";
                        frm.lblIdCompro.Text    = dtIdCompr.Rows[0][0].ToString();
                        frm.lblSerie.Text       = dtIdCompr.Rows[0][1].ToString();
                        frm.lblNro.Text         = dtIdCompr.Rows[0][2].ToString();
                        frm.lblFecha.Text       = dtIdCompr.Rows[0][3].ToString();
                        frm.lblComprobante.Text = this.lblTipoComprobante.Text;
                        frm.lblVuelto.Text      = this.lblVuelto.Text;
                        frm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("No se completó la operación");
            }
        }