private string categoryname; //categoryname public Add_category() { InitializeComponent(); string dbpath = Application.StartupPath + @"\StoreData.accdb";//database data Category_control.ConnectionString = dbpath; Category_data = Category_control.Instance; categorys = Category_data.GetCategory();//get categoey info }
/*Display boxs combobox*/ private void Displayboxs() { Category[] category_arr; category_arr = Category_data.GetCategory(); //category data products = product_data.GetproductData(); //product data displaysupplier.Items.Clear(); //clear suppliers Supplier[] supplierinfo = Supplier_data.Getsupplierinfo(); //get supplier data foreach (Supplier i in supplierinfo) { displaysupplier.Items.Add(i.Name);//add supplier name to box } display_category.Items.Clear(); /*getting data category and add it to the cells*/ foreach (Category i in category_arr) { display_category.Items.Add(i.Name.ToString());//add to category box name of category } }
/*display data boxs category ,supplier*/ public void displaydataboxs() { categorys_list = Category_data.GetCategory(); //get category data suppliers_list = Supplier_data.Getsupplierinfo(); //get supplier data display_category.Items.Clear(); /*get category to box*/ for (int i = 0; i < categorys_list.Length; i++) { display_category.Items.Add(categorys_list[i].Name.ToString()); } display_category.SelectedIndex = 0;//get the first value in category list displaysupplier.Items.Clear(); /*display suppliers list in box*/ for (int i = 0; i < suppliers_list.Length; i++) { displaysupplier.Items.Add(suppliers_list[i].Name); } displaysupplier.SelectedIndex = 0;//display first supplier index }