导航时全局变量重置

时间:2016-08-03 06:42:20

标签: c# .net wpf xaml

我在CURRENTUSER中有一个变量GlobalVariable.cs

GlobalVariables.cs

LoginPage.xaml.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.csConceptForm.xaml.cs中进行一些调试,我得到了进一步的证据,告诉我点击Login上的LoginPage.xaml.csCURRENTUSER的值根据提供的登录凭据,1是正确的,但在加载ConceptForm.xaml.cs时,它会告诉我CURRENTUSER现在是0,这是不正确的。

这导致错误的信息显示在ConceptForm.xaml.csCURRENTUSER依赖于显示的信息。

我做错了什么,拜托?

提前谢谢!

0 个答案:

没有答案