private void btnAdd_Click(object sender, EventArgs e) { try { label3.Text = ""; label2.Text = ""; if (txtBrandName.Text == "") { label2.Text = "Please add a Brand Name"; } if (txtBrandDesc.Text == "") { label3.Text = "Please add a Brand Description"; } if (label2.Text == "" && label3.Text == "") { LTS.Brand c = DAT.DataAccess.GetBrand().Where(i => i.BrandName == txtBrandName.Text).FirstOrDefault(); if (c == null) { try { LTS.Brand b = new LTS.Brand(); b.BrandName = txtBrandName.Text; b.BrandDescription = txtBrandDesc.Text; int bID = DAT.DataAccess.AddBrand(b); if (bID == -1) { MessageBox.Show("An Error Has Occured, Please try Again"); txtBrandName.Text = ""; txtBrandDesc.Text = ""; } else { MessageBox.Show("Added Successfully!"); goBack(); //((Main)this.Parent.Parent).ChangeView<Categories>(); } } catch (Exception eex) { MessageBox.Show("Please try Again"); } } else { label2.Text = "Sorry, this brand name already exists"; } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
public static LTS.Brand GetBrandItemByID(int?BrandID) { LTS.Brand brand = new LTS.Brand(); try { using (LTS.LTSBase access = new LTS.LTSDC()) { brand = access.Brand.Where(o => o.BrandID == BrandID).FirstOrDefault(); } } catch (Exception ex) { } return(brand); }
public static int AddBrand(LTS.Brand brand) { int?BrandID = -1; try { using (LTS.LTSBase access = new LTS.LTSDC()) { access.InsertBrand(brand.BrandDescription, brand.BrandName, ref BrandID); } } catch (Exception ex) { } return(BrandID.Value); }
public static bool UpdateBrand(LTS.Brand brand) { bool completed = false; try { using (LTS.LTSBase access = new LTS.LTSDC()) { access.UpdateBrand(brand.BrandDescription, brand.BrandName, brand.BrandID); completed = true; } } catch (Exception ex) { completed = false; } return(completed); }
private void bAdd_Click(object sender, EventArgs e) { int iRet = 0; int iID = 0; if (this.tBrandName.Text == "" || this.tBrandDesc.Text == "") { MessageBox.Show("please input brand name and brand description."); return; } LTS.Brand stBrand = new LTS.Brand();; stBrand.BrandName = this.tBrandName.Text; stBrand.BrandDescription = this.tBrandDesc.Text; /*去重*/ iRet = Db.BrandIsExist(stBrand.BrandName, ref iID); if (iRet == -1) { Log.WriteLog(LogType.Error, "error to call BrandIsExist"); //MessageBox.Show("error to call BrandIsExist"); return; } else if (iRet == 1) { Log.WriteLog(LogType.Trace, "the name [" + stBrand.BrandName + "] already in database, you should use another name"); MessageBox.Show("the name[" + stBrand.BrandName + "] already in database, you should use another name."); return; } /*brand添加到数据库*/ iID = DAT.DataAccess.AddBrand(stBrand); if (iID != -1) { Log.WriteLog(LogType.Trace, "success to insert brand with name[" + stBrand.BrandName + "] and id[" + iID + "]into db."); MessageBox.Show("sussess to add brand name[" + stBrand.BrandName + "]into db."); } else { Log.WriteLog(LogType.Error, "error to insert brand with name[" + stBrand.BrandName + "] into db."); //MessageBox.Show("error to add brand name[" + stBrand.BrandName + "] into db."); } }
//Marius private void Product_Load(object sender, EventArgs e) { try { List <LTS.Product> prod = new List <LTS.Product>(); prod = DAT.DataAccess.GetProduct().ToList(); for (int i = 0; i < prod.Count; i++) { ProductMain pmThis = new ProductMain(); pmThis.ProductID = prod[i].ProductID; pmThis.ProductName = prod[i].ProductName; pmThis.ProductDescription = prod[i].ProductDescription; pmThis.CategoryID = prod[i].CategoryID; pmThis.BrandID = prod[i].BrandID; pmThis.BarcodeID = prod[i].BarcodeID; pmThis.amountItems = DAT.DataAccess.GetItem().Where(u => u.ProductID == pmThis.ProductID && u.ItemStatus == true).ToList().Count; LTS.Category c = DAT.DataAccess.GetCategory().Where(o => o.CategoryID == prod[i].CategoryID).FirstOrDefault(); pmThis.CategoryName = c.CategoryName; pmThis.CategoryDescription = c.CategoryDescription; LTS.Brand b = DAT.DataAccess.GetBrand().Where(o => o.BrandID == prod[i].BrandID).FirstOrDefault(); pmThis.BrandName = b.BrandName; pmThis.BrandDescription = b.BrandDescription; LTS.Barcode bar = DAT.DataAccess.GetBarcode().Where(o => o.BarcodeID == prod[i].BarcodeID).FirstOrDefault(); pmThis.BarcodeNumber = bar.BarcodeNumber; pm.Add(pmThis); dgvProducts.Rows.Add(pmThis.ProductID, pmThis.ProductName, pmThis.ProductDescription, pmThis.BarcodeNumber, pmThis.BrandName, pmThis.CategoryName, pmThis.amountItems); } dgvProducts.ClearSelection(); } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
private void dgvUpdateProduct_SelectionChanged(object sender, EventArgs e) { try { if (dgvUpdateProduct.SelectedRows.Count == 1) { int index = dgvUpdateProduct.SelectedRows[0].Index; ProductMain p = new ProductMain(); p = pm[index]; current = p; lblProdID.Text = p.ProductID.ToString(); tbProdName.Text = p.ProductName.ToString(); tbProdDescr.Text = p.ProductDescription.ToString(); tbBarcode.Text = p.BarcodeNumber.ToString(); LTS.Category cat = new LTS.Category(); cat = listC.Where(o => o.CategoryID == p.CategoryID).FirstOrDefault(); if (cat != null) { int catIndex = listC.IndexOf(cat); cbCategoryName.SelectedIndex = catIndex; } LTS.Brand brand = new LTS.Brand(); brand = listB.Where(z => z.BrandID == p.BrandID).FirstOrDefault(); if (brand != null) { int brandInd = listB.IndexOf(brand); cbBrandName.SelectedIndex = brandInd; } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//Marius private void UpdateProduct_Load(object sender, EventArgs e) { try { listBar = DAT.DataAccess.GetBarcode().ToList(); listB = new List <LTS.Brand>(); listB = DAT.DataAccess.GetBrand().ToList(); for (int a = 0; a < listB.Count; a++) { Brand.Add(listB[a].BrandName); } listC = new List <LTS.Category>(); listC = DAT.DataAccess.GetCategory().ToList(); for (int b = 0; b < listC.Count; b++) { Category.Add(listC[b].CategoryName); } cbBrandName.DataSource = Brand; cbCategoryName.DataSource = Category; lblBarVal.Visible = false; lblDesVal.Visible = false; lblNameVal.Visible = false; List <LTS.Product> prod = new List <LTS.Product>(); prod = DAT.DataAccess.GetProduct().ToList(); for (int i = 0; i < prod.Count; i++) { ProductMain pmThis = new ProductMain(); pmThis.ProductID = prod[i].ProductID; pmThis.ProductName = prod[i].ProductName; pmThis.ProductDescription = prod[i].ProductDescription; pmThis.CategoryID = prod[i].CategoryID; pmThis.BrandID = prod[i].BrandID; pmThis.BarcodeID = prod[i].BarcodeID; pmThis.amountItems = DAT.DataAccess.GetItem().Where(u => u.ProductID == pmThis.ProductID && u.ItemStatus == true).ToList().Count; LTS.Category c = DAT.DataAccess.GetCategory().Where(o => o.CategoryID == prod[i].CategoryID).FirstOrDefault(); pmThis.CategoryName = c.CategoryName; pmThis.CategoryDescription = c.CategoryDescription; LTS.Brand b = DAT.DataAccess.GetBrand().Where(o => o.BrandID == prod[i].BrandID).FirstOrDefault(); pmThis.BrandName = b.BrandName; pmThis.BrandDescription = b.BrandDescription; LTS.Barcode bar = DAT.DataAccess.GetBarcode().Where(o => o.BarcodeID == prod[i].BarcodeID).FirstOrDefault(); pmThis.BarcodeNumber = bar.BarcodeNumber; pm.Add(pmThis); dgvUpdateProduct.Rows.Add(pmThis.ProductID, pmThis.ProductName, pmThis.ProductDescription, pmThis.BarcodeNumber, pmThis.BrandName, pmThis.CategoryName, pmThis.amountItems); } foreach (DataGridViewColumn column in dgvUpdateProduct.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
//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(); } }
//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!"); } }
//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!"); } }
//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); } }
//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!"); } }
//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(); } }
private void btnlogin_Click(object sender, EventArgs e) { try { label3.Text = ""; label4.Text = ""; if (txtName.Text == "") { label3.Text = "Please add a Category Name"; } if (txtSur.Text == "") { label4.Text = "Please add a Category Description"; } if (label4.Text == "" && label3.Text == "") { if (txtName.Text == oldName) { try { int bID; bID = Int32.Parse(label2.Text); LTS.Brand UB = new LTS.Brand(); UB.BrandID = bID; UB.BrandName = txtName.Text; UB.BrandDescription = txtSur.Text; bool updateB = DAT.DataAccess.UpdateBrand(UB); if (updateB) { if (DialogResult.OK == MessageBox.Show("Category Updated Successfully")) { ((Main)this.Parent.Parent).ChangeView <Pages.Items.Brands>(); } } else { if (DialogResult.OK == MessageBox.Show("Category was not Updated Successfully")) { ((Main)this.Parent.Parent).ChangeView <Pages.Items.Brands>(); } } } catch (Exception eex) { MessageBox.Show("Please try Again"); } } else { LTS.Brand b = DAT.DataAccess.GetBrand().Where(i => i.BrandName == txtName.Text).FirstOrDefault(); if (b == null) { try { int BrandID; BrandID = Int32.Parse(label2.Text); LTS.Brand Ub = new LTS.Brand(); Ub.BrandID = BrandID; Ub.BrandName = txtName.Text; Ub.BrandDescription = txtSur.Text; bool updateBrand = DAT.DataAccess.UpdateBrand(Ub); if (updateBrand) { if (DialogResult.OK == MessageBox.Show("Category Updated Successfully")) { ((Main)this.Parent.Parent).ChangeView <Pages.Items.Brands>(); } } else { if (DialogResult.OK == MessageBox.Show("Category was not Updated Successfully")) { ((Main)this.Parent.Parent).ChangeView <Pages.Items.Brands>(); } } } catch (Exception eex) { MessageBox.Show("Please try Again"); } } else { label3.Text = "Sorry, the newly entered Brand name already exists"; } } } } 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 + "]"); } }
//Marius private void btnAdd_Click(object sender, EventArgs e) { try { brandlbl.Visible = false; catlbl.Visible = false; lblBarcodeVal.Visible = false; lblDescVal.Visible = false; lblNameVal.Visible = false; int getBarcodeID; try { LTS.Product prod = new LTS.Product(); LTS.Brand brand = new LTS.Brand(); brand = DAT.DataAccess.GetBrand().Where(o => o.BrandName == comboBoxBrand.SelectedItem.ToString()).FirstOrDefault(); if (brand != null) { prod.BrandID = brand.BrandID; } else { brandlbl.Visible = true; } LTS.Category cat = new LTS.Category(); cat = DAT.DataAccess.GetCategory().Where(o => o.CategoryName == comboBoxCategory.SelectedItem.ToString()).FirstOrDefault(); if (cat != null) { prod.CategoryID = cat.CategoryID; } else { catlbl.Visible = true; } LTS.Barcode barc = new LTS.Barcode(); if (listBar.Where(u => u.BarcodeNumber == tbBarcode.Text).FirstOrDefault() == null) { barc.BarcodeNumber = tbBarcode.Text; } else { lblBarcodeVal.Visible = true; lblBarcodeVal.Text = "The barcode value is already in use"; } //validation if (tbProdName.Text == "") { lblNameVal.Visible = true; lblNameVal.Text = "Please enter a product name"; } if (tbProdDesc.Text == "") { lblDescVal.Visible = true; lblDescVal.Text = "Please enter a product description"; } if (tbBarcode.Text == "") { lblBarcodeVal.Visible = true; lblBarcodeVal.Text = "Please enter a barcode number"; } int ok; if (lblBarcodeVal.Visible == false && lblDescVal.Visible == false && lblNameVal.Visible == false && brandlbl.Visible == false && catlbl.Visible == false) { getBarcodeID = DAT.DataAccess.AddBarcode(barc); if (getBarcodeID != -1) { prod.BarcodeID = getBarcodeID; prod.ProductName = tbProdName.Text; prod.ProductDescription = tbProdDesc.Text; ok = DAT.DataAccess.AddProduct(prod); if (ok == -1) { DAT.DataAccess.RemoveBarcode(prod.BarcodeID); MessageBox.Show("Sorry something went wrong, the Product was not Added!"); ((Main)this.Parent.Parent).ChangeView <Pages.Products.Product>(); } else { MessageBox.Show("The Product was added successfully!"); ((Main)this.Parent.Parent).ChangeView <Pages.Products.Product>(); } } else { lblBarcodeVal.Visible = true; lblBarcodeVal.Text = "The barcode could not be created!"; } } } catch (Exception ex) { if (DialogResult.OK == MessageBox.Show("The Product was not added successfully!")) { ((Main)this.Parent.Parent).ChangeView <Pages.Products.Product>(); } } } catch (Exception ex) { MessageBox.Show("Sorry Something went wrong, the action was not completed!"); } }
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(); } }