} //O(1) private void proBtnDel_Click(object sender, EventArgs e) //deleted a products, if product doesn't exsits does { proStatusMsglbl.Text = ""; DBhandler DBUse = new DBhandler(); int product = 0; proStatusMsglbl.Text += proNumtxt.Text.Trim().Length == 0 ? "Missing Product Number.\n" : ""; proStatusMsglbl.Text += !int.TryParse(proNumtxt.Text, out product) && proNumtxt.Text.Trim().Length != 0 ? "Not a number for Product number.\n" : ""; proStatusMsglbl.Text += product != 0 && DBUse.isProductOrderd(product) ? "Product is ordered.\nNeed to delivere or cancel order first." : ""; if (proStatusMsglbl.Text.Length == 0) { DBUse.deleteProduct(product); fillListProducts(); } productClearTxt(); DBUse = null; } //O(1)
} //O(1) private void proBtnAdd_Click(object sender, EventArgs e) //add/update a product, changed after submition { proStatusMsglbl.Text = string.Empty; DBhandler DBUse = new DBhandler(); int product = 0, supplier = 0; //making sure all values are correct proStatusMsglbl.Text += proNumtxt.Text.Trim().Length == 0 ? "Missing Product Number.\n" : ""; proStatusMsglbl.Text += proNametxt.Text.Trim().Length == 0 ? "Missing Product Name.\n" : ""; proStatusMsglbl.Text += proSupIDtxt.Text.Trim().Length == 0 ? "Missing Supplier ID.\n" : ""; proStatusMsglbl.Text += !int.TryParse(proNumtxt.Text, out product) && proNumtxt.Text.Trim().Length != 0 ? "Not a number for Product number.\n" : ""; proStatusMsglbl.Text += !int.TryParse(proSupIDtxt.Text, out supplier) && proSupIDtxt.Text.Trim().Length != 0 ? "Not a number for Supplier ID.\n" : ""; proStatusMsglbl.Text += DBUse.supplierExists(supplier) && supplier != 0 ? "Supplier doesn't exits\n" : ""; proStatusMsglbl.Text += product != 0 && DBUse.isProductOrderd(product) ? "Product is ordered.\nNeed to delivere or cancel order first." : ""; //change added after submition date if (proStatusMsglbl.Text.Length == 0) { DBUse.addProduct(product, proNametxt.Text.Trim(), supplier); fillListProducts(); //Clears and refill the listview after added/updated } productClearTxt(); DBUse = null; } //O(1)