private bool IsValid()
{
try
{
if (string.IsNullOrEmpty(TxtBroker.Text))
throw new Exception("Please Enter Valid Broker Name.");
if (string.IsNullOrEmpty(TxtPhone.Text))
throw new Exception("Please ENter Valid Phone No.");
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
private void BtnSave_Click(object sender, EventArgs e)
{
try
{
if (IsValid())
{
//write your code
}
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
No comments:
Post a Comment