Exemple #1
0
        private int Valida()
        {
            int    rs       = 0;
            double Cantidad = 0;

            if (String.IsNullOrEmpty(txtCantidad.Text))
            {
                Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                rs = 1;
            }
            else
            {
                if (txtCantidad.Text.Length >= 1)
                {
                    if (!Util.Decimal(txtCantidad.Text))
                    {
                        Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                        rs = 1;
                    }
                    else
                    {
                        Cantidad = Convert.ToDouble(txtCantidad.Text);
                        ttCantidad.Hide(txtCantidad);
                    }
                }
            }

            if (rs == 0)
            {
                int status = CantInv.CompareTo(Cantidad);
                if (status < 0)
                {
                    if (CfgAlma.NumRojo == 1)
                    {
                        if (MessageBoxAdv.Show("Cantidad solicitada es mayor a la existencia del Articulo\n" +
                                               " Existencia: " + CantInv + "\n" +
                                               " ¿Desea continuar?",
                                               "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            rs = 1;
                        }
                    }
                    else
                    {
                        rs = 1;
                        Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad solicitada es mayor a la existencia del Articulo\n" +
                                    " Existencia: " + CantInv + "\n", ToolTipIcon.Error);
                    }
                }
            }

            return(rs);
        }
Exemple #2
0
        private void Calculos(int Op)
        {
            double Descuento = 0;
            double SubTotal  = 0;
            double Total     = 0;


            if (String.IsNullOrEmpty(txtDescuento.Text))
            {
                if (Op == 1)
                {
                    Util.MsjBox(ttDescuento, txtDescuento, "Descuento", "Descuento: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                    ErrCalc = false;
                }
                else
                {
                    Descuento = 0;
                    ttDescuento.Hide(txtDescuento);
                }
            }
            else
            {
                if (txtDescuento.Text.Length >= 1)
                {
                    if (!Util.Decimal(txtDescuento.Text))
                    {
                        Util.MsjBox(ttDescuento, txtDescuento, "Descuento", "Descuento: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                        ErrCalc = false;
                    }
                    else
                    {
                        Descuento = Convert.ToDouble(txtDescuento.Text);
                        ttDescuento.Hide(txtDescuento);
                    }
                }
            }

            if (String.IsNullOrEmpty(txtSubTotal.Text))
            {
                if (Op == 1)
                {
                    Util.MsjBox(ttSubTotal, txtSubTotal, "SubTotal", "SubTotal: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                    ErrCalc = false;
                }
                else
                {
                    SubTotal = 0;
                    ttSubTotal.Hide(txtSubTotal);
                }
            }
            else
            {
                if (txtSubTotal.Text.Length >= 1)
                {
                    if (!Util.Decimal(Util.LimpiarTxt(txtSubTotal.Text)))
                    {
                        Util.MsjBox(ttSubTotal, txtSubTotal, "SubTotal", "SubTotal: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                        ErrCalc = false;
                    }
                    else
                    {
                        SubTotal = Convert.ToDouble(Util.LimpiarTxt(txtSubTotal.Text));
                        ttSubTotal.Hide(txtSubTotal);
                    }
                }
            }

            if (ErrCalc)
            {
                /*
                 * Total = SubTotal - Descuento;
                 *
                 * if (Descuento > 0)
                 * {
                 *  TotalIEPS = _iEPS > 0 ? SubTotal * (_iEPS / 100) : 0;
                 *  SubTotal = SubTotal + TotalIEPS;
                 *  TotalIva = iva > 0 ? SubTotal * (iva / 100) : 0;
                 *
                 *  TotalPartida = SubTotal + TotalIva;
                 *  SubTotal = SubTotal - TotalIEPS;
                 *
                 * }
                 *
                 * if (Total >= 0)
                 * {
                 *  ttTotal.Hide(txtTotal);
                 *  txtTotal.Text = Util.FormtDouDec(Total);
                 * }
                 * else
                 * {
                 *  Util.MsjBox(ttTotal, txtTotal, "Descuento", "Descuento: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                 *  ErrCalc = false;
                 * }
                 */
            }
        }
Exemple #3
0
        private void ValidaCalculos(int Op)
        {
            //String err = "";
            if (String.IsNullOrEmpty(txtCantidad.Text))
            {
                if (Op == 1)
                {
                    Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                    //err = err + "Cantidad: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                    ErrCalc = false;
                }
                else
                {
                    Cantidad = 0;
                    ttCantidad.Hide(txtCantidad);
                }
            }
            else
            {
                if (txtCantidad.Text.Length >= 1)
                {
                    if (!Util.Decimal(txtCantidad.Text))
                    {
                        Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                        //err = err + "Cantidad: Contiene caracteres no validos. Sugiere: 0)\n";
                        ErrCalc = false;
                    }
                    else
                    {
                        Cantidad = Convert.ToDouble(txtCantidad.Text);
                        ttCantidad.Hide(txtCantidad);
                    }
                }
            }

            if (String.IsNullOrEmpty(txtPrecio.Text))
            {
                if (Op == 1)
                {
                    Util.MsjBox(ttPrecio, txtPrecio, "Precio", "Precio: Contiene caracteres no validos. Sugiere: 0.0 0000", ToolTipIcon.Error);
                    //err = err + "Precio: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                    ErrCalc = false;
                }
                else
                {
                    Precio = 0;
                    ttPrecio.Hide(txtPrecio);
                }
            }
            else
            {
                if (txtPrecio.Text.Length >= 1)
                {
                    if (!Util.Decimal(txtPrecio.Text))
                    {
                        new BalloonTip("Error de captura", "Contiene caracteres no validos. Sugiere: 0.0 0000", txtPrecio, BalloonTip.ICON.INFO, 5000);
                        //err = err + "Precio: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                        ErrCalc = false;
                    }
                    else
                    {
                        Precio = Convert.ToDouble(txtPrecio.Text);
                        ttPrecio.Hide(txtPrecio);
                    }
                }
            }

            if (String.IsNullOrEmpty(txtDescuento.Text))
            {
                if (Op == 1)
                {
                    Util.MsjBox(ttDescuento, txtDescuento, "Descuento", "Descuento: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                    //err = err + "Descuento: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                    ErrCalc = false;
                }
                else
                {
                    Descuento = 0;
                    ttDescuento.Hide(txtDescuento);
                }
            }
            else
            {
                if (txtDescuento.Text.Length >= 1)
                {
                    if (!Util.Decimal(txtDescuento.Text))
                    {
                        Util.MsjBox(ttDescuento, txtDescuento, "Descuento", "Descuento: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                        //err = err + "Descuento: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                        ErrCalc = false;
                    }
                    else
                    {
                        Descuento = (Convert.ToDouble(txtDescuento.Text));
                        ttDescuento.Hide(txtDescuento);
                    }
                }
            }

            if (ErrCalc)
            {
                ttCantidad.Hide(txtCantidad);
                if (PModLlama.Equals("Minv"))
                {
                    if (CfgMovInv.EsTraspaso == 1 || CfgMovInv.EntSal.Equals("S"))
                    {
                        if ((CantInv - Cantidad) < 0)
                        {
                            if (CfgAlma.NumRojo == 1)
                            {
                                if (MessageBoxAdv.Show("Cantidad solicitada es mayor a la existencia del Articulo\n" +
                                                       " Existencia: " + CantInv + "\n" +
                                                       " ¿Desea continuar?",
                                                       "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    ExisNegativa = 0;
                                }
                                else
                                {
                                    ExisNegativa = 1;
                                }
                            }
                            else
                            {
                                ExisNegativa = 1;
                                Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad solicitada es mayor a la existencia del Articulo\n" +
                                            " Existencia: " + CantInv + "\n", ToolTipIcon.Error);
                            }
                        }
                        else
                        {
                            ExisNegativa = 0;
                        }
                    }
                    else
                    {
                        ExisNegativa = 0;
                        //ValidaCalculos(Op);
                    }
                }
                else
                {
                    ExisNegativa = 0;
                }

                SubTotal     = 0; txtSubTotal.Text = "0.0";
                PNeto        = 0; txtPrecioNeto.Text = "0.0";
                TotalIva     = 0; TotalIEPS = 0;
                TotalPartida = 0; txtTotal.Text = "0.0";


                //002 eNTRADA - 501 - SALIDA por ajuste de inventario
                if (!CfgMovInv.CveTipoMov.Equals("002") || !CfgMovInv.CveTipoMov.Equals("501"))
                {
                    SubTotal = Precio * Cantidad;
                    if (chkCalculaPorcentaje.Checked)
                    {
                        PNeto = (SubTotal * Descuento / 100);
                    }
                    else
                    {
                        PNeto = Descuento;
                    }

                    SubTotal = SubTotal - PNeto;

                    //PENDIENTE: Valida una matrz y dentro de un else va lo siguiente
                    if (CfgMovInv.CalculaIva == 1)
                    {
                        double iva   = Convert.ToDouble(txtValorIVA.Text);
                        double _iEPS = Convert.ToDouble(txtValorIEPS.Text);

                        TotalIEPS = _iEPS > 0 ? SubTotal * (_iEPS / 100) : 0;
                        SubTotal  = SubTotal + TotalIEPS;
                        TotalIva  = iva > 0 ? SubTotal * (iva / 100) : 0;
                    }

                    TotalPartida = SubTotal + TotalIva;
                    SubTotal     = SubTotal - TotalIEPS;
                }
                else
                {
                    CveImp = "";
                }

                txtTotalDescuento.Text = Util.FormtDouDec(PNeto);        //Convert.ToString(SubTotal);
                txtSubTotal.Text       = Util.FormtDouDec(SubTotal);     //Convert.ToString(SubTotal);
                txtImpuesto.Text       = Util.FormtDouDec(TotalIva);     //Convert.ToString(TotalIva);
                txtImpIEPS.Text        = Util.FormtDouDec(TotalIEPS);    //Convert.ToString(TotalIva);
                txtTotal.Text          = Util.FormtDouDec(TotalPartida); //Convert.ToString(TotalPartida);
            }
        }
Exemple #4
0
        private void Calculos(int Op)
        {
            //String err = "";
            double Precio       = 0;
            double Descuento    = 0;
            double PNeto        = 0;
            double Cantidad     = 0;
            double SubTotal     = 0;
            double TotalIva     = 0;
            double TotalIEPS    = 0;
            double TotalPartida = 0;

            if (String.IsNullOrEmpty(txtCantidad.Text))
            {
                if (Op == 1)
                {
                    Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                    ErrCalc = false;
                }
                else
                {
                    Cantidad = 0;
                    ttCantidad.Hide(txtCantidad);
                }
            }
            else
            {
                if (txtCantidad.Text.Length >= 1)
                {
                    if (!Util.Decimal(txtCantidad.Text))
                    {
                        Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                        ErrCalc = false;
                    }
                    else
                    {
                        Cantidad = Convert.ToDouble(txtCantidad.Text);
                        ttCantidad.Hide(txtCantidad);
                    }
                }
            }

            if (String.IsNullOrEmpty(txtPrecio.Text))
            {
                if (Op == 1)
                {
                    //err = err + "Precio: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                    Util.MsjBox(ttPrecio, txtPrecio, "Precio", "Precio: Contiene caracteres no validos. Sugiere: 0.0 0000", ToolTipIcon.Error);
                    ErrCalc = false;
                }
                else
                {
                    Precio = 0;
                    ttPrecio.Hide(txtPrecio);
                }
            }
            else
            {
                if (txtPrecio.Text.Length >= 1)
                {
                    if (!Util.Decimal(txtPrecio.Text))
                    {
                        //err = err + "Precio: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                        Util.MsjBox(ttPrecio, txtPrecio, "Precio", "Precio: Contiene caracteres no validos. Sugiere: 0.0 0000", ToolTipIcon.Error);
                        ErrCalc = false;
                    }
                    else
                    {
                        Precio = Convert.ToDouble(txtPrecio.Text);
                        ttPrecio.Hide(txtPrecio);
                    }
                }
            }

            if (String.IsNullOrEmpty(txtDescuento.Text))
            {
                if (Op == 1)
                {
                    //err = err + "Descuento: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                    Util.MsjBox(ttDescuento, txtDescuento, "Descuento", "Descuento: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                    ErrCalc = false;
                }
                else
                {
                    Descuento = 0;
                    ttDescuento.Hide(txtDescuento);
                }
            }
            else
            {
                if (txtDescuento.Text.Length >= 1)
                {
                    if (!Util.Decimal(txtDescuento.Text))
                    {
                        //err = err + "Descuento: Contiene caracteres no validos. Sugiere: 0.0 0000\n";
                        Util.MsjBox(ttDescuento, txtDescuento, "Descuento", "Descuento: Contiene caracteres no validos. Sugiere: 0", ToolTipIcon.Error);
                        ErrCalc = false;
                    }
                    else
                    {
                        //Descuento = (Convert.ToDouble(txtDescuento.Text) / 100);
                        Descuento = (Convert.ToDouble(txtDescuento.Text));
                        ttDescuento.Hide(txtDescuento);
                    }
                }
            }

            if (ErrCalc)
            {
                if (ConfigDoc.UsaAlmTmp == 1)
                {
                    if ((CantInv - Cantidad) < 0)
                    {
                        if (CfgAlma.NumRojo == 1)
                        {
                            if (MessageBoxAdv.Show("Cantidad solicitada es mayor a la existencia del Articulo\n" +
                                                   " Existencia: " + CantInv + "\n" +
                                                   " ¿Desea continuar?",
                                                   "Pregunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                ExisNegativa = 0;
                            }
                            else
                            {
                                ExisNegativa = 1;
                            }
                        }
                        else
                        {
                            ExisNegativa = 1;
                            Util.MsjBox(ttCantidad, txtCantidad, "Cantidad", "Cantidad solicitada es mayor a la existencia del Articulo\n" +
                                        " Existencia: " + CantInv + "\n", ToolTipIcon.Error);
                        }
                    }
                    else
                    {
                        ExisNegativa = 0;
                    }
                }
                else
                {
                    ExisNegativa = 0;
                }

                if (ExisNegativa == 0)
                {
                    double iva   = Convert.ToDouble(txtValorIVA.Text);
                    double _iEPS = Convert.ToDouble(txtValorIESP.Text);

                    SubTotal = Precio * Cantidad;

                    if (chkCalculaPorcentaje.Checked)
                    {
                        PNeto = (SubTotal * Descuento / 100);
                    }
                    else
                    {
                        PNeto = Descuento;
                    }

                    SubTotal = SubTotal - PNeto;


                    TotalIEPS = _iEPS > 0 ? SubTotal * (_iEPS / 100) : 0;
                    SubTotal  = SubTotal + TotalIEPS;
                    TotalIva  = iva > 0 ? SubTotal * (iva / 100) : 0;

                    TotalPartida = SubTotal + TotalIva;
                    SubTotal     = SubTotal - TotalIEPS;

                    txtImpIEPS.Text        = Util.FormtDouDec(TotalIEPS);    //Convert.ToString(TotalIva);
                    txtImpuesto.Text       = Util.FormtDouDec(TotalIva);     //TotalIva.ToString();
                    txtTotalDescuento.Text = Util.FormtDouDec(PNeto);        //SubTotal.ToString();
                    txtSubtotal.Text       = Util.FormtDouDec(SubTotal);     //SubTotal.ToString();
                    txtTotal.Text          = Util.FormtDouDec(TotalPartida); //TotalPartida.ToString();
                }
            }
        }