private void updateItem_store_SelectedIdxChg(object sender, EventArgs e) { Log.WriteLog(LogType.Trace, "come in updateItem_store_SelectedIdxChg"); lConnectMsg.Text = " "; lStoreMsg.Text = " "; try { if (cbStore.SelectedIndex > -1) { LTS.Store stStore = listS[cbStore.SelectedIndex]; LTS.Settings set = DAT.DataAccess.GetSettings().Where(y => y.StoreID == stStore.StoreID && y.SettingsSelect == true).FirstOrDefault(); //在指定的store下进行扫描,并返回扫到的epc if (set == null) { Log.WriteLog(LogType.Warning, "warning:there is not settings available in store[" + stStore.StoreID + "]"); lStoreMsg.Text = ("the matchine[" + stStore.StoreName + "] is not band any settings, please change another matchine. "); } } } catch (Exception ex) { Log.WriteLog(LogType.Error, "error to change store index, the error msg is " + ex.Message + ""); } }
//Tiaan private void btnlogin_Click(object sender, EventArgs e) { LTS.Store store = new LTS.Store(); if (txtName.Text == "") { //error } else if (txtSur.Text == "") { //error } else { store.StoreName = txtName.Text; store.StoreLocation = txtSur.Text; } int storeID = DAT.DataAccess.AddStore(store); if (storeID == -1) { if (DialogResult.OK == MessageBox.Show("Sorry something went wrong, the machine was not added")) { } } else { if (DialogResult.OK == MessageBox.Show("The machine was added successfully")) { } } }
private void addItem_rfid_click(object sender, EventArgs e) { Log.WriteLog(LogType.Trace, "come in addItem_rfid_click"); lStoreMsg.Visible = false; try { try { time = 0; lblTimer.Text = time.ToString(); timer = new System.Timers.Timer(); //注册时间超时后需要执行的事件 timer.Elapsed += addItem_timer_elapsed; timer.Interval = 1000; //屏蔽一些控件的可用性 addItem_enableOrDisable(false); epc = ""; int iStore = cbStore.SelectedIndex; LTS.Store s = listS[iStore]; //读取store下生效的settings配置 LTS.Settings set = DAT.DataAccess.GetSettings().Where(y => y.StoreID == s.StoreID && y.SettingsSelect == true).FirstOrDefault(); if (set != null) { Log.WriteLog(LogType.Trace, "goto connect reader with setting[" + set.SettingsID + "] in store[" + s.StoreID + "]"); addItem_connect(set); } else { //lblConnect.Text = ("Settings not found!"); lStoreMsg.Visible = true; Log.WriteLog(LogType.Error, "can not get any settings from database with in store[" + s.StoreID + "]"); addItem_enableOrDisable(true); } } catch (Exception exx) { Log.WriteLog(LogType.Error, "error to get settings info with store"); //lblConnect.Text = ("Store not selected!"); lStoreMsg.Visible = true; addItem_enableOrDisable(true); } } catch (Exception ex) { Log.WriteLog(LogType.Error, "error to connect to reader in store"); MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//Tiaan private void btnlogin_Click(object sender, EventArgs e) { try { labelError1.Visible = false; labelError2.Visible = false; labelError3.Visible = false; LTS.Store store = new LTS.Store(); bool check = true; if (txtName.Text == "") { labelError1.Text = "Please enter store name!"; labelError1.Visible = true; check = false; } if (txtSur.Text == "") { labelError2.Text = "Please enter store location!"; labelError2.Visible = true; check = false; } if (st != null) { if (st.Where(u => u.StoreName == txtName.Text).FirstOrDefault() != null) { labelError3.Text = "Store already exists"; labelError3.Visible = true; check = false; } } if (check) { store.StoreName = txtName.Text; store.StoreLocation = txtSur.Text; int storeID = DAT.DataAccess.AddStore(store); if (storeID == -1) { MessageBox.Show("Sorry something went wrong, the store was not added"); ((Main)this.Parent.Parent).ChangeView <Pages.Store.Store>(); } else { MessageBox.Show("The store was added successfully"); ((Main)this.Parent.Parent).ChangeView <Pages.Store.Store>(); } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//Margo private void button2_Click(object sender, EventArgs e) { try { label1.Visible = false; if (st.Where(u => u.StoreName == comboBoxStore.SelectedItem.ToString()).FirstOrDefault() != null) { try { time = 0; lblTimer.Text = time.ToString(); timer = new System.Timers.Timer(); timer.Elapsed += timer_Elapsed; timer.Interval = 1000; ((UpdateStock)this.Parent.Parent).EnableOrDisable(false); EnableOrDisable(false); epc = ""; int iStore = comboBoxStore.SelectedIndex; LTS.Store s = st[iStore]; LTS.Settings set = DAT.DataAccess.GetSettings().Where(y => y.StoreID == s.StoreID && y.SettingsSelect == true).FirstOrDefault(); if (set != null) { connect(set); } else { lblConnect.Text = ("Settings not found!"); EnableOrDisable(true); ((UpdateStock)this.Parent.Parent).EnableOrDisable(true); } } catch (Exception exx) { lblConnect.Text = ("Store not selected!"); EnableOrDisable(true); ((UpdateStock)this.Parent.Parent).EnableOrDisable(true); } } else { label1.Visible = true; } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//Margo private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { try { dataGridViewReaders.DataSource = null; dataGridViewReaders.Rows.Clear(); int settingsIndex = comboBox1.SelectedIndex; int settingsID = listSet[settingsIndex].SettingsID; SelectedSetting = settingsID; SettingsMain sm = new SettingsMain(); sm.SettingsID = settingsID; sm.SettingsName = listSet[settingsIndex].SettingsName; sm.SettingsSelect = listSet[settingsIndex].SettingsSelect; sm.StoreID = listSet[settingsIndex].StoreID; smi = sm; LTS.Store store = DAT.DataAccess.GetStore().Where(i => i.StoreID == sm.StoreID).FirstOrDefault(); sm.StoreLocation = store.StoreLocation; sm.StoreName = store.StoreName; List <LTS.Reader> readers = new List <LTS.Reader>(); readers = DAT.DataAccess.GetReader().Where(j => j.SettingsID == sm.SettingsID).ToList(); for (int j = 0; j < readers.Count; j++) { ReaderMain rm = new ReaderMain(); rm.ReaderID = readers[j].ReaderID; rm.IPaddress = readers[j].IPaddress; rm.NumAntennas = readers[j].NumAntennas; rm.antennas = DAT.DataAccess.GetAntenna().Where(q => q.ReaderID == rm.ReaderID).ToList(); sm.Readers.Add(rm); } for (int i = 0; i < sm.Readers.Count; i++) { for (int y = 0; y < sm.Readers[i].antennas.Count; y++) { dataGridViewReaders.Rows.Add(sm.Readers[i].IPaddress, sm.Readers[i].antennas[y].AntennaNumber, sm.Readers[i].antennas[y].TxPower, sm.Readers[i].antennas[y].RxPower); } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
public static LTS.Store GetStoreItemByID(int?StoreID) { LTS.Store store = new LTS.Store(); try { using (LTS.LTSBase access = new LTS.LTSDC()) { store = access.Store.Where(o => o.StoreID == StoreID).FirstOrDefault(); } } catch (Exception ex) { } return(store); }
public static int AddStore(LTS.Store store) { int?StoreID = -1; try { using (LTS.LTSBase access = new LTS.LTSDC()) { access.InsertStore(store.StoreLocation, store.StoreName, ref StoreID); } } catch (Exception ex) { } return(StoreID.Value); }
//Margo private void Settings_Load(object sender, EventArgs e) { try { List <LTS.Settings> set = new List <LTS.Settings>(); set = DAT.DataAccess.GetSettings().ToList(); for (int x = 0; x < set.Count; x++) { SettingsMain sm = new SettingsMain(); sm.SettingsID = set[x].SettingsID; sm.SettingsName = set[x].SettingsName; sm.SettingsSelect = set[x].SettingsSelect; sm.StoreID = set[x].StoreID; LTS.Store store = DAT.DataAccess.GetStore().Where(i => i.StoreID == sm.StoreID).FirstOrDefault(); sm.StoreLocation = store.StoreLocation; sm.StoreName = store.StoreName; List <LTS.Reader> readers = new List <LTS.Reader>(); readers = DAT.DataAccess.GetReader().Where(j => j.SettingsID == sm.SettingsID).ToList(); for (int j = 0; j < readers.Count; j++) { ReaderMain rm = new ReaderMain(); rm.ReaderID = readers[j].ReaderID; rm.IPaddress = readers[j].IPaddress; rm.NumAntennas = readers[j].NumAntennas; rm.antennas = DAT.DataAccess.GetAntenna().Where(q => q.ReaderID == rm.ReaderID).ToList(); sm.Readers.Add(rm); } settings.Add(sm); } for (int i = 0; i < settings.Count; i++) { dataGridViewSettings.Rows.Add(settings[i].SettingsID, settings[i].SettingsName, settings[i].SettingsSelect, settings[i].Readers.Count, settings[i].TotalAmountAntennas().ToString(), settings[i].StoreName); } dataGridViewSettings.ClearSelection(); } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
public static bool UpdateStore(LTS.Store store) { bool completed = false; try { using (LTS.LTSBase access = new LTS.LTSDC()) { access.UpdateStore(store.StoreLocation, store.StoreName, store.StoreID); completed = true; } } catch (Exception ex) { completed = false; } return(completed); }
/*在指定的store里面扫描epc,并把epc返回*/ private void updateItem_rfid_click(object sender, EventArgs e) { Log.WriteLog(LogType.Trace, "come in updateItem_rfid_click"); lConnectMsg.Text = " "; label4.Visible = false; try { time = 0; lblTimer.Text = time.ToString(); timer = new System.Timers.Timer(); timer.Elapsed += updateItem_timer_elapsed; timer.Interval = 1000; updateItem_enableOrDisable(false); epc = ""; int iStore = cbStore.SelectedIndex; LTS.Store s = listS[iStore]; LTS.Settings set = DAT.DataAccess.GetSettings().Where(y => y.StoreID == s.StoreID && y.SettingsSelect == true).FirstOrDefault(); //在指定的store下进行扫描,并返回扫到的epc if (set != null) { Log.WriteLog(LogType.Trace, "goto connect reader using settings[" + set.SettingsID + "] configuration in store[" + s.StoreID + "]"); updateItem_connect(set); } else { Log.WriteLog(LogType.Warning, "warning:there is not settings available in store[" + s.StoreID + "]"); lStoreMsg.Text = ("Settings not found!"); updateItem_enableOrDisable(true); } } catch (Exception exx) { Log.WriteLog(LogType.Error, "error to get epc from specify store"); lStoreMsg.Text = ("error to get epc from specify store"); updateItem_enableOrDisable(true); } }
private void dataGridView1_SelectionChanged(object sender, EventArgs e) { try { if (dataGridView1.SelectedRows.Count >= 1) { using (DataGridViewRow index = this.dataGridView1.SelectedRows[0]) { int i = index.Index; current = store[i]; label2.Text = store[i].StoreID.ToString(); txtName.Text = store[i].StoreName; txtSur.Text = store[i].StoreLocation; } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//Margo private void StockBookOutRemoval_Load(object sender, EventArgs e) { try { st = DAT.DataAccess.GetStore().ToList(); List <string> S = new List <string>(); for (int x = 0; x < st.Count; x++) { S.Add(st[x].StoreName); } comboBoxStore.DataSource = S; List <LTS.BookOut> bo = new List <LTS.BookOut>(); bo = DAT.DataAccess.GetBookOut().ToList(); for (int i = 0; i < bo.Count; i++) { BookOutMain b = new BookOutMain(); b.BookOutID = bo[i].BookOutID; b.itemID = bo[i].ItemID; b.UserID = bo[i].UserID; b.Reason = bo[i].Reason; b.Project = bo[i].Project; b.Date = bo[i].Date; LTS.Item it = new LTS.Item(); it = DAT.DataAccess.GetItem().Where(u => u.ItemID == b.itemID).FirstOrDefault(); b.ItemStatus = it.ItemStatus; b.EPC = it.TagEPC; b.ProductID = it.ProductID; b.StoreID = it.StoreID; //get the specific product and assign the info to the ItemMain object LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == b.ProductID).FirstOrDefault(); b.ProductName = p.ProductName; b.ProductDescription = p.ProductDescription; b.BrandID = p.BrandID; b.CategoryID = p.CategoryID; b.BarcodeID = p.BarcodeID; //get the specific store and assign the info to the ItemMain object LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == b.StoreID).FirstOrDefault(); b.StoreName = s.StoreName; b.StoreLocation = s.StoreLocation; //get the specific brand and assign the info to the ItemMain object LTS.Brand br = new LTS.Brand(); br = DAT.DataAccess.GetBrand().Where(y => y.BrandID == b.BrandID).FirstOrDefault(); b.BrandName = br.BrandName; b.BrandDescription = br.BrandDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == b.CategoryID).FirstOrDefault(); b.CategoryName = c.CategoryName; b.CategoryDescription = c.CategoryDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == b.BarcodeID).FirstOrDefault(); b.BarcodeNumber = ba.BarcodeNumber; LTS.User us = new LTS.User(); us = DAT.DataAccess.GetUser().Where(h => h.UserID == b.UserID).FirstOrDefault(); b.UserIdentityNumber = us.UserIdentityNumber; b.UserName = us.UserName; b.UserSurname = us.UserSurname; bom.Add(b); dataGridView1.Rows.Add(b.BookOutID, b.EPC, b.BarcodeNumber, b.ProductName, b.Reason, b.Project, b.Date, b.UserName, b.UserSurname); } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//Margo bool connect(LTS.Settings se) { try { lblConnect.Text = "Connecting..."; int index = comboBoxStore.SelectedIndex; if (st != null) { int storeID = st[index].StoreID; LTS.Settings set = se; sm = null; sm = new SettingsMain(); impinjrev.Clear(); sm.SettingsID = set.SettingsID; sm.SettingsName = set.SettingsName; sm.SettingsSelect = set.SettingsSelect; sm.StoreID = set.StoreID; LTS.Store store = DAT.DataAccess.GetStore().Where(i => i.StoreID == sm.StoreID).FirstOrDefault(); sm.StoreLocation = store.StoreLocation; sm.StoreName = store.StoreName; List <LTS.Reader> readers = new List <LTS.Reader>(); readers = DAT.DataAccess.GetReader().Where(j => j.SettingsID == sm.SettingsID).ToList(); for (int j = 0; j < readers.Count; j++) { ReaderMain rm = new ReaderMain(); rm.ReaderID = readers[j].ReaderID; rm.IPaddress = readers[j].IPaddress; rm.NumAntennas = readers[j].NumAntennas; rm.antennas = DAT.DataAccess.GetAntenna().Where(q => q.ReaderID == rm.ReaderID).ToList(); sm.Readers.Add(rm); } bool checks = true; for (int x = 0; x < sm.Readers.Count; x++) { ImpinjRevolution ir = new ImpinjRevolution(); ir.ReaderScanMode = ScanMode.ScanItem; ir.HostName = sm.Readers[x].IPaddress; ir.Antennas = sm.Readers[x].antennas; ir.TagRead += ir_TagRead; ir.Connect(); impinjrev.Add(ir); if (!ir.isConnected) { if (checks == true) { checks = false; } } } if (checks == true) { lblConnect.Text = "Connected"; timer.Start(); impinjrev.ForEach(imp => { imp.TagRead += ir_TagRead; imp.StartRead(); }); ((Form1)this.Parent.Parent.Parent.Parent).scan = true; lblConnect.Text = "Reading..."; lblTimer.Text = time.ToString(); } else { lblConnect.Text = "Not Connected!"; timer.Stop(); timer.Elapsed -= timer_Elapsed; time = 0; for (int i = 0; i < impinjrev.Count; i++) { impinjrev[i].StopRead(); impinjrev[i].Disconnect(); } EnableOrDisable(true); ((Form1)this.Parent.Parent.Parent.Parent).scan = false; } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } return(true); }
//Devon private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked) { whatCheck = "All"; dataGridView2.Rows.Clear(); List <LTS.Item> i = new List <LTS.Item>(); i = DAT.DataAccess.GetItem().ToList();//list from db for (int x = 0; x < i.Count; x++) { ItemMain im = new ItemMain(); //assign the item info to the ItemMain object im.itemID = i[x].ItemID; im.EPC = i[x].TagEPC; im.ItemStatus = i[x].ItemStatus; im.ProductID = i[x].ProductID; im.StoreID = i[x].StoreID; //get the specific product and assign the info to the ItemMain object LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault(); im.ProductName = p.ProductName; im.ProductDescription = p.ProductDescription; im.BrandID = p.BrandID; im.CategoryID = p.CategoryID; im.BarcodeID = p.BarcodeID; //get the specific store and assign the info to the ItemMain object LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault(); im.StoreName = s.StoreName; im.StoreLocation = s.StoreLocation; //get the specific brand and assign the info to the ItemMain object LTS.Brand b = new LTS.Brand(); b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault(); im.BrandName = b.BrandName; im.BrandDescription = b.BrandDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault(); im.CategoryName = c.CategoryName; im.CategoryDescription = c.CategoryDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault(); im.BarcodeNumber = ba.BarcodeNumber; imList.Add(im); dataGridView2.Rows.Add(i[x].ItemID, i[x].TagEPC, p.ProductName, p.ProductDescription, ba.BarcodeNumber, b.BrandName, c.CategoryName , i[x].ItemStatus, s.StoreName); } } else { dataGridView2.Rows.Clear(); } }
//Devon private void button1_Click(object sender, EventArgs e) { dataGridView2.Rows.Clear(); string comboVal = comboBoxStore.SelectedItem.ToString(); int sIndex = comboBoxStore.SelectedIndex; LTS.Store st = listS[sIndex]; int storeID = st.StoreID; List <LTS.Item> i; if (whatCheck == "OutOfStock") { i = DAT.DataAccess.GetItem().Where(f => f.StoreID == storeID && f.ItemStatus == false).ToList(); } else if (whatCheck == "InStock") { i = DAT.DataAccess.GetItem().Where(f => f.StoreID == storeID && f.ItemStatus == true).ToList(); } else { i = DAT.DataAccess.GetItem().Where(f => f.StoreID == storeID).ToList(); } for (int x = 0; x < i.Count; x++) { ItemMain im = new ItemMain(); //assign the item info to the ItemMain object im.itemID = i[x].ItemID; im.EPC = i[x].TagEPC; im.ItemStatus = i[x].ItemStatus; im.ProductID = i[x].ProductID; im.StoreID = i[x].StoreID; //get the specific product and assign the info to the ItemMain object LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault(); im.ProductName = p.ProductName; im.ProductDescription = p.ProductDescription; im.BrandID = p.BrandID; im.CategoryID = p.CategoryID; im.BarcodeID = p.BarcodeID; //get the specific store and assign the info to the ItemMain object LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault(); im.StoreName = s.StoreName; im.StoreLocation = s.StoreLocation; //get the specific brand and assign the info to the ItemMain object LTS.Brand b = new LTS.Brand(); b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault(); im.BrandName = b.BrandName; im.BrandDescription = b.BrandDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault(); im.CategoryName = c.CategoryName; im.CategoryDescription = c.CategoryDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault(); im.BarcodeNumber = ba.BarcodeNumber; imList.Add(im); dataGridView2.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName , im.ItemStatus, im.StoreName); } }
private void btnlogin_Click(object sender, EventArgs e) { try { labelError1.Visible = false; labelError2.Visible = false; labelError3.Visible = false; txterror.Visible = false; bool check = true; if (txtName.Text == "") { labelError1.Text = "Please enter store name!"; labelError1.Visible = true; check = false; } if (txtSur.Text == "") { labelError2.Text = "Please enter store location!"; labelError2.Visible = true; check = false; } if (current == null) { txterror.Visible = true; check = false; } if (check) { bool update = false; if (current.StoreName == txtName.Text) { current.StoreName = txtName.Text; current.StoreLocation = txtSur.Text; update = DAT.DataAccess.UpdateStore(current); if (update) { MessageBox.Show("The store updated successfully"); ((Main)this.Parent.Parent).ChangeView <Pages.Store.Store>(); } else { MessageBox.Show("The store was not updated successfully"); ((Main)this.Parent.Parent).ChangeView <Pages.Store.Store>(); } } else { LTS.Store s = DAT.DataAccess.GetStore().Where(y => y.StoreName == txtName.Text).FirstOrDefault(); if (s == null) { current.StoreName = txtName.Text; current.StoreLocation = txtSur.Text; update = DAT.DataAccess.UpdateStore(current); if (update) { MessageBox.Show("The store updated successfully"); ((Main)this.Parent.Parent).ChangeView <Pages.Store.Store>(); } else { MessageBox.Show("The store was not updated successfully"); ((Main)this.Parent.Parent).ChangeView <Pages.Store.Store>(); } } else { labelError3.Visible = true; } } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
private void updateItem_load(object sender, EventArgs e) { Log.WriteLog(LogType.Trace, "come in updateItem_load"); //load store names into combo box from db listS = DAT.DataAccess.GetStore().ToList(); List <string> S = new List <string>(); for (int x = 0; x < listS.Count; x++) { S.Add(listS[x].StoreName); } cbStore.DataSource = S; if (listS.Count > 1) { cbStore.SelectedIndex = 0; } //load barcode into combo box from db listBar = DAT.DataAccess.GetBarcode().ToList(); List <string> Ba = new List <string>(); for (int x = 0; x < listBar.Count; x++) { Ba.Add(listBar[x].BarcodeNumber); } cbBarcode.DataSource = Ba; //会触发select index change 事件 if (listBar.Count > 1) { cbBarcode.SelectedIndex = 0; } List <LTS.Item> i = new List <LTS.Item>(); i = DAT.DataAccess.GetItem().ToList();//list from db imList = new List <ItemMain>(); for (int x = 0; x < i.Count; x++) { ItemMain im = new ItemMain(); //assign the item info to the ItemMain object im.itemID = i[x].ItemID; im.EPC = i[x].TagEPC; im.ItemStatus = i[x].ItemStatus; im.ProductID = i[x].ProductID; im.StoreID = i[x].StoreID; Log.WriteLog(LogType.Trace, "goto load item[" + im.itemID + "] detail info from database, the summary info is:epc[" + im.EPC + "], item status[" + im.ItemStatus + "]," + "product id[" + im.ProductID + "], store id[" + im.StoreID + "]"); //get the specific product and assign the info to the ItemMain object LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault(); if (null == p) { Log.WriteLog(LogType.Error, "error to get product[" + im.ProductID + "] info while loading item[" + im.itemID + "] detail info."); continue; } im.ProductName = p.ProductName; im.ProductDescription = p.ProductDescription; im.BrandID = p.BrandID; im.CategoryID = p.CategoryID; im.BarcodeID = p.BarcodeID; //get the specific store and assign the info to the ItemMain object LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault(); if (null == s) { Log.WriteLog(LogType.Error, "error to get store[" + im.StoreID + "] info while loading item[" + im.itemID + "] detail info."); continue; } im.StoreName = s.StoreName; im.StoreLocation = s.StoreLocation; //get the specific brand and assign the info to the ItemMain object LTS.Brand b = new LTS.Brand(); b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault(); if (null == b) { Log.WriteLog(LogType.Error, "error to get brand[" + im.BrandID + "] info while loading item[" + im.itemID + "] detail info."); continue; } im.BrandName = b.BrandName; im.BrandDescription = b.BrandDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault(); if (null == c) { Log.WriteLog(LogType.Error, "error to get category[" + im.CategoryID + "] info while loading item[" + im.itemID + "] detail info."); continue; } im.CategoryName = c.CategoryName; im.CategoryDescription = c.CategoryDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault(); if (null == ba) { Log.WriteLog(LogType.Error, "error to get barcode[" + im.BarcodeID + "] info while loading item[" + im.itemID + "] detail info."); continue; } im.BarcodeNumber = ba.BarcodeNumber; imList.Add(im); dgvItem.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName , im.ItemStatus, im.StoreName); Log.WriteLog(LogType.Trace, "success to load item[" + im.itemID + "] detail info:epc[" + im.EPC + "], productName[" + im.ProductName + "], productDesciption[" + im.ProductDescription + "]" + "barcode[" + im.BarcodeNumber + "], brandName[" + im.BrandName + "], categoryName[" + im.CategoryName + "], itemStatus[" + im.ItemStatus + "], storeName[" + im.StoreName + "]"); } }
//Devon private void radioButton4_CheckedChanged(object sender, EventArgs e) { try { if (radioButton4.Checked) { whatCheck = "OutOfStock"; dataGridView2.Rows.Clear(); List <LTS.Item> i = new List <LTS.Item>(); i = DAT.DataAccess.GetItem().Where(s => s.ItemStatus == false).ToList();//list from db List <ItemMain> imList = new List <ItemMain>(); for (int x = 0; x < i.Count; x++) { ItemMain im = new ItemMain(); //assign the item info to the ItemMain object im.itemID = i[x].ItemID; im.EPC = i[x].TagEPC; im.ItemStatus = i[x].ItemStatus; im.ProductID = i[x].ProductID; im.StoreID = i[x].StoreID; //get the specific product and assign the info to the ItemMain object LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault(); im.ProductName = p.ProductName; im.ProductDescription = p.ProductDescription; im.BrandID = p.BrandID; im.CategoryID = p.CategoryID; im.BarcodeID = p.BarcodeID; //get the specific store and assign the info to the ItemMain object LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault(); im.StoreName = s.StoreName; im.StoreLocation = s.StoreLocation; //get the specific brand and assign the info to the ItemMain object LTS.Brand b = new LTS.Brand(); b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault(); im.BrandName = b.BrandName; im.BrandDescription = b.BrandDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault(); im.CategoryName = c.CategoryName; im.CategoryDescription = c.CategoryDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault(); im.BarcodeNumber = ba.BarcodeNumber; imList.Add(im); dataGridView2.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName , im.ItemStatus, im.StoreName); } } else { dataGridView2.Rows.Clear(); } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//Margo private void button5_Click(object sender, EventArgs e) { try { lblSelect.Visible = false; if (listS.Where(u => u.StoreName == comboBoxStore.SelectedItem.ToString()).FirstOrDefault() != null) { if (set != null) { button4.Enabled = false; button2.Enabled = false; comboBoxStore.Enabled = false; lblConnect.Text = "Connecting ..."; lblStartRead.Visible = false; lblStop.Visible = false; btnStart.Enabled = false; lblConnect.Visible = true; sm = null; sm = new SettingsMain(); impinjrev.Clear(); sm.SettingsID = set.SettingsID; sm.SettingsName = set.SettingsName; sm.SettingsSelect = set.SettingsSelect; sm.StoreID = set.StoreID; LTS.Store store = DAT.DataAccess.GetStore().Where(i => i.StoreID == sm.StoreID).FirstOrDefault(); sm.StoreLocation = store.StoreLocation; sm.StoreName = store.StoreName; List <LTS.Reader> readers = new List <LTS.Reader>(); readers = DAT.DataAccess.GetReader().Where(j => j.SettingsID == sm.SettingsID).ToList(); for (int j = 0; j < readers.Count; j++) { ReaderMain rm = new ReaderMain(); rm.ReaderID = readers[j].ReaderID; rm.IPaddress = readers[j].IPaddress; rm.NumAntennas = readers[j].NumAntennas; rm.antennas = DAT.DataAccess.GetAntenna().Where(q => q.ReaderID == rm.ReaderID).ToList(); sm.Readers.Add(rm); } bool checks = true; for (int x = 0; x < sm.Readers.Count; x++) { ImpinjRevolution ir = new ImpinjRevolution(); ir.ReaderScanMode = ScanMode.FullScan; ir.HostName = sm.Readers[x].IPaddress; ir.Antennas = sm.Readers[x].antennas; ir.TagRead += ir_TagRead; ir.Connect(); impinjrev.Add(ir); if (!ir.isConnected) { if (checks == true) { checks = false; } } } if (checks == true) { config = true; lblConnect.Text = "Connected"; btnStart.Enabled = true; btnStop.Enabled = false; ((Form1)this.Parent.Parent.Parent.Parent).scan = true; } else { lblConnect.Text = "Not Connected"; } } else { MessageBox.Show("The Store selected does not have a setting set, please go to the Select Setting page and choose a setting!", "", MessageBoxButtons.OKCancel); } } else { lblSelect.Visible = true; } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//Devon private void UpdateStock_Load(object sender, EventArgs e) { try { ChangeView <SearchWithEPC>(); //load store names into combo box from db listS = DAT.DataAccess.GetStore().ToList(); List <string> S = new List <string>(); for (int x = 0; x < listS.Count; x++) { S.Add(listS[x].StoreName); } comboBoxStore.DataSource = S; //load barcode into combo box from db listBar = DAT.DataAccess.GetBarcode().ToList(); List <string> Ba = new List <string>(); for (int x = 0; x < listBar.Count; x++) { Ba.Add(listBar[x].BarcodeNumber); } comboBox1.DataSource = Ba; List <LTS.Item> i = new List <LTS.Item>(); i = DAT.DataAccess.GetItem().ToList();//list from db imList = new List <ItemMain>(); for (int x = 0; x < i.Count; x++) { ItemMain im = new ItemMain(); //assign the item info to the ItemMain object im.itemID = i[x].ItemID; im.EPC = i[x].TagEPC; im.ItemStatus = i[x].ItemStatus; im.ProductID = i[x].ProductID; im.StoreID = i[x].StoreID; //get the specific product and assign the info to the ItemMain object LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault(); im.ProductName = p.ProductName; im.ProductDescription = p.ProductDescription; im.BrandID = p.BrandID; im.CategoryID = p.CategoryID; im.BarcodeID = p.BarcodeID; //get the specific store and assign the info to the ItemMain object LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault(); im.StoreName = s.StoreName; im.StoreLocation = s.StoreLocation; //get the specific brand and assign the info to the ItemMain object LTS.Brand b = new LTS.Brand(); b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault(); im.BrandName = b.BrandName; im.BrandDescription = b.BrandDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault(); im.CategoryName = c.CategoryName; im.CategoryDescription = c.CategoryDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault(); im.BarcodeNumber = ba.BarcodeNumber; imList.Add(im); dataGridView2.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName , im.ItemStatus, im.StoreName); } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
private void item_radioAll_click(object sender, EventArgs e) { Log.WriteLog(LogType.Trace, "come in item_radioAll_click"); if (radioAll.Checked) { try { //从数据库中读取item记录到内存 List <LTS.Item> i = new List <LTS.Item>(); i = DAT.DataAccess.GetItem().ToList(); List <ItemMain> imList = new List <ItemMain>(); //根据item记录字段,组装厂家,类型等信息到内存 for (int x = 0; x < i.Count; x++) { ItemMain im = new ItemMain(); //将item记录信息保存到内存 im.itemID = i[x].ItemID; im.EPC = i[x].TagEPC; im.ItemStatus = i[x].ItemStatus; im.ProductID = i[x].ProductID; im.StoreID = i[x].StoreID; Log.WriteLog(LogType.Trace, "goto get item[" + im.itemID + "] info into memery:epc[" + im.EPC + "], status[{" + im.ItemStatus + "}], pruduct id[{" + im.ProductID + "}], store id[{" + im.StoreID + "}]"); //组装item的产品信息 LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault(); im.ProductName = p.ProductName; im.ProductDescription = p.ProductDescription; im.BrandID = p.BrandID; im.CategoryID = p.CategoryID; im.BarcodeID = p.BarcodeID; //组装item的store信息 LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault(); im.StoreName = s.StoreName; im.StoreLocation = s.StoreLocation; //组装item的厂家信息 LTS.Brand b = new LTS.Brand(); b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault(); im.BrandName = b.BrandName; im.BrandDescription = b.BrandDescription; //组装item的类型信息 LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault(); im.CategoryName = c.CategoryName; im.CategoryDescription = c.CategoryDescription; //组装item的条形码信息 LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault(); im.BarcodeNumber = ba.BarcodeNumber; //item完整信息添加到list中,并在控件中展示 imList.Add(im); dataGridView1.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName , im.ItemStatus, im.StoreName); } } catch (Exception ex) { Log.WriteLog(LogType.Error, "error to show item info into data grid view for all"); } } else { dataGridView1.Rows.Clear(); } }
bool updateItem_connect(LTS.Settings se) { Log.WriteLog(LogType.Trace, "come in updateItem_connect"); try { lConnectMsg.Text = "Connecting..."; int index = cbStore.SelectedIndex; int storeID = listS[index].StoreID; LTS.Settings set = se; sm = null; sm = new SettingsMain(); impinjrev.Clear(); sm.SettingsID = set.SettingsID; sm.SettingsName = set.SettingsName; sm.SettingsSelect = set.SettingsSelect; sm.StoreID = set.StoreID; LTS.Store store = DAT.DataAccess.GetStore().Where(i => i.StoreID == sm.StoreID).FirstOrDefault(); if (null == store) { Log.WriteLog(LogType.Error, "error to get store with id[" + set.StoreID + "]"); return(false); } sm.StoreLocation = store.StoreLocation; sm.StoreName = store.StoreName; Log.WriteLog(LogType.Trace, "success to get settings[" + sm.SettingsID + "] witch in store[" + set.StoreID + "] info:settingsName[" + set.SettingsName + "], " + "select flag[" + set.SettingsSelect + "], the storeName[" + store.StoreName + "] and storeLocation[" + store.StoreLocation + "]"); List <LTS.Reader> readers = new List <LTS.Reader>(); readers = DAT.DataAccess.GetReader().Where(j => j.SettingsID == sm.SettingsID).ToList(); if (null == readers) { Log.WriteLog(LogType.Error, "error to get readers in settings[" + sm.SettingsID + "]"); return(false); } for (int j = 0; j < readers.Count; j++) { ReaderMain rm = new ReaderMain(); rm.ReaderID = readers[j].ReaderID; rm.IPaddress = readers[j].IPaddress; rm.NumAntennas = readers[j].NumAntennas; rm.antennas = DAT.DataAccess.GetAntenna().Where(q => q.ReaderID == rm.ReaderID).ToList(); sm.Readers.Add(rm); } bool checks = true; Log.WriteLog(LogType.Trace, "success go get " + readers.Count + " readers with in settings[" + sm.SettingsID + "] into memery"); Log.WriteLog(LogType.Trace, "success go get " + readers.Count + " readers with in settings[" + sm.SettingsID + "] into memery"); //根据settings上的读写器配置,进行读写器连接操作 for (int x = 0; x < sm.Readers.Count; x++) { bool bOk = true; //针对每一个reader配置生成一个reader解决方案节点 ImpinjRevolution ir = new ImpinjRevolution(); ir.ReaderScanMode = ScanMode.ScanItem; ir.HostName = sm.Readers[x].IPaddress; ir.Antennas = sm.Readers[x].antennas; ir.isConnected = false; //ir.TagRead += ir_TagRead; Log.WriteLog(LogType.Trace, "goto connect to reader with ip[" + ir.HostName + "]"); //连接到指定的读写器上 if (!ir.ir_connectReader()) { bOk = false; Log.WriteLog(LogType.Error, "error to connect to reader[" + ir.HostName + "]"); } impinjrev.Add(ir); if (!bOk) { if (checks == true) { Log.WriteLog(LogType.Trace, "goto set the check flag into false status."); checks = false; } } } Log.WriteLog(LogType.Trace, "after connect to all the readers"); if (checks == true) { lConnectMsg.Text = "Connected"; //启动定时器,定时器超时后,执行定时器超时函数 timer.Start(); //遍历读写器数组,为他们注册委托事件,并启动读写器 impinjrev.ForEach(imp => { imp.dReadHandler += updateItem_ir_tagRead; imp.ir_startRead(); }); Log.WriteLog(LogType.Trace, "success to start all readers"); ((Form1)this.Parent.Parent.Parent.Parent).scan = true; lConnectMsg.Text = "Reading..."; } else { lConnectMsg.Text = "Not Connected!"; timer.Stop(); timer.Elapsed -= updateItem_timer_elapsed; time = 0; for (int i = 0; i < impinjrev.Count; i++) { impinjrev[i].ir_stopRead(); impinjrev[i].ir_disconnect(); } updateItem_enableOrDisable(true); ((Form1)this.Parent.Parent.Parent.Parent).scan = false; } return(true); } catch (Exception ex) { Log.WriteLog(LogType.Error, "there is something wrong during connect to readers. the error msg is " + ex.Message + ""); MessageBox.Show("Sorry Something went wrong, the action was not completed!"); return(true); } }
//当改变store时,显示旗下settings的配置信息 private void scanItem_cbStore_selectIdxChg(object sender, EventArgs e) { panel1.Visible = false; int index = cbStore.SelectedIndex; LTS.Store stStore = listS[index]; int iStoreId = stStore.StoreID; Log.WriteLog(LogType.Trace, "come in scanItem_cbStore_selectIdxChg"); Log.WriteLog(LogType.Trace, "goto get store[" + iStoreId + "] avaliable settings from database"); try { //获取store生效的settings gstSettings = DAT.DataAccess.GetSettings().Where(s => s.StoreID == iStoreId && s.SettingsSelect == true).FirstOrDefault(); if (gstSettings != null) { List <LTS.Reader> stReader; //获取settings配置的readers stReader = DAT.DataAccess.GetReader().Where(y => y.SettingsID == gstSettings.SettingsID).ToList(); if (stReader == null) { Log.WriteLog(LogType.Error, "error to get settings[" + gstSettings.SettingsID + "] readers info"); return; } Log.WriteLog(LogType.Trace, "success to get " + stReader.Count + " reader(s) from settings[" + gstSettings.SettingsID + "]"); //提取reader信息,并显示在list box中 List <string> sReaderInfo = new List <string>(); for (int q = 0; q < stReader.Count; q++) { sReaderInfo.Add(stReader[q].IPaddress + " : " + stReader[q].NumAntennas + " antenna(s)"); Log.WriteLog(LogType.Trace, "success to add reader[" + stReader[q].ReaderID + "] with [" + stReader[q].NumAntennas + "] antenna(s) into front"); } lbReader.DataSource = sReaderInfo; setName.Text = gstSettings.SettingsName; //在小窗口显示reader信息 scanItem_showReaderInfo(true, iStoreId); /*从数据库中获取指定store下的所有item*/ if (!scanItem_item2List(iStoreId, ref theList)) { Log.WriteLog(LogType.Error, "error to call scanItem_Items2List"); return; } //将items通过list box显示 if (!scanItem_itemList2ListBox(ref theList)) { Log.WriteLog(LogType.Error, "error to call scanItem_itemList2ListBox"); return; } } else { Log.WriteLog(LogType.Trace, "there is not avaliable settings in store[" + iStoreId + "], please change another store."); scanItem_showReaderInfo(false, iStoreId); } } catch (Exception ex) { Log.WriteLog(LogType.Error, "the exception is:" + ex.Message + "."); } }
private void item_radioOutStock_click(object sender, EventArgs e) { Log.WriteLog(LogType.Trace, "come in item_radioOutStock_click"); if (radioOutStock.Checked) { try { List <LTS.Item> i = new List <LTS.Item>(); i = DAT.DataAccess.GetItem().Where(s => s.ItemStatus == false).ToList(); //list from db List <ItemMain> imList = new List <ItemMain>(); for (int x = 0; x < i.Count; x++) { ItemMain im = new ItemMain(); //assign the item info to the ItemMain object im.itemID = i[x].ItemID; im.EPC = i[x].TagEPC; im.ItemStatus = i[x].ItemStatus; im.ProductID = i[x].ProductID; im.StoreID = i[x].StoreID; //get the specific product and assign the info to the ItemMain object LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault(); im.ProductName = p.ProductName; im.ProductDescription = p.ProductDescription; im.BrandID = p.BrandID; im.CategoryID = p.CategoryID; im.BarcodeID = p.BarcodeID; //get the specific store and assign the info to the ItemMain object LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault(); im.StoreName = s.StoreName; im.StoreLocation = s.StoreLocation; //get the specific brand and assign the info to the ItemMain object LTS.Brand b = new LTS.Brand(); b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault(); im.BrandName = b.BrandName; im.BrandDescription = b.BrandDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault(); im.CategoryName = c.CategoryName; im.CategoryDescription = c.CategoryDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault(); im.BarcodeNumber = ba.BarcodeNumber; imList.Add(im); dataGridView1.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName , im.ItemStatus, im.StoreName); } } catch (Exception ex) { Log.WriteLog(LogType.Error, "error to show item info into data grid view for out stock "); } } else { dataGridView1.Rows.Clear(); } }
//Tiaan private void BookStockOut_Load(object sender, EventArgs e) { try { imList = new List <ItemMain>(); item = DAT.DataAccess.GetItem().Where(u => u.ItemStatus == true).ToList(); if (item != null) { for (int x = 0; x < item.Count; x++) { ItemMain im = new ItemMain(); //assign the item info to the ItemMain object im.itemID = item[x].ItemID; im.EPC = item[x].TagEPC; im.ItemStatus = item[x].ItemStatus; im.ProductID = item[x].ProductID; im.StoreID = item[x].StoreID; //get the specific product and assign the info to the ItemMain object LTS.Product p = new LTS.Product(); p = DAT.DataAccess.GetProduct().Where(h => h.ProductID == im.ProductID).FirstOrDefault(); im.ProductName = p.ProductName; im.ProductDescription = p.ProductDescription; im.BrandID = p.BrandID; im.CategoryID = p.CategoryID; im.BarcodeID = p.BarcodeID; //get the specific store and assign the info to the ItemMain object LTS.Store s = new LTS.Store(); s = DAT.DataAccess.GetStore().Where(j => j.StoreID == im.StoreID).FirstOrDefault(); im.StoreName = s.StoreName; im.StoreLocation = s.StoreLocation; //get the specific brand and assign the info to the ItemMain object LTS.Brand b = new LTS.Brand(); b = DAT.DataAccess.GetBrand().Where(y => y.BrandID == im.BrandID).FirstOrDefault(); im.BrandName = b.BrandName; im.BrandDescription = b.BrandDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Category c = new LTS.Category(); c = DAT.DataAccess.GetCategory().Where(z => z.CategoryID == im.CategoryID).FirstOrDefault(); im.CategoryName = c.CategoryName; im.CategoryDescription = c.CategoryDescription; //get the sepcific category and assign the info to the ItemMain object LTS.Barcode ba = new LTS.Barcode(); ba = DAT.DataAccess.GetBarcode().Where(a => a.BarcodeID == im.BarcodeID).FirstOrDefault(); im.BarcodeNumber = ba.BarcodeNumber; imList.Add(im); dataGridView1.Rows.Add(im.itemID, im.EPC, im.ProductName, im.ProductDescription, im.BarcodeNumber, im.BrandName, im.CategoryName , im.ItemStatus, im.StoreName); } } st = new List <LTS.Store>(); st = DAT.DataAccess.GetStore().ToList(); List <string> S = new List <string>(); for (int x = 0; x < st.Count; x++) { S.Add(st[x].StoreName); } comboBoxStore.DataSource = S; } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }