Exemple #1
0
        private void cargarGrillaDetalle(int idPed)
        {
            double totalIVA = 0;
            double subtotal = 0;

            try
            {
                List <DetallePedido> detP = DetallePedidoDAO.GetDetalleXPedido(idPed);
                ped.detallePedido = detP;
                dgv_detalle.Rows.Clear();
                foreach (DetallePedido detPed in detP)
                {
                    if (Convert.ToInt32(cmb_iva.SelectedIndex) == 0)
                    {
                        //ACA CAMBIAR EL PORCENTAJE DEL IVA
                        double Iva = detPed.precio * 0.21;
                        totalIVA += Iva * detPed.cantidad;
                        subtotal += (detPed.precio - Iva) * detPed.cantidad;
                        dgv_detalle.Rows.Add(detPed.producto.CODProducto, detPed.producto.Nombre, detPed.producto.Unidad.Nombre, detPed.cantidad, detPed.precio - Iva, detPed.subTotal, detPed.producto.idProducto, (Iva) * detPed.cantidad, 0);
                    }
                    else
                    {
                        subtotal += detPed.precio * detPed.cantidad;
                        dgv_detalle.Rows.Add(detPed.producto.CODProducto, detPed.producto.Nombre, detPed.producto.Unidad.Nombre, detPed.cantidad, detPed.precio, detPed.subTotal, detPed.producto.idProducto, 0, 0);
                    }
                }
                txt_subtotal.Text = subtotal.ToString();
                txt_totalIva.Text = totalIVA.ToString();
            }
            catch (ApplicationException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
Exemple #2
0
        private void dtp_fecha_inicio_ValueChanged(object sender, EventArgs e)
        {
            limpiarGrillas();
            if (dtp_fecha_inicio.Value.Date < dtp_creacion_plan.Value.Date)
            {
                //MessageBox.Show("La fecha de inicio del plan no puede ser anterior a la actual", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                dtp_fecha_inicio.Value = dtp_fecha_inicio.Value.AddDays(7);;
                dtp_fecha_final.Value  = dtp_fecha_inicio.Value.AddDays(6);
                //deshabilitar();
                dtp_fecha_inicio.Focus();
            }
            else
            {
                dtp_fecha_final.Value = dtp_fecha_inicio.Value;
            }

            int result = DayOfWeek.Sunday - dtp_fecha_inicio.Value.DayOfWeek;

            dtp_fecha_inicio.Value = dtp_fecha_inicio.Value.AddDays(result);
            dtp_fecha_final.Value  = dtp_fecha_inicio.Value.AddDays(6);
            limpiarGrillas();
            cargarPestanias();
            foreach (TabPage tab in tab_dias.TabPages)
            {
                List <DetallePedido> pedidos = new List <DetallePedido>();
                foreach (Control contl in tab.Controls)
                {
                    if (contl is DateTimePicker)
                    {
                        try
                        {
                            pedidos = DetallePedidoDAO.getCantidadPedidaxProducto(((DateTimePicker)contl).Value.Date);
                            if (pedidos.Count > 0)
                            {
                                btn_guardar.Enabled = true;
                            }
                        }
                        catch (ApplicationException ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        }
                    }
                }
                foreach (Control contl in tab.Controls)
                {
                    if (contl is DataGridView)
                    {
                        foreach (DetallePedido ped in pedidos)
                        {
                            ((DataGridView)contl).Rows.Add(ped.producto.idProducto, ped.producto.Nombre, null, 0, ped.cantidad, ped.cantidad, ped.producto.Unidad.Nombre);
                        }
                    }
                }
            }
        }
 public static List <DetallePedido> buscarDetallePedido(int ped)
 {
     try
     {
         return(DetallePedidoDAO.GetDetalleXPedido(ped));
     }
     catch (ApplicationException ex)
     {
         throw new ApplicationException(ex.Message);
     }
 }