我在CURRENTUSER
中有一个变量GlobalVariable.cs
:
在LoginPage.xaml.cs
:
导航到ConceptForm.xaml.cs
后,它会被调用几次:
public partial class ConceptForm : Page
{
//Default Constructor
public ConceptForm()
{
//Initializing the Default Constructor
InitializeComponent();
//Debugging Code To Indicate Current Signed In User
string cU = GlobalVariables.**CURRENTUSER**.ToString();
MessageBox.Show(cU);
//Get Current User Name Based On login credentials
campaignProductManagerBox.Text = campaignProductManagerBox.Text + GlobalVariables.USERS[GlobalVariables.**CURRENTUSER**, 2];
//Get Current Date And Time
DateTime dAT = DateTime.Now;
dateAndTimeBox.Text = dateAndTimeBox.Text + dAT;
//Get Current User Phone Number Based On Login Credentials
contactNumberBox.Text = contactNumberBox.Text + GlobalVariables.USERS[GlobalVariables.**CURRENTUSER**, 4];
//Conditional to determine Quarter of the Year Based On Date And Time Gotten Earlier
//If current month is January, February or March
if ( dAT.Month == 1 || dAT.Month == 2 || dAT.Month == 3 )
{
//It is the First Quarter of the Year
conceptIdBox.Text = conceptIdBox.Text + "Q1_";
}
//If current month is April, May or June
else if (dAT.Month == 4 || dAT.Month == 5 || dAT.Month == 6 )
{
//It is the Second Quarter of the Year
conceptIdBox.Text = conceptIdBox.Text + "Q2_";
}
//If current month is July, August or September
else if (dAT.Month == 7 || dAT.Month == 8 || dAT.Month == 9)
{
//It is the Third Quarter of the Year
conceptIdBox.Text = conceptIdBox.Text + "Q3_";
}
else
{
//It is the Fourth Quarter of the Year
conceptIdBox.Text = conceptIdBox.Text + "Q2_";
}
//Get Current User Department Based On Login Credentials
conceptIdBox.Text = conceptIdBox.Text + GlobalVariables.USERS[GlobalVariables.**CURRENTUSER**, 3] + "_0";
}
但是,导航到CURRENTUSER
后,0
的值重置为ConceptForm.xaml.cs
通过在LoginPage.xaml.cs
和ConceptForm.xaml.cs
中进行一些调试,我得到了进一步的证据,告诉我点击Login
上的LoginPage.xaml.cs
,CURRENTUSER
的值根据提供的登录凭据,1
是正确的,但在加载ConceptForm.xaml.cs
时,它会告诉我CURRENTUSER
现在是0
,这是不正确的。
这导致错误的信息显示在ConceptForm.xaml.cs
上CURRENTUSER
依赖于显示的信息。
我做错了什么,拜托?
提前谢谢!