private void searchbtn_Click(object sender, EventArgs e) { if (customernametb.Text != "" && contacttb.Text != "" && addresstb.Text != "" && contacttb.TextLength == 11 && dateTimePicker1.Text != "" && dataGridView2.SelectedRows.Count == 1) { if (Convert.ToInt32(dataGridView2.SelectedCells[2].Value) == 0) { MessageBox.Show("Selected Book not available", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { double d = (dateTimePicker1.Value.Date - DateTime.Now.Date).TotalDays; if (d > 0) { MessageBox.Show(lc.assignBookNewCustomer(customernametb.Text, contacttb.Text, addresstb.Text, DateTime.Today, dateTimePicker1.Value, Convert.ToInt32(dataGridView2.SelectedCells[0].Value), Convert.ToInt32(dataGridView2.SelectedCells[2].Value)), "Successful"); dataGridView2.DataSource = null; dateTimePicker1.Value = DateTime.Today; } else { MessageBox.Show("Submission date must be greater than today's date", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else if (customernametb.Text != "" && contacttb.Text != "" && addresstb.Text != "" && dataGridView2.SelectedRows.Count != 1) { MessageBox.Show("Please Select any Book First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (customernametb.Text != "" && contacttb.Text != "" && addresstb.Text != "" && contacttb.TextLength != 11 && dateTimePicker1.Text != "" && dataGridView2.SelectedRows.Count == 1) { MessageBox.Show("Contact Number must be of 11 digits", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Please Fill the required Fields properly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }