}// end of GetPackage button // GetPackage function to display the packageid information private void GetPackage(int packageId) { try { package = PackageDB.GetPackage(packageId); } catch (Exception ex)//show an error if catch any problem { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }
/// <summary> /// Katrina: Package selection changes /// </summary> private void PkgIdComboBox_SelectedIndexChanged(object sender, EventArgs e) { int selectedId = Convert.ToInt32(PkgIdComboBox.SelectedValue); try { currentPkg = PackageDB.GetPackage(selectedId); DisplayCurrentPkgData(); } catch (Exception ex) { MessageBox.Show("Error while retrieving package with selected ID: " + ex.Message, ex.GetType().ToString()); } }
/// <summary> /// Katrina: Opens form for modifying package info and displays new modified data on main form /// </summary> private void btnModPackage_Click(object sender, EventArgs e) { frmAddModifyPackage updateForm = new frmAddModifyPackage(); updateForm.addPackage = false; updateForm.currentPkg = currentPkg; // set current package on update form -Katrina DialogResult result = updateForm.ShowDialog(); // display second form modal -Katrina if (result == DialogResult.OK) { currentPkg = updateForm.currentPkg; // receive current pkg from update form -Katrina } else if (result == DialogResult.Retry) { currentPkg = PackageDB.GetPackage(currentPkg.PackageId); } DisplayCurrentPkgData(); }
private void frmPackage_Load(object sender, EventArgs e) { //Retrieve all the packages packages = PackageDB.GetPackage(); //add rows to the dTgrid view for (int i = 0; i < packages.Count; i++) { dgvPackages.Rows.Add(); } //add package data to the rows for (int i = 0; i <= packages.Count - 1; i++) { dgvPackages.Rows[i].Cells[0].Value = packages[i].PackageID; dgvPackages.Rows[i].Cells[1].Value = packages[i].PackageName; dgvPackages.Rows[i].Cells[2].Value = packages[i].PackageDesc; //dgvPackages.Rows[i].Cells[3].Value = ((DateTime)packages[i].StartDate).ToString("d"); //dgvPackages.Rows[i].Cells[4].Value = ((DateTime)packages[i].EndDate).ToString("d"); //dgvPackages.Rows[i].Cells[5].Value = packages[i].BasePrice.ToString("c"); //dgvPackages.Rows[i].Cells[6].Value = ((decimal)packages[i].AgencyCommission).ToString("c"); } }
//display packages private void DisplayPackages() { packages = PackageDB.GetPackage(); packageDataGridView.DataSource = packages; }