public frmPagarDividida()
 {
     InitializeComponent();
     frmPagarDividida.f1 = this;
 }
Beispiel #2
0
        private void btnPagar_Click(object sender, EventArgs e)
        {
            DialogResult opcion;

            opcion = MessageBox.Show("Está seguro de dividir las cuentas?", "Sistema de Ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            string rpta = "";

            if (opcion == DialogResult.OK)
            {
                frmPagarDividida form = new frmPagarDividida();
                if (this.lblIdVenta.Text == "0")
                {
                    /* rpta = NVenta.InsertarPedidoSeparado(null,  Convert.ToInt32(this.lblIdMesa.Text), DateTime.Now, "Pedido DV", "",
                     *                                   Convert.ToDecimal(this.lblDescuento.Text), Convert.ToInt32(this.lblIdUsuario.Text), "CS", frmVenta.f1.dtDetalle);
                     */
                    rpta = NVenta.InsertarPedidoSeparado(null, Convert.ToInt32(this.lblIdMesa.Text), DateTime.Now, "Pedido DV", "",
                                                         Convert.ToDecimal(this.lblDescuento.Text), Convert.ToInt32(this.lblIdUsuario.Text), "CD", 1, frmVenta.f1.dtDetalle,
                                                         frmVenta.f1.dtDetalleMenu, DateTime.Now, 00.00m, Convert.ToInt32(this.lblIdUsuario.Text), "", "", "", "");
                    if (rpta != "")
                    {
                        for (int i = 0; i < frmVenta.f1.dataListadoDetalle.Rows.Count; i++)
                        {
                            if (frmVenta.f1.dataListadoDetalle.Rows[i].Cells["Tipo"].Value.ToString() == "C")
                            {
                                DataTable dtDetalleProducto = new DataTable();
                                dtDetalleProducto = NProducto.mostrarDetalleProducto_Venta(Convert.ToInt32(frmVenta.f1.dataListadoDetalle.Rows[i].Cells["Cod"].Value.ToString()));
                                int cantPedido = Convert.ToInt32(frmVenta.f1.dataListadoDetalle.Rows[i].Cells["Cant"].Value.ToString());
                                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());

                                    NProducto.EditarStock(idProducto_Com, cantRequerida * cantPedido);
                                }
                            }
                        }
                    }

                    this.lblIdVenta.Text = rpta;
                }
                else
                {
                    int cont = Convert.ToInt32(frmVenta.f1.lblNroFilas.Text);
                    for (int i = cont; i < frmVenta.f1.dataListadoDetalle.Rows.Count; i++)
                    {
                        int     idProducto = Convert.ToInt32(frmVenta.f1.dataListadoDetalle.Rows[i].Cells[0].Value.ToString());
                        int     cantidad   = Convert.ToInt32(frmVenta.f1.dataListadoDetalle.Rows[i].Cells[2].Value.ToString());
                        decimal prVenta    = Convert.ToDecimal(frmVenta.f1.dataListadoDetalle.Rows[i].Cells[3].Value.ToString());
                        decimal desc       = Convert.ToDecimal(frmVenta.f1.dataListadoDetalle.Rows[i].Cells[4].Value.ToString());
                        string  barra      = frmVenta.f1.dataListadoDetalle.Rows[i].Cells["Barra"].Value.ToString();
                        string  tipo       = frmVenta.f1.dataListadoDetalle.Rows[i].Cells["Tipo"].Value.ToString();

                        rpta = NDetalleVenta.InsertarAdicPedido(Convert.ToInt32(this.lblIdVenta.Text), idProducto, cantidad, prVenta, desc,
                                                                frmVenta.f1.dataListadoDetalle.Rows[i].Cells[6].Value.ToString(), tipo, barra, frmVenta.f1.dtDetalleMenu, "Pedido");
                        if (rpta == "OK")
                        {
                            for (int p = cont; p < frmVenta.f1.dataListadoDetalle.Rows.Count; p++)
                            {
                                if (frmVenta.f1.dataListadoDetalle.Rows[i].Cells["Tipo"].Value.ToString() == "C")
                                {
                                    DataTable dtDetalleProducto = new DataTable();
                                    dtDetalleProducto = NProducto.mostrarDetalleProducto_Venta(Convert.ToInt32(frmVenta.f1.dataListadoDetalle.Rows[i].Cells["Cod"].Value.ToString()));
                                    int cantPedido = Convert.ToInt32(frmVenta.f1.dataListadoDetalle.Rows[i].Cells["Cant"].Value.ToString());
                                    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());

                                        NProducto.EditarStock(idProducto_Com, cantRequerida * cantPedido);
                                    }
                                }
                            }
                        }
                    }
                }


                if (this.txtNumeroDiv.Text.Trim().Equals("1"))
                {
                    form.btn1.Enabled = true;
                }
                else if (this.txtNumeroDiv.Text.Trim().Equals("2"))
                {
                    form.btn1.Enabled = true;
                    form.btn2.Enabled = true;
                }
                else if (this.txtNumeroDiv.Text.Trim().Equals("3"))
                {
                    form.btn1.Enabled = true;
                    form.btn2.Enabled = true;
                    form.btn3.Enabled = true;
                }
                else if (this.txtNumeroDiv.Text.Trim().Equals("4"))
                {
                    form.btn1.Enabled = true;
                    form.btn2.Enabled = true;
                    form.btn3.Enabled = true;
                    form.btn4.Enabled = true;
                }
                else if (this.txtNumeroDiv.Text.Trim().Equals("5"))
                {
                    form.btn1.Enabled = true;
                    form.btn2.Enabled = true;
                    form.btn3.Enabled = true;
                    form.btn4.Enabled = true;
                    form.btn5.Enabled = true;
                }
                else if (this.txtNumeroDiv.Text.Trim().Equals("6"))
                {
                    form.btn1.Enabled = true;
                    form.btn2.Enabled = true;
                    form.btn3.Enabled = true;
                    form.btn4.Enabled = true;
                    form.btn5.Enabled = true;
                    form.btn6.Enabled = true;
                }

                form.lblIdMesa.Text       = this.lblIdMesa.Text;
                form.lblIdVenta.Text      = this.lblIdVenta.Text;
                form.lblIdTrabajador.Text = this.lblIdTrabajador.Text;
                form.lblRedondeo.Text     = this.lblRedondeo.Text;
                form.lblIdUsuario.Text    = this.lblIdUsuario.Text;

                /*
                 * descuento = Convert.ToDecimal(this.lblDescuento_Ind.Text);
                 * form.lblDescuento.Text = this.lblDescuento_Ind.Text;
                 * total = suma - descuento;
                 * form.lblTotal.Text = total.ToString();*/
                form.Show();
            }
        }