private void btnAdd_Click(object sender, EventArgs e) { addModifyForm addCustomerForm = new addModifyForm(); addCustomerForm.addPackage = true; DialogResult result = addCustomerForm.ShowDialog(); if (result == DialogResult.OK) { dataGridView1.DataSource = PackagesDB.GetPackages(); } }
private void DisplayPackages() { packages = PackagesDB.GetPackages(); if (packages != null) // if we have product suppliers to display { lstView.Items.Clear(); //start with empty list box foreach (Packages pkg in packages) { lstView.Items.Add(pkg); } } else // null this product does not exist - need to refresh combo box { packageIds = PackagesDB.GetPackageIds(); } }
private void btnModify_Click(object sender, EventArgs e) { var cells = dataGridView1.CurrentRow.Cells; string rowId = cells[0].Value.ToString(); var selectedPackage = PackagesDB.GetPackage(rowId); addModifyForm modifyPackageForm = new addModifyForm(); modifyPackageForm.addPackage = false; modifyPackageForm.modifyPack = selectedPackage; DialogResult result = modifyPackageForm.ShowDialog(); if (result == DialogResult.OK) { dataGridView1.DataSource = PackagesDB.GetPackages(); } }
// display packages after getting list by DB method public void DisplayPackages() { packagesList = PackagesDB.GetPackages(); if (packagesList != null) // if we have product suppliers to display { lstView.Items.Clear(); //start with empty list box foreach (Packages pkg in packagesList) { lstView.Items.Add(pkg); lstView.Refresh(); } } else // null this package does not exist - need to refresh combo box { MessageBox.Show("There is no package to display."); } }
private void Form1_Load(object sender, EventArgs e) { dataGridView1.DataSource = PackagesDB.GetPackages(); dataGridView1.Rows[0].Selected = true; }