コード例 #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            frmProductAddEdit productAddForm = new frmProductAddEdit();

            productAddForm.xNewProduct = true;

            if (productAddForm.ShowDialog() == DialogResult.OK)
            {
                RefreshList();
                cmbProducts.Text = productAddForm.txbProductName.Text;  // Reposition the selection (cursor)
            }
        }
コード例 #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            frmProductAddEdit productEditForm = new frmProductAddEdit();

            productEditForm.xNewProduct = false;

            productEditForm.txbProductID.Text   = this.txbProductID.Text;
            productEditForm.txbProductName.Text = this.txbProductName.Text;

            DialogResult result = productEditForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                RefreshList();
                cmbProducts.SelectedValue = Convert.ToInt32(productEditForm.txbProductID.Text); // Reposition the selection (cursor)
            }
        }
コード例 #3
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            switch (uxTreeView.SelectedNode.Parent.Name)
            {
            case "rootPackages":        // open AddEditPackage form with related Package object in Edit mode
                Package pkg = frmMain.packageList[frmMain.packageList.FindIndex(pk => pk.PkgName == uxTreeView.SelectedNode.Name)];
                frmAddModifyPackages frmEditPackage = new frmAddModifyPackages();
                frmEditPackage.add     = false;
                frmEditPackage.package = pkg;
                if (frmEditPackage.ShowDialog() == DialogResult.OK)
                {
                    RefreshPackages();      // Refresh the Package List and the TreeView Node
                    frmMain.DisplayMessage("The package has been modified successfully.");
                }
                break;

            case "rootProducts":        // open AddEditProduct form with related Product object in Edit mode
                Product           prd            = frmMain.productList[frmMain.productList.FindIndex(pr => pr.ProdName == uxTreeView.SelectedNode.Name)];
                frmProductAddEdit frmEditProduct = new frmProductAddEdit();
                frmEditProduct.xNewProduct         = false;
                frmEditProduct.txbProductID.Text   = prd.ProductId.ToString();
                frmEditProduct.txbProductName.Text = prd.ProdName;
                if (frmEditProduct.ShowDialog() == DialogResult.OK)
                {
                    RefreshProducts();      // Refresh the Product List and the TreeView Node
                    frmMain.DisplayMessage("The product has been modified successfully.");
                }
                break;

            case "rootSuppliers":       // open AddEditSupplier form with related Supplier object in Edit mode
                Supplier             sp = frmMain.supplierList[frmMain.supplierList.FindIndex(s => s.SupName == uxTreeView.SelectedNode.Name)];
                frmAddModifySupplier frmEditSupplier = new frmAddModifySupplier();
                frmEditSupplier.add             = false;
                frmEditSupplier.supplierContact = SupplierContactsDB.GetSupplierbySupID(sp.SupplierId);
                if (frmEditSupplier.ShowDialog() == DialogResult.OK)
                {
                    RefreshSuppliers();      // Refresh the Supplier List and the TreeView Node
                    frmMain.DisplayMessage("The supplier information have been modified successfully.");
                }
                break;

            default:
                break;
            }
        }
コード例 #4
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            switch (uxTreeView.SelectedNode.Name)
            {
            case "rootPackages":        // open AddEditPackage form in NewPackage mode
                frmAddModifyPackages frmNewPackage = new frmAddModifyPackages();
                frmNewPackage.add = true;
                if (frmNewPackage.ShowDialog() == DialogResult.OK)
                {
                    RefreshPackages();      // Refresh the Supplier List and the TreeView Node
                    frmMain.DisplayMessage("A new package has been added successfully.");
                }
                break;

            case "rootProducts":        // open AddEditProduct form in NewProduct mode
                frmProductAddEdit frmNewProduct = new frmProductAddEdit();
                frmNewProduct.xNewProduct = true;
                if (frmNewProduct.ShowDialog() == DialogResult.OK)
                {
                    RefreshProducts();      // Refresh the Product List and the TreeView Node
                    frmMain.DisplayMessage("A new product has been added successfully.");
                }
                break;

            case "rootSuppliers":       // open AddEditSupplier form in NewSupplier mode
                frmAddModifySupplier frmNewSupplier = new frmAddModifySupplier();
                frmNewSupplier.add = true;
                if (frmNewSupplier.ShowDialog() == DialogResult.OK)
                {
                    RefreshSuppliers();      // Refresh the Supplier List and the TreeView Node
                    frmMain.DisplayMessage("A new supplier has been added successfully.");
                }
                break;

            default:
                break;
            }
        }