Exemple #1
0
 private void refreshDataGrid()
 {
     // Populate data grid showing products
     using (travelexpertsDataContext db = new travelexpertsDataContext())
     {
         grdProdSup.DataSource = TravelExpertsQueryManager.FindProdInfoByPackage(db, currentPackage.PackageId);
     }
 }
Exemple #2
0
        // Updates the data and display just for the grid of associated products, based on current selection of package datagrid
        private void RefreshProductGrid()
        {
            // Grab ID of the row currently selected in the Packages Datagrid. [Eric]
            selectedPackageId = Convert.ToInt32(grdPackages.CurrentRow.Cells[0].Value);

            // Set title for the products data using that current id
            lblSelectedProdsTitle.Text = $"Products for Selected Package (ID #{selectedPackageId})";

            // Populate data in Product Info gridview
            using (travelexpertsDataContext db = new travelexpertsDataContext())
            {
                // Use an in-depth query to grab the info needed for the product info data grid
                dataGridView1.DataSource = TravelExpertsQueryManager.FindProdInfoByPackage(db, selectedPackageId);
            }
        }
Exemple #3
0
        //If Modify Button was clicked on Form1
        private void frmAddModify_Load(object sender, EventArgs e)
        {
            if (!isAdd)   // Set up for Modify mode - use the Package passed from the last form to populate fields
            {
                // Update the title and description of the page
                lblTitle.Text = "Package Manager - Edit Package";
                lblDesc.Text  = $"Edit any details and modify product list for the current package (ID #{currentPackage.PackageId}).";

                using (travelexpertsDataContext db = new travelexpertsDataContext())
                {
                    // Grab current package ID used to create this modify page
                    int packageId = currentPackage.PackageId;
                    // Use an in-depth query to grab the info needed for the product info data grid
                    dataGridView1.DataSource = TravelExpertsQueryManager.FindProdInfoByPackage(db, currentPackage.PackageId);
                }

                // Set up a snapshot of current associated package_product_suppliers entries
                ppsSnapshot = TravelExpertsQueryManager.GetPackagesProductsSuppliersByPackageID(currentPackage.PackageId);

                // handle nullable datetime
                if (currentPackage.PkgStartDate == null)
                {
                    EmptyDateTimePicker(pkgStartDateDateTimePicker);
                }

                if (currentPackage.PkgEndDate == null)
                {
                    EmptyDateTimePicker(pkgEndDateDateTimePicker);
                }

                // Display current package information in details view
                packageBindingSource.Add(currentPackage);
            }

            else // Set up for Add mode
            {
                // Update the title and description of the page
                lblTitle.Text = "Package Manager - Add A New Package";
                lblDesc.Text  = "Add details and products for a new package.";
                EmptyDateTimePicker(pkgStartDateDateTimePicker);
                EmptyDateTimePicker(pkgEndDateDateTimePicker);
            }
        }
Exemple #4
0
        //To add Products to a Package - calls form ProdSuppliers
        private void btnEditAddProducts_Click(object sender, EventArgs e)
        {
            frmProdSupplier prodsForm = new frmProdSupplier();

            prodsForm.currentPackage = currentPackage;
            DialogResult result = prodsForm.ShowDialog(); // display second form modal

            if (result == DialogResult.OK)                // new row got inserted
            {
                // Toggle a switch noting that products were updated - checked in the event of cancel
                didAddProducts = true;

                // Show the updated list of products associated with this package
                using (travelexpertsDataContext db = new travelexpertsDataContext())
                {
                    dataGridView1.DataSource = TravelExpertsQueryManager.FindProdInfoByPackage(db, currentPackage.PackageId);
                }
            }
        }