string FormToNet() { string err; if (_skuInStock.Article.Matrix.CellsX.Count == 1 && _skuInStock.Article.Matrix.CellsY.Count == 1) { err = TextBoxToCell(T_Amount, _skuInStock[0, 0]); if (err != null) { T_Amount.Focus(); return(c_errInvalidQty); } } else { NetPanel netPan = (NetPanel)PAN_Net.Controls[0]; for (int i = 0; i < _skuInStock.Article.Matrix.CellsX.Count; i++) { for (int j = 0; j < _skuInStock.Article.Matrix.CellsY.Count; j++) { TextBox txtBox = netPan.FindCellTextBox(i, j); err = TextBoxToCell(txtBox, _skuInStock[i, j]); if (err != null) { txtBox.Focus(); return(err); } } } } return(null); }
/// <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; } }