private void btnDelete_Click(object sender, EventArgs e)//button for delete { OperationSign = "Delete"; cklstProductSupplier.Visible = false; btnDelete.Enabled = false; currentDeleteProductId = Convert.ToInt32(lstProducts.SelectedValue); //get delete target productID currentDeleteSupplierId = Convert.ToInt32(lstSuppliers.SelectedValue); //get delete target supplierID currentDeleteProductName = lstProducts.Text; currentDeleteSupplierName = lstSuppliers.Text; currentDeleteProductSupplierId = ProductSupplierDB.getProductSupplierId(currentDeleteProductId, currentDeleteSupplierId); //get productsupplierId in PS TABLE if (ProductSupplierDB.referencedInPackages(currentDeleteProductSupplierId)) //chech delete target is referenced in Package table or no { MessageBox.Show("The product:" + currentDeleteProductName + " with supplier of " + currentDeleteSupplierName + " has been referenced in Package Table,Please go to Package!"); panel2.Visible = false; panel1.Visible = true; btnSave.Enabled = false; lblSave.Enabled = false; lblSave.Visible = false; } else//selected row is not referenced in PAckage Table { panel2.Visible = true; panel1.Visible = false; btnSave.Enabled = true; lblSave.Enabled = true; lblSave.Visible = true; currentPS = OperationPS.getCurrentPS(currentDeleteProductId, currentDeleteSupplierId, OperationSign); lblSave.Text = "You are preparing to delete product:" + currentDeleteProductName + " with supplier:" + currentDeleteSupplierName; Display(); } }
private void btnAdd_Click(object sender, EventArgs e) { OperationSign = "Add"; //initialize Edit panel panel2.Visible = true; panel1.Visible = false; lblSave.Visible = true; btnSave.Enabled = true; cklstProductSupplier.Visible = true; //get selected productID and productName currentProdId = Convert.ToInt32(lstProducts.SelectedValue); //get selected productID currentProdName = lstProducts.Text; //get selected productName currentAddProductId = currentProdId; currentAddProductName = currentProdName; //load corresponding suppliers row currentPS = OperationPS.getCurrentPS(currentAddProductId, OperationSign);//load all of suppliers corresponding from PRODUCTS_SUPPLIERS TABLE and displayed in bottom grid Display(); //add all of suppliers which are not related to currtent productID AddAvailableSupplier();//add all of suppliers which are not related to currtent productID btnAdd.Enabled = false; lblSave.Text = "You are adding new suppliers to product:" + currentAddProductName; }
private void btnDelete_Click(object sender, EventArgs e) { //int currentDeletePSid; OperationSign = "Delete"; // cklstProductSupplier.Visible = false; // btnDelete.Enabled = false; // currentDeleteProductId = Convert.ToInt32(lstProducts.SelectedValue); currentDeleteSupplierId = Convert.ToInt32(lstSuppliers.SelectedValue); currentDeleteProductName = lstProducts.Text; currentDeleteSupplierName = lstSuppliers.Text; currentDeleteProductSupplierId = ProductSupplierDB.getProductSupplierId(currentDeleteProductId, currentDeleteSupplierId);//get productsupplierId in PS TABLE if (ProductSupplierDB.referencedInPackages(currentDeleteProductSupplierId)) { MessageBox.Show("Your selection product:" + currentDeleteProductName + " with supplier of " + currentDeleteSupplierName + " has been referenced in Package Table,Please go to Package!"); panel2.Visible = false; panel1.Visible = true; btnSave.Enabled = false; lblSave.Enabled = false; lblSave.Visible = false; } else { panel2.Visible = true; panel1.Visible = false; btnSave.Enabled = true; lblSave.Enabled = true; lblSave.Visible = true; currentPS = OperationPS.getCurrentPS(currentDeleteProductId, currentDeleteSupplierId, OperationSign); lblSave.Text = "You are preparing to delete product:" + currentDeleteProductName + " with supplier:" + currentDeleteSupplierName; Display(); } }
private void btnUpdate_Click(object sender, EventArgs e) { OperationSign = "Update"; //when clikc update button ,then set "Update" value to oPERATIONsIGN //initialize form lblSave.Visible = true; btnSave.Enabled = true; cklstProductSupplier.Visible = true; panel2.Visible = true; panel1.Visible = false; //get update target productId // currentProdId = Convert.ToInt32(lstProducts.SelectedValue); // currentProdName = lstProducts.Text; currentUpdateProductId = Convert.ToInt32(lstProducts.SelectedValue); currentUpdateProductName = lstProducts.Text; currentUpdatesupplierId = Convert.ToInt32(lstSuppliers.SelectedValue); currentUpdatesupplierName = lstSuppliers.Text; currentPS = OperationPS.getCurrentPS(currentUpdateProductId, currentUpdatesupplierId, OperationSign);//GET selected ProdcutSupplierID // currentUpdateProductId = currentProdId; Display(); UpdateAvailableSupplier();//call update oeration method btnUpdate.Enabled = false; lblSave.Text = "You are updating Prodcut:" + currentUpdateProductName + " with supplier:" + currentUpdatesupplierName; }