//Devon private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { try { comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown; comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems; try { int bIndex = comboBox1.SelectedIndex; int barID = listBar[bIndex].BarcodeID; LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(f => f.BarcodeID == barID).FirstOrDefault(); string pBarcode = comboBox1.Text; int sIndex = comboBoxStore.SelectedIndex; int storeID = listS[sIndex].StoreID; string brand = DAT.DataAccess.GetBrand().Where(o => o.BrandID == p.BrandID).FirstOrDefault().BrandName; string cat = DAT.DataAccess.GetCategory().Where(o => o.CategoryID == p.CategoryID).FirstOrDefault().CategoryName; try { panel1.Controls.Clear(); Control find = new ShowProductDetails(pBarcode, p.ProductName, p.ProductDescription, brand, cat); find.Parent = panel1; find.Dock = DockStyle.Fill; find.BringToFront(); } catch { } } catch { } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
/*当barcode改变时,用来实时显示该barcode的产品,厂家,类型信息。(一个barcode只能对应一个product)*/ private void addItem_barcode_selectedIdxChg(object sender, EventArgs e) { Log.WriteLog(LogType.Trace, "come in addItem_barcode_selectedIdxChg"); lBarcodeMsg.Visible = false; try { cbBarcode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown; cbBarcode.AutoCompleteMode = AutoCompleteMode.SuggestAppend; cbBarcode.AutoCompleteSource = AutoCompleteSource.ListItems; try { /*获取barcode信息*/ int bIndex = cbBarcode.SelectedIndex; int barID = listBar[bIndex].BarcodeID; Log.WriteLog(LogType.Trace, "the barcord[" + barID + "] with index[" + bIndex + "] is selected."); /*获取barcode对应的产品信息*/ LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(f => f.BarcodeID == barID).FirstOrDefault(); if (p == null) { Log.WriteLog(LogType.Warning, "there is not product band with barcode[" + barID + "]"); panel1.Controls.Clear(); lBarcodeMsg.Parent = panel1; lBarcodeMsg.Dock = DockStyle.Fill; lBarcodeMsg.BringToFront(); lBarcodeMsg.Visible = true; return; } Log.WriteLog(LogType.Trace, "success get product[" + p.ProductID + "] witch bind with barcode[" + barID + "]"); string pBarcode = cbBarcode.Text; /*获得产品的厂家id和类型id*/ string brand = DAT.DataAccess.GetBrand().Where(o => o.BrandID == p.BrandID).FirstOrDefault().BrandName; Log.WriteLog(LogType.Trace, "success get brand[" + p.BrandID + "] witch named[" + brand + "]"); string cat = DAT.DataAccess.GetCategory().Where(o => o.CategoryID == p.CategoryID).FirstOrDefault().CategoryName; Log.WriteLog(LogType.Trace, "success get category[" + p.CategoryID + "] witch named[" + cat + "]"); /*显示barcode对应的产品详细信息*/ try { Log.WriteLog(LogType.Trace, "goto show the barcode[" + barID + "] beyond to product[" + p.ProductID + "] in brand[" + p.BrandID + "] category[" + p.CategoryID + "] detail info"); panel1.Controls.Clear(); Control find = new ShowProductDetails(pBarcode, p.ProductName, p.ProductDescription, brand, cat); find.Parent = panel1; find.Dock = DockStyle.Fill; find.BringToFront(); } catch (Exception ex) { Log.WriteLog(LogType.Trace, "error to show barcode[" + barID + "] detail info"); throw ex; } } catch (Exception ex) { Log.WriteLog(LogType.Trace, "error to get barcode detail info"); throw ex; } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }