/// <summary> /// 快速Grid添加(按产品类型) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void krpbAddByFastGrid_Click(object sender, EventArgs e) { FastGridWindow window = new FastGridWindow(false, false); window.ShowDialog(this); HandleFastGrid(window); }
/// <summary> /// 处理快速查找 /// </summary> /// <param name="window"></param> private void HandleFastGrid(FastGridWindow window) { if (window.DialogResult == System.Windows.Forms.DialogResult.OK) { foreach (var item in window.ReturnValue) { Product product = Resources.GetRes().Products.Where(x => x.ProductId == item.Key && (x.HideType == 0 || x.HideType == 3)).FirstOrDefault(); string name = ""; if (Resources.GetRes().MainLangIndex == 0) { name = product.ProductName0; } else if (Resources.GetRes().MainLangIndex == 1) { name = product.ProductName1; } else if (Resources.GetRes().MainLangIndex == 2) { name = product.ProductName2; } // 判断是否已存在! if (ProductAlreadyExists(name)) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("CurrentProductAlreadyExists"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { AddToGrid("*", "-1", product.ProductId, item.Value.Price, item.Value.Count, Math.Round(item.Value.Price * item.Value.Count, 2), product.Price); if (product.CostPriceChangeMode == 1 && Common.GetCommon().IsChangeCostPrice()) { krpdgList.Rows[0].Cells["krpcmCostPrice"].ReadOnly = false; } if (product.PriceChangeMode == 1 && Common.GetCommon().IsChangeUnitPrice()) { krpdgList.Rows[0].Cells["krpcmPrice"].ReadOnly = false; } } } Import import; List <ImportDetail> importDetails; Calc(out importDetails, out import); } }
/// <summary> /// 扫条形码 /// </summary> private void ScanBarcode(string code) { // 获取条码产品 List <Product> products = Resources.GetRes().Products.Where(x => (x.Barcode == code) && (x.HideType == 0 || x.HideType == 3)).ToList(); if (products.Count > 1) { this.BeginInvoke(new Action(() => { FastGridWindow window = new FastGridWindow(false, true); window.FastGridBarcodeSearch(products, code); window.ShowDialog(this); HandleFastGrid(window); })); return; } else if (products.Count == 0) { return; } Product product = products.FirstOrDefault(); // 如果找到了 if (null != product) { string name = ""; if (Resources.GetRes().MainLangIndex == 0) { name = product.ProductName0; } else if (Resources.GetRes().MainLangIndex == 1) { name = product.ProductName1; } else if (Resources.GetRes().MainLangIndex == 2) { name = product.ProductName2; } // 判断是否已存在! this.BeginInvoke(new Action(() => { if (ProductAlreadyExists(name)) { KryptonMessageBox.Show(this, Resources.GetRes().GetString("CurrentProductAlreadyExists"), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); } else { AddToGrid("*", "-1", product.ProductId, product.CostPrice, 1, Math.Round(product.CostPrice * 1, 2), product.Price); if (product.PriceChangeMode == 1 && Common.GetCommon().IsChangeCostPrice()) { krpdgList.Rows[0].Cells["krpcmCostPrice"].ReadOnly = false; } if (product.PriceChangeMode == 1 && Common.GetCommon().IsChangeUnitPrice()) { krpdgList.Rows[0].Cells["krpcmPrice"].ReadOnly = false; } Import import; List <ImportDetail> importDetails; Calc(out importDetails, out import); if (null != krpdgList.CurrentCell && !krpdgList.IsCurrentCellInEditMode) { krpdgList.Focus(); krpdgList.ClearSelection(); krpdgList.CurrentCell = krpdgList.Rows[0].Cells["krpcmCount"]; } } })); } }