当前位置: 首页>>代码示例>>C#>>正文


C# Control.Show方法代码示例

本文整理汇总了C#中Control.Show方法的典型用法代码示例。如果您正苦于以下问题:C# Control.Show方法的具体用法?C# Control.Show怎么用?C# Control.Show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Control的用法示例。


在下文中一共展示了Control.Show方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnLogin_Click

        private void btnLogin_Click(object sender, RoutedEventArgs e)  //*****the function of login button*****
        {
            if (txtUsername.Text == "")      //check if the username field is empty
            {
                MessageBox.Show("You have to enter your Matric number (username) to log in!");
                return;
            }
            else if (passwordBox1.Password == "") //check if the password field is empty
            {
                MessageBox.Show("You have to enter your password to log in!");
                return;
            }
            else
            {
                StreamReader SR;
                string S;
                SR = File.OpenText(@"students.txt");     //load data from 'students.txt' using StreamReader
                S = SR.ReadLine();

                while (S != null)    //using the while loop to load data to the 3 lists
                {
                    string[] words = S.Split(',');
                    if (words.Count() > 4)
                    {
                        nameList.Add(words[0]);
                        usernameList.Add(words[1]);
                        passwordList.Add(words[2]);
                    }

                    S = SR.ReadLine();

                }

                SR.Close();

                bool check = false;

                for (int i = 0; i < usernameList.Count(); i++)
                {
                    if (txtUsername.Text == usernameList[i])      //to check if the username entered by the user exists in the data base
                    {
                        if (passwordBox1.Password == passwordList[i])  //the case which the password is correct
                        {
                            StreamWriter writer = new StreamWriter(@"matricNo.txt");
                            writer.WriteLine(usernameList[i]);
                            writer.Close();
                            StreamWriter writers = new StreamWriter(@"name.txt");
                            writers.WriteLine(nameList[i]);
                            writers.Close();
                            Control controlwindow = new Control();
                            controlwindow.Show();
                            controlwindow.labelwelcome.Content = nameList[i]+"  (" + usernameList[i] +")   ";
                           // MessageBox.Show("Welcome, " + nameList[i] + "!");
                            this.Close();
                            check = true;
                            return;
                        }
                        else if (passwordBox1.Password != passwordList[i])  //the case which the password is incorrect
                        {
                            MessageBox.Show("The password you entered is invalid. Please try again.");
                            check = true;
                            return;

                        }
                    }
                }

                if (check == false)   //the case the username is not registered in the data base
                {
                    MessageBox.Show("No such user! Please check again!");
                }
            }
        }
开发者ID:hywq3857,项目名称:2103final,代码行数:73,代码来源:MainWindow.xaml.cs


注:本文中的Control.Show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。