private void DisplayPackage()
        {
            currentProductSupplierIds = Packages_Products_SuppliersDB.GetProductSupplierIds((int)id);
            Packages currentPackage = PackagesDB.GetPackageById((int)id);

            txtPackageId.Text = currentPackage.PackageId.ToString();
            txtPkgName.Text   = currentPackage.PkgName;
            txtPkgDesc.Text   = currentPackage.PkgDesc;
            txtBasePrice.Text = currentPackage.PkgBasePrice.ToString();

            DisplayCurrentPackageProductSupplierData();

            if (currentPackage.PkgStartDate == null)
            {
                dtpStartDate.Text = "";
            }
            else
            {
                DateTime startDate = (DateTime)currentPackage.PkgStartDate;
                dtpStartDate.Text = startDate.ToShortDateString();
            }

            if (currentPackage.PkgEndDate == null)
            {
                dtpEndDate.Text = "";
            }
            else
            {
                DateTime endDate = (DateTime)currentPackage.PkgEndDate;
                dtpEndDate.Text = endDate.ToShortDateString();
            }

            if (currentPackage.PkgAgencyCommission.Equals(null))
            {
                txtCommission.Text = "";
            }
            else
            {
                txtCommission.Text = Convert.ToDecimal(currentPackage.PkgAgencyCommission).ToString();
            }
        }
Esempio n. 2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string tableName = cboTableNames.SelectedValue.ToString();

            if (tableName == "Products")
            {
                frmAddUpdateProducts updateProductForm = new frmAddUpdateProducts();
                updateProductForm.addProduct = false;
                updateProductForm.product    = currentProd;
                DialogResult result = updateProductForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    currentProd = updateProductForm.product;
                    this.DisplayProductData();
                }
                else if (result == DialogResult.Retry)
                {
                    currentProd = ProductsDB.GetProductById(currentProd.ProductId);
                    if (currentProd != null)
                    {
                        this.DisplayProductData();
                    }
                }
            }
            else if (tableName == "Suppliers")
            {
                frmAddUpdateSuppliers updateSupplierForm = new frmAddUpdateSuppliers();
                updateSupplierForm.addSupplier = false;
                updateSupplierForm.supplier    = currentSupplier;
                DialogResult result = updateSupplierForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    currentSupplier = updateSupplierForm.supplier;
                    this.DisplaySupplierData();
                }
                else if (result == DialogResult.Retry)
                {
                    currentSupplier = SuppliersDB.GetSupplierById(currentSupplier.SupplierId);
                    if (currentSupplier != null)
                    {
                        this.DisplaySupplierData();
                    }
                }
            }
            else if (tableName == "Products_Suppliers")
            {
                frmAddUpdateProductSupplier updateProductSupplierForm = new frmAddUpdateProductSupplier();
                updateProductSupplierForm.addProductSupplier = false;
                updateProductSupplierForm.productSupplier    = currentProductSupplier;
                DialogResult result = updateProductSupplierForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    this.DisplayCurrentProductSupplierData();
                    this.DisplayProductSupplierData();
                }
                else if (result == DialogResult.Retry)
                {
                    currentProductSupplier = Products_SuppliersDB.GetProductSupplierById(currentProductSupplier.ProductSupplierId);
                    if (currentProductSupplier != null)
                    {
                        this.DisplayCurrentProductSupplierData();
                    }
                    this.DisplayProductSupplierData();
                }
            }
            else if (tableName == "Packages")
            {
                frmAddUpdatePackages updatePackageForm = new frmAddUpdatePackages();
                updatePackageForm.addPackage = false;
                updatePackageForm.package    = currentPackage;
                updatePackageForm.currentProductSupplierIds = Packages_Products_SuppliersDB.GetProductSupplierIds(currentPackage.PackageId);
                DialogResult result = updatePackageForm.ShowDialog();
                if (result == DialogResult.OK)
                {
                    this.DisplayPackages();
                    DisplayCurrentPackageProductSupplierData();
                }
                else if (result == DialogResult.Retry)
                {
                    currentPackage = PackagesDB.GetPackageById(currentPackage.PackageId);
                    if (currentPackage != null)
                    {
                        DisplayCurrentPackageProductSupplierData();
                    }
                    this.DisplayPackages();
                }
            }
        }
Esempio n. 3
0
        private void cboId_SelectedIndexChanged(object sender, EventArgs e)
        {
            string tableName = cboTableNames.SelectedValue.ToString();

            if (tableName == "Products")
            {
                int selectedID = (int)cboId.SelectedValue;
                lblName.Text = "Product Name";
                try
                {
                    currentProd = ProductsDB.GetProductById(selectedID);
                    DisplayCurrentProductData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while retrieving product with selected ID: " + ex.Message,
                                    ex.GetType().ToString());
                }
            }
            else if (tableName == "Suppliers")
            {
                int selectedID = (int)cboId.SelectedValue;
                lblName.Text = "Supplier Name";
                try
                {
                    currentSupplier = SuppliersDB.GetSupplierById(selectedID);
                    DisplayCurrentSupplierData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while retrieving supplier with selected ID: " + ex.Message,
                                    ex.GetType().ToString());
                }
            }
            else if (tableName == "Products_Suppliers")
            {
                int selectedID = (int)cboId.SelectedValue;
                try
                {
                    currentProductSupplier = Products_SuppliersDB.GetProductSupplierById(selectedID);
                    DisplayCurrentProductSupplierData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while retrieving product supplier with selected ID: " + ex.Message,
                                    ex.GetType().ToString());
                }
            }
            else if (tableName == "Packages_Products_Suppliers")
            {
                int selectedID = (int)cboId.SelectedValue;
                try
                {
                    productSupplierIds = Packages_Products_SuppliersDB.GetProductSupplierIds(selectedID);
                    DisplayCurrentPackageProductSupplierData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while retrieving package product supplier with selected ID: " + ex.Message,
                                    ex.GetType().ToString());
                }
            }
            else if (tableName == "Packages")
            {
                int selectedID = (int)cboId.SelectedValue;
                lblName.Text = "Package Name";
                try
                {
                    productSupplierIds = Packages_Products_SuppliersDB.GetProductSupplierIds(selectedID);
                    DisplayCurrentPackageProductSupplierData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while retrieving package product supplier with selected ID: " + ex.Message,
                                    ex.GetType().ToString());
                }
                try
                {
                    currentPackage = PackagesDB.GetPackageById(selectedID);
                    txtName.Text   = currentPackage.PkgName;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error while retrieving package with selected ID: " + ex.Message,
                                    ex.GetType().ToString());
                }
            }
        }