private void button1_Click(object sender, EventArgs e) { if (!IsEmptyOrWhiteSpace(textBoxName.Text)) { if (!IsEmptyOrWhiteSpace(textBoxEmail.Text)) { try { if (!(DatabaseConnection.getInstance().GetSelectRowsCount(string.Format("SELECT * FROM Comity WHERE Name='{0}' AND Id<>'{1}'", textBoxName.Text, Id)) > 0)) { DatabaseConnection.getInstance().ExecuteQuery(string.Format("UPDATE Comity SET Name='{0}',Email='{1}' WHERE Id='{2}'", textBoxName.Text, textBoxEmail.Text, Id)); MessageBox.Show("Committee Updated"); frm.Reload(); this.Close(); } else { MessageBox.Show("Committee already exists with same name!"); } } catch (Exception exp) { MessageBox.Show("Failed to update Committee, Error : " + exp); } } else { MessageBox.Show("Email Field must not be empty"); } } else { MessageBox.Show("Committee Name must not empty or white spaces!"); } }
private void button1_Click(object sender, EventArgs e) { try { DatabaseConnection.getInstance().ExecuteQuery(string.Format("DELETE FROM Task WHERE ComityId='{0}'", Id)); DatabaseConnection.getInstance().ExecuteQuery(string.Format("DELETE FROM Comity WHERE Id='{0}'", Id)); MessageBox.Show("Committee Deleted!"); frm.Reload(); this.Close(); } catch (Exception exp) { MessageBox.Show("Failed to delete Committee, Error : " + exp); } }