Ejemplo n.º 1
0
 private void DisplayCurrentSupplierData()
 {
     if (currentSupplier != null)
     {
         txtName.Text = currentSupplier.SupName;
     }
     else // null this product does not exist - need to refresh combo box
     {
         supplierIds = SuppliersDB.GetSuppliersIds();
     }
 }
 private void frmAddUpdateProductSupplier_Load(object sender, EventArgs e)
 {
     productIds               = ProductsDB.GetProductsIds();
     cboProdId.DataSource     = productIds;
     supplierIds              = SuppliersDB.GetSuppliersIds();
     cboSupplierId.DataSource = supplierIds;
     if (addProductSupplier)
     {
         this.Text = "Add Product Supplier";
         cboProdId.SelectedIndex     = 0;
         cboSupplierId.SelectedIndex = 0;
     }
     else
     {
         this.Text = "Update Product Supplier";
         this.DisplayCustomer();
     }
 }
Ejemplo n.º 3
0
 private void DisplaySupplierData()
 {
     supplierIds      = SuppliersDB.GetSuppliersIds();
     cboId.DataSource = supplierIds;
     if (supplierIds != null)
     {
         txtName.Text       = currentSupplier.SupName;
         cboId.SelectedItem = currentSupplier.SupplierId;
         lstView.Items.Clear();//start with empty list box
         lstView.Items.Add("Id " + ": " + "Supplier Name");
         foreach (int id in supplierIds)
         {
             Suppliers s = SuppliersDB.GetSupplierById(id);
             lstView.Items.Add(s);
         }
     }
     else // null this product does not exist - need to refresh combo box
     {
         supplierIds = SuppliersDB.GetSuppliersIds();
     }
 }
Ejemplo n.º 4
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();
                }
            }
        }