private void UploadButton_Click(object sender, EventArgs e) { this.Hide(); //Declaring a variable for UploadForm UploadForm form3 = new UploadForm(); form3.isModifyOrDeleteSet = false; form3.isUploadSet = true; //Showing UploadForm form3.ShowDialog(); }
// Code to add functionality for Modify button private void ModifyButton_Click(object sender, EventArgs e) { // Check whether user has selected product category if (ProductCategoryComboBox.SelectedIndex < 0) { MessageBox.Show("Please select a product category", "Input needed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // check whether user selected a shop location if (ProductLocationModifyFormComboBox.SelectedIndex < 0) { MessageBox.Show("Please select the location", "Input needed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // Check whether user selected a product from the list if (ProductDisplayDataGridView.SelectedRows.Count <= 0 && ProductDisplayDataGridView.SelectedCells.Count <= 0) { MessageBox.Show("Please choose a valid product from the list", "Selection needed", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // Case A: User selected a row if (ProductDisplayDataGridView.SelectedRows.Count > 0) { DataGridViewRow row = this.ProductDisplayDataGridView.SelectedRows[0]; this.Hide(); //Declaring a variable for Upload form UploadForm form3 = new UploadForm(); form3.productCategoryModifySet = ProductCategoryComboBox.SelectedIndex; form3.productLocationLocationSet = ProductLocationModifyFormComboBox.SelectedIndex; form3.selectedProduct = row.Cells["ITEM_ID"].Value.ToString(); form3.selectedProduct_Name = row.Cells["ITEM_NAME"].Value.ToString(); form3.isModifyOrDeleteSet = true; form3.isUploadSet = false; //Showing UploadForm form3.ShowDialog(); } // Case B: User selected a cell and not a row else if (ProductDisplayDataGridView.SelectedCells.Count > 0 && ProductDisplayDataGridView.SelectedRows.Count == 0) { int selectedrowindex = ProductDisplayDataGridView.SelectedCells[0].RowIndex; DataGridViewRow row = this.ProductDisplayDataGridView.Rows[selectedrowindex]; this.Hide(); //Declaring a variable for Upload form UploadForm form3 = new UploadForm(); form3.productCategoryModifySet = ProductCategoryComboBox.SelectedIndex; form3.productLocationLocationSet = ProductLocationModifyFormComboBox.SelectedIndex; form3.selectedProduct = row.Cells["ITEM_ID"].Value.ToString(); form3.selectedProduct_Name = row.Cells["ITEM_NAME"].Value.ToString(); //Showing UploadForm form3.isModifyOrDeleteSet = true; form3.isUploadSet = false; form3.ShowDialog(); } } } } }