anupama b

anupama b

  • NA
  • 7
  • 3.4k

Accessing the code in One If Condition from another condition

Feb 10 2012 7:36 AM
Hi,

I am trying to access the code in another if condition from another but unable to . could you please suggest an approach. Here is the code i am using

foreach (string arg in Environment.GetCommandLineArgs())
{
if (arg == "–Auto_BlueGrass")
{
for (int i = 0; i < 2; i++)
{
if (i==0)
{
mstrSwitch = "BluegrassCH";
AllocConsole();
Console.WriteLine("BlueGrass Chargeable Claims Job started in Auto mode - " + DateTime.Now + " ");
mblnAutomode = true;
goto AutoModePoint;
}
else if(i==1)
{
mstrSwitch = "BluegrassRP";
AllocConsole();
Console.WriteLine("BlueGrass Reporting Claims Job started in Auto mode - " + DateTime.Now + " ");
mblnAutomode = true;
goto AutoModePoint;
}
}


}



AutoModePoint: if (!IsUserAuthorized())
{
if (mblnAutomode)
{
Console.WriteLine("You do not have permissions to run this application. This application will now close." + " " + DateTime.Now);
Application.Current.Shutdown();
}
else
{
MessageBox.Show("You do not have permissions to run this application. This application will now close.", "No Access", MessageBoxButton.OK, MessageBoxImage.Stop);
Application.Current.Shutdown();
}
}
else
{
this.DataContext = this;
DefinePacificareStateCodes();
ReadApplicationSettings();
}


In the above code first i am using a for condition inside a if and foreach condition.

After execution the steps next to if(i==0) cond it has to goto the if (!IsUserAuthorized()) and execute those steps under that condition.
I tried using the goto statement but in that case it only executes if(i==0) condition but i also want if(i==1) condition to eexecute once the i is incremented in for loop which is not happening using goto statement could anyone please suggets an approach or any idea is appreciated

Aim : suppose i have a x job and x1 and x2 are sub jobs to it instead of executing x1 and x2 individually whenever i click on x first it has to complete x1 and then it should automatically start x2 and complete it.

if question is not understandable please let me know i will modify the question more ..




Answers (1)