hello
i want to run this code,where all fields is not null then Query will be Executed,if not then message will be displayed
private bool IsValidationSuccess()
{
try
{
if (string.IsNullOrEmpty(txtCompanyName.Text.Trim())
{
try
{
if (string.IsNullOrEmpty(txtCompanyName.Text.Trim())
&& string.IsNullOrEmpty(txtCompanyAddress1.Text) &&string.IsNullOrEmpty(txtPincode.Text.Trim())
&& cmbDistrict.SelectedIndex <=0 && cmbTaluka.SelectedIndex <=0)
{
return false;
}
else
{
return true ;
}
}
catch (SqlException ex)
{
throw ex;
}
&& cmbDistrict.SelectedIndex <=0 && cmbTaluka.SelectedIndex <=0)
{
return false;
}
else
{
return true ;
}
}
catch (SqlException ex)
{
throw ex;
}
//on button click
if (IsValidationSuccess())
{
AddCompanyDetails();
}
else
{
MessageBox.Show("Please fill Compulsary(*) field");
}
///////////////////////////////
{
AddCompanyDetails();
}
else
{
MessageBox.Show("Please fill Compulsary(*) field");
}
///////////////////////////////
error:when all field contain data it returns false,and message box is displayed .

Sujeet SumanRank #790 · 2.9K reputationPosted Feb 3, 2016, 6:01 AM EST
|| cmbDistrict.SelectedIndex <=0 || cmbTaluka.SelectedIndex <=0)
return false;
}
else
{
return true ;
}
Abhay ShankerRank #375 · 6.7K reputationPosted Feb 3, 2016, 3:21 PM EST
Priya M36 reputationPosted Feb 4, 2016, 12:18 AM EST
Sujeet SumanRank #790 · 2.9K reputationPosted Feb 5, 2016, 5:14 PM EST