Exemplo n.º 1
0
        private void btnAddPackage_Click(object sender, EventArgs e)
        {
            // add new package
            var frmAddEdit = new frmAddEditPackage("add");

            frmAddEdit.Package = new Package();

            // if user clicks save
            if (frmAddEdit.ShowDialog() == DialogResult.OK)
            {
                // add package to database and get package ID
                int PackageId = frmAddEdit.Package.AddPackage();
                frmAddEdit.Package.PackageId = PackageId;

                // add products to newly created package
                foreach (var ps in frmAddEdit.AddedPSList)
                {
                    ps.AddToPackage(frmAddEdit.Package.PackageId);
                }
                Reload();
                // find this package in new button list and click it to show update details
                string buttonName = PackageId.ToString();
                ((Button)pnlPackages.Controls[buttonName]).PerformClick();
            }
        }
Exemplo n.º 2
0
        private void btnEditPackage_Click(object sender, EventArgs e)
        {
            // modify current package
            var frmAddEdit = new frmAddEditPackage("edit");

            frmAddEdit.Package = currentPackage;
            // if user clicks save
            if (frmAddEdit.ShowDialog() == DialogResult.OK)
            {
                frmAddEdit.Package.Update();
                frmAddEdit.Package.RemoveProducts();
                // add products to package
                foreach (var ps in frmAddEdit.AddedPSList)
                {
                    ps.AddToPackage(frmAddEdit.Package.PackageId);
                }
                Reload();

                // find this package in new button list and click it to show update details
                string buttonName = frmAddEdit.Package.PackageId.ToString();
                ((Button)pnlPackages.Controls[buttonName]).PerformClick();
            }
        }