private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtZoneName.Text)) { Exception ex = new Exception("Validation Exception : Please provide a new name!"); HandleException(ex); } else if(string.IsNullOrEmpty(textBox1.Text)) { Exception ex = new Exception("Validation Exception : Please provide a valid start time!"); HandleException(ex); } else if (string.IsNullOrEmpty(textBox2.Text)) { Exception ex = new Exception("Validation Exception : Please provide a valid end time!"); HandleException(ex); } else if(string.IsNullOrEmpty(textBox3.Text)) { Exception ex = new Exception("Validation Exception : Please provide an interval value!"); HandleException(ex); } else { try { lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule(); DAO.ConnectionString = _connectionString; DAO.Insert(txtZoneName.Text,textBox1.Text,textBox2.Text,int.Parse(textBox3.Text), DateTime.Now); HandleInformationMesssage("Data successfully saved! Please refresh the form data!"); this.Close(); } catch (Exception ex) { HandleException(ex); } } }
private void btnOK_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtZoneName.Text)) { Exception ex = new Exception("Validation Exception : Please provide a new name!"); HandleException(ex); } else if (string.IsNullOrEmpty(textBox1.Text)) { Exception ex = new Exception("Validation Exception : Please provide a valid start time!"); HandleException(ex); } else if (string.IsNullOrEmpty(textBox2.Text)) { Exception ex = new Exception("Validation Exception : Please provide a valid end time!"); HandleException(ex); } else if (string.IsNullOrEmpty(textBox3.Text)) { Exception ex = new Exception("Validation Exception : Please provide an interval value!"); HandleException(ex); } else { try { lfa.pmgmt.data.DAO.Schedule.Schedule DAO = new data.DAO.Schedule.Schedule(); DAO.ConnectionString = _connectionString; DAO.Insert(txtZoneName.Text, textBox1.Text, textBox2.Text, int.Parse(textBox3.Text), DateTime.Now); HandleInformationMesssage("Data successfully saved! Please refresh the form data!"); this.Close(); } catch (Exception ex) { HandleException(ex); } } }