private void button4_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(textBox7.Text)) { MessageBox.Show("Please Enter a Package Name !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (dateTimePicker1.Value >= dateTimePicker2.Value) { MessageBox.Show("Package End Date must be later than Package Start Date !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(textBox9.Text)) { MessageBox.Show("Please Enter Package Description !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(textBox11.Text)) { MessageBox.Show("Please Enter Base Price !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (string.IsNullOrWhiteSpace(textBox10.Text)) { MessageBox.Show("Please Enter Agency Commission !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (Convert.ToInt32(textBox10.Text) > Convert.ToInt32(textBox11.Text)) { MessageBox.Show("Agency Commission cannot be greater than the Base Price !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (list3_ToDB.Count == 0) { MessageBox.Show("Please choose products for this package !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } int newID = PackagesDB.AddPackageForForm2(textBox7.Text, dateTimePicker1.Value, dateTimePicker2.Value, textBox9.Text, Convert.ToDecimal(textBox11.Text.ToString()), Convert.ToDecimal(textBox10.Text.ToString())); if (newID == -1) { MessageBox.Show("Error adding Package."); } else { foreach (var ps in list3_ToDB) { int psid = Products_SuppliersDB.GetPSID_By_P_SID(ps.ProductId, ps.SupplierId); if (!Packages_Products_SuppliersDB.AddPPS(newID, psid)) { MessageBox.Show("Error adding Packages_Products_Suppliers."); } } } listBox3.DataSource = null; list3.Clear(); list3_ToDB.Clear(); textBox7.Text = ""; textBox9.Text = ""; textBox11.Text = ""; textBox10.Text = ""; }