private void autoComplete() { try { txtInvoiceSearch.AutoCompleteMode = AutoCompleteMode.Suggest; txtInvoiceSearch.AutoCompleteSource = AutoCompleteSource.CustomSource; txtSNameSearch.AutoCompleteMode = AutoCompleteMode.Suggest; txtSNameSearch.AutoCompleteSource = AutoCompleteSource.CustomSource; txtPNameSearch.AutoCompleteMode = AutoCompleteMode.Suggest; txtPNameSearch.AutoCompleteSource = AutoCompleteSource.CustomSource; txtSupName.AutoCompleteMode = AutoCompleteMode.Suggest; txtSupName.AutoCompleteSource = AutoCompleteSource.CustomSource; AutoCompleteStringCollection stringColl = new AutoCompleteStringCollection(); AutoCompleteStringCollection stringColl2 = new AutoCompleteStringCollection(); AutoCompleteStringCollection stringColl3 = new AutoCompleteStringCollection(); M_Product_BS product = new M_Product_BS(); ProductList = product.GetProducts(con); foreach (BusinessObjects.M_Product_BS item in ProductList) { stringColl.Add(item.name); } //retreive stock data Stock sc = new Stock(); StockList = sc.GetStockList(con); foreach (BusinessObjects.Stock item in StockList) { stringColl2.Add(item.sup_name); stringColl3.Add(item.invoice_no.ToString()); } txtPNameSearch.AutoCompleteCustomSource = stringColl; txtSNameSearch.AutoCompleteCustomSource = stringColl2; txtInvoiceSearch.AutoCompleteCustomSource = stringColl3; txtSupName.AutoCompleteCustomSource = stringColl2; BusinessObjects.Category_BS catObj = new BusinessObjects.Category_BS(); CategoryList = catObj.GetCategory(con); cmbECategory.DataSource = null; cmbECategory.DataSource = CategoryList; cmbECategory.DisplayMember = "name"; cmbECategory.ValueMember = "ID"; } catch (Exception ex) { MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//donno y i have created this function private void loadGrid() { try { List <Category_BS> catList = new List <Category_BS>(); List <BusinessObjects.M_Product_BS> cObjList = new List <M_Product_BS>(); BusinessObjects.M_Product_BS cObj = new BusinessObjects.M_Product_BS(); cObjList = cObj.GetProducts(con); //MessageBox.Show(cObjList.Count.ToString()); BusinessObjects.Category_BS catObj = new BusinessObjects.Category_BS(); catList = catObj.GetCategory(con); foreach (BusinessObjects.Category_BS itemCat in catList) { foreach (BusinessObjects.M_Product_BS itemProd in cObjList) { if (itemProd.category == itemCat.ID) { itemProd.catObj = itemCat; } } } int i = 0; tblProduct.Rows.Clear(); //MessageBox.Show(cObjList.Count.ToString()); foreach (BusinessObjects.M_Product_BS item in cObjList) { tblProduct.Rows.Add(); tblProduct.Rows[i].Cells[0].Value = item.ID; tblProduct.Rows[i].Cells[1].Value = item.name; tblProduct.Rows[i].Cells[3].Value = item.cost; tblProduct.Rows[i].Cells[2].Value = item.unitPrice; tblProduct.Rows[i].Cells[5].Value = "VIEW"; tblProduct.Rows[i].Cells[6].Value = "ADD"; i++; } autoComplete(); } catch (Exception ex) { MetroMessageBox.Show(this, "System Error " + ex.Message, "System Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void loadCombo() { try { cmbECategory.DataSource = null; BusinessObjects.Category_BS CBS = new BusinessObjects.Category_BS(); List <BusinessObjects.Category_BS> CList = new List <BusinessObjects.Category_BS>(); CList = CBS.GetCategory(con); cmbECategory.DataSource = CList; cmbECategory.DisplayMember = "name"; cmbECategory.ValueMember = "ID"; } catch (Exception ex) { MetroMessageBox.Show(this, "! System Error. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error); } }