Пример #1
0
 private void DisplayProductSupplierData()
 {
     productSupplierIds = Products_SuppliersDB.GetProductSupplierIds();
     lstProdSup.Items.Clear();//start with empty list box
     lstProdSup.Items.Add("Id " + ": " + "Product Name" + ",  " + "Supplier Name");
     foreach (int id in productSupplierIds)
     {
         //Products_Suppliers ps = Products_SuppliersDB.GetProductSupplierById(id);
         // lstProdSup.Items.Add(ps);
     }
 }
Пример #2
0
 private void DisplayProductSupplierData()
 {
     productSupplierIds = Products_SuppliersDB.GetProductSupplierIds();
     if (currentProductSupplier != null) // if we have product suppliers to display
     {
         lstView.Items.Clear();          //start with empty list box
         lstView.Items.Add("Id " + ": " + "Product Name" + ",  " + "Supplier Name");
         foreach (int id in productSupplierIds)
         {
             Products_Suppliers ps = Products_SuppliersDB.GetProductSupplierById(id);
             lstView.Items.Add(ps);
         }
     }
     else // null this product does not exist - need to refresh combo box
     {
         productSupplierIds = Products_SuppliersDB.GetProductSupplierIds();
     }
 }
Пример #3
0
        private void cboTableNames_SelectedIndexChanged(object sender, EventArgs e)
        {
            string tableName = cboTableNames.SelectedValue.ToString();

            if (tableName == "Products")
            {
                pnlName.Visible  = true;
                pnlName2.Visible = false;
                lblId.Text       = "Product Id";
                productIds       = ProductsDB.GetProductsIds();

                if (productIds.Count > 0) // if there are prodcuts
                {
                    cboId.DataSource    = productIds;
                    cboId.SelectedIndex = 0; // triggers SelectedIndexChanged
                }
                else // no members
                {
                    MessageBox.Show("There are no products. " +
                                    "Add some products in the database, and restart the application ", "Empty Load");
                    Application.Exit();
                }
                DisplayProductData();
            }
            else if (tableName == "Suppliers")
            {
                lblId.Text       = "Supplier Id";
                supplierIds      = SuppliersDB.GetSuppliersIds();
                pnlName.Visible  = true;
                pnlName2.Visible = false;
                if (supplierIds.Count > 0) // if there are suppliers
                {
                    cboId.DataSource    = supplierIds;
                    cboId.SelectedIndex = 0; // triggers SelectedIndexChanged
                }
                else // no members
                {
                    MessageBox.Show("There are no suppliers. " +
                                    "Add some supplier in the database, and restart the application ", "Empty Load");
                    Application.Exit();
                }
                DisplaySupplierData();
            }
            else if (tableName == "Products_Suppliers")
            {
                lblId.Text         = "ProductSupplier Id";
                lblName.Text       = "Product Name";
                lblName2.Text      = "Supplier Name";
                pnlName.Visible    = true;
                pnlName2.Visible   = true;
                productSupplierIds = Products_SuppliersDB.GetProductSupplierIds();

                if (productSupplierIds.Count > 0) // if there are suppliers
                {
                    cboId.DataSource    = productSupplierIds;
                    cboId.SelectedIndex = 0; // triggers SelectedIndexChanged
                }
                else // no members
                {
                    MessageBox.Show("There are no product_suppliers. " +
                                    "Add some product_supplier in the database, and restart the application ", "Empty Load");
                    Application.Exit();
                }
                DisplayProductSupplierData();
            }
            else if (tableName == "Packages_Products_Suppliers")
            {
                lblId.Text       = "Package Id";
                packageIds       = Packages_Products_SuppliersDB.GetPackageIds();
                pnlName.Visible  = false;
                pnlName2.Visible = false;

                if (packageIds.Count > 0) // if there are packages
                {
                    cboId.DataSource    = packageIds;
                    cboId.SelectedIndex = 0; // triggers SelectedIndexChanged
                }
                else // no members
                {
                    MessageBox.Show("There are no packages with products_suppliers. " +
                                    "Add some packages with product_supplier in the database, and restart the application ", "Empty Load");
                    Application.Exit();
                }
            }
            else if (tableName == "Packages")
            {
                lblId.Text       = "Package Id";
                pnlName.Visible  = true;
                pnlName2.Visible = false;
                packageIds       = PackagesDB.GetPackageIds();
                DisplayPackages();
                if (packageIds.Count > 0) // if there are suppliers
                {
                    cboId.DataSource    = packageIds;
                    cboId.SelectedIndex = 0; // triggers SelectedIndexChanged
                }
                else // no members
                {
                    MessageBox.Show("There are no packages. " +
                                    "Add some packages in the database, and restart the application ", "Empty Load");
                    Application.Exit();
                }
            }
        }