コード例 #1
0
        protected void CalculateBenefit(RadMaskedEditBox unitPrice, RadMaskedEditBox productCost, RadMaskedEditBox benefit)
        {
            var result = 0.00;

            if (Convert.ToDouble(productCost.Value) == 0.00)
            {
                errorProductProvider.SetError(ProductCostRadMaskedEditBox, "Introduzca el costo por unidad.");
                ProductCostRadMaskedEditBox.Focus();
                return;
            }
            errorProductProvider.Clear();

            var _productCost = Convert.ToDecimal(productCost.Value);
            var _unitprice   = Convert.ToDecimal(unitPrice.Value);

            result = (double)(((_unitprice - _productCost) * 100) / _productCost);

            if (result != 0 & result > 1)
            {
                benefit.Text = string.Format("{0}", result);
            }
            else
            {
                benefit.Text = string.Format("{0}", 0);
            }
        }
コード例 #2
0
        /// <summary>
        /// Register a new Product
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void RegisterRadButton_RegisterNewProduct(object sender, EventArgs e)
        {
            try
            {
                //Validate a new product to register

                #region Validate ProductCodeRadTextBoxControl
                if (String.IsNullOrEmpty(ProductCodeRadTextBoxControl.Text))
                {
                    errorProductProvider.SetError(ProductCodeRadTextBoxControl, "Introduzca un código.");
                    ProductCodeRadTextBoxControl.Focus();
                    return;
                }
                errorProductProvider.Clear();
                if (isExitProductCode)
                {
                    errorProductProvider.SetError(ProductCodeRadTextBoxControl, "Código existe en la base de datos");
                    return;
                }
                errorProductProvider.Clear();
                #endregion
                #region Validate ProductNameRadTextBoxControl
                if (String.IsNullOrEmpty(ProductNameRadTextBoxControl.Text))
                {
                    errorProductProvider.SetError(ProductNameRadTextBoxControl, "Introduzca un nombre para el producto.");
                    ProductNameRadTextBoxControl.Focus();
                    return;
                }
                errorProductProvider.Clear();
                #endregion
                #region Validate ProductCostRadMaskedEditBox
                if (Convert.ToDouble(ProductCostRadMaskedEditBox.Value) == 0.00)
                {
                    errorProductProvider.SetError(ProductCostRadMaskedEditBox, "Introduzca el costo por unidad.");
                    ProductCostRadMaskedEditBox.Focus();
                    return;
                }
                errorProductProvider.Clear();
                #endregion
                #region Validate InitialStockRadMaskedEditBox
                if (Convert.ToInt32(InitialStockRadMaskedEditBox.Value) == 0)
                {
                    errorProductProvider.SetError(InitialStockRadMaskedEditBox, "Introduzca la cantidad Inicial.");
                    InitialStockRadMaskedEditBox.Focus();
                    return;
                }
                errorProductProvider.Clear();
                #endregion

                //Create Product
                Product _p = new Product()
                {
                    ProductCode         = ProductCodeRadTextBoxControl.Text,
                    ProductName         = ProductNameRadTextBoxControl.Text,
                    Description         = DescriptionRadTextBoxControl.Text != string.Empty ? DescriptionRadTextBoxControl.Text : null,
                    State               = StateRadCheckBox.Checked,
                    InvoiceWithoutStock = InvoiceWithoutStockRadCheckBox.Checked,
                    InvoiceWithPrice    = GetInvoiceWithPrice(),
                };
                if (CategoryIDComboBox.SelectedIndex != 0)
                {
                    _p.CategoryID = (int)CategoryIDComboBox.SelectedValue;
                }

                if (UnitIDComboBox.SelectedIndex != 0)
                {
                    _p.UnitID = (int)UnitIDComboBox.SelectedValue;
                }
                //Create Product Details
                ProductDetail _pd = new ProductDetail()
                {
                    ProductCost = Convert.ToDecimal(ProductCostRadMaskedEditBox.Value),
                    BodegaID    = 1,
                };
                if (Convert.ToDouble(UnitPrice1RadMaskedEditBox.Value) != 0.00)
                {
                    _pd.UnitPrice1 = Convert.ToDecimal(UnitPrice1RadMaskedEditBox.Value);
                }
                if (Convert.ToDouble(UnitPrice2RadMaskedEditBox.Value) != 0.00)
                {
                    _pd.UnitPrice2 = Convert.ToDecimal(UnitPrice2RadMaskedEditBox.Value);
                }
                if (Convert.ToDouble(UnitPrice3RadMaskedEditBox.Value) != 0.00)
                {
                    _pd.UnitPrice3 = Convert.ToDecimal(UnitPrice3RadMaskedEditBox.Value);
                }
                if (TaxIDComboBox.SelectedIndex != 0)
                {
                    _pd.TaxID = (int)TaxIDComboBox.SelectedValue;
                }

                var InitialStock = Convert.ToInt32(InitialStockRadMaskedEditBox.Value);
                _pd.Stock = InitialStock;

                //Create Kardex
                Kardex _k = new Kardex()
                {
                    RegisterDate = DateTime.Now,
                    TypeOfMove   = "Inventario Inicial",
                    KardexIn     = InitialStock,
                    KardexStock  = InitialStock
                };

                _pd.Kardexes.Add(_k);
                _p.ProductDetails.Add(_pd);
                this._serviceProductBL.Add(_p);
                this._currentParentForm.FillProductsRadGridView();
                RadMessageBox.Show(null, "Producto registrado satisfactoriamente", "JOSIAS INDUSTRIAL SRL", MessageBoxButtons.OK, RadMessageIcon.Info);
            }
            catch (Exception ex)
            {
                RadMessageBox.Show(null, string.Format("Error : {0}", ex.InnerException), "JOSIAS INDUSTRIAL SRL", MessageBoxButtons.OK, RadMessageIcon.Error);
                return;
            }
        }