コード例 #1
0
 bool TryParsePrices(out int out_priceOfPurchase, out int out_priceOfSell)
 {
     _ = out_priceOfSell = 0;
     if (!int.TryParse(T_PriceOfPurchase.Text, out out_priceOfPurchase) || out_priceOfPurchase < 0)
     {
         T_PriceOfPurchase.Focus();
         MessageBox.Show(this, c_errInvalidCostOfPurchase, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return(false);
     }
     if (!int.TryParse(T_PriceOfSell.Text, out out_priceOfSell) || out_priceOfSell < 0)
     {
         T_PriceOfSell.Focus();
         MessageBox.Show(this, c_errInvalidSellPriceOfSell, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         return(false);
     }
     return(true);
 }
コード例 #2
0
        /// <summary>
        /// Search of SKU
        /// <remarks>Form is switching to warehouse stock edit mode.</remarks>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void B_Search_Click(object sender, EventArgs e)
        {
            bool canSearch = true;

            if (string.IsNullOrWhiteSpace(T_Name.Text))
            {
                MessageBox.Show(this, Resources.NAME_NOT_SET, Resources.FAILURE, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                T_Name.Focus();
                return;
            }

            Cursor oldCursor = this.Cursor;

            try
            {
                this.Cursor      = Cursors.WaitCursor;
                B_Search.Enabled = false;
                Application.DoEvents();

                List <Article> articles = Article.RestoreByName(T_Name.Text.Trim());
                if (articles.Count == 0)
                {
                    _article = null;

                    // Ask whether to create new SKU
                    if (MessageBox.Show(this, Resources.ASK_WHETHER_TO_CREATE_NEW_SKU, Resources.QUESTION, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        _modified = true;

                        T_Name.ReadOnly       = true;
                        B_Search.Enabled      = false;
                        canSearch             = false;
                        PAN_SkuParams.Enabled = true;
                        T_Amount.Focus();
                    }
                    else
                    {
                        T_Name.Focus();
                        return;
                    }
                }
                //else if (articles.Count > 1)
                //{
                //    // Display form for selection SKU by cost of purchase.
                //}
                else
                {
                    using (FRM_SelectArticleByPriceOfPurchase frm = new FRM_SelectArticleByPriceOfPurchase(articles))
                    {
                        if (frm.ShowDialog(this) != DialogResult.OK)
                        {
                            T_Name.Focus();
                            return;
                        }

                        _modified = true;

                        if (frm.NewPriceEntered)
                        {
                            _article = new Article()
                            {
                                Name            = articles[0].Name,
                                PriceOfPurchase = frm.NewPrice,
                                Matrix          = articles[0].Matrix
                            };
                        }
                        else
                        {
                            _article = frm.SelectedArticle;
                        }

                        // Display a size chart and let user to fill it.
                        T_Name.ReadOnly            = true;
                        T_PriceOfPurchase.ReadOnly = true;
                        B_Search.Enabled           = false;
                        canSearch             = false;
                        B_Reset.Enabled       = false;
                        PAN_SkuParams.Enabled = true;

                        CB_NetType.SelectBizItem(_article.Matrix.Id);
                        CB_NetType.Enabled = false;

                        _skuInStock = SkuInStock.Restore(_article, Registry.CurrentPointOfSale);
                        NetToForm();
                        if (_skuInStock.Article.Matrix.CellsX.Count == 1 && _skuInStock.Article.Matrix.CellsY.Count == 1)
                        {
                            T_Amount.Focus();
                        }
                        else
                        {
                            T_PriceOfPurchase.Focus();
                        }
                    }
                }
            }
            finally
            {
                B_Search.Enabled = canSearch;
                this.Cursor      = oldCursor;
            }
        }