コード例 #1
0
ファイル: checkout.cs プロジェクト: PBJ-1234/Storefront
 // Opens and refreshes storepage
 private void returnToStore(object sender, MouseEventArgs e)
 {
     this.Close();
     prev.Show();
     prev.Enabled = true;
     prev.reinitalizeUser();
 }
コード例 #2
0
        //Grabs info, checks for existance, and returns file or sends error
        private void loginStore(object sender, MouseEventArgs e)
        {
            bool   exists      = false;
            User   currentUser = new User();
            string user        = Path.Combine(storeClasses.generalFilePath, "Users", UsernameBox.Text + ".txt");
            string pass        = PasswordBox.Text;

            string projectPath = storeClasses.generalFilePath;

            projectPath = Path.Combine(projectPath, "Users");

            foreach (string itemFile in Directory.EnumerateFiles(projectPath))
            {
                if (itemFile == user)
                {
                    exists = true;
                    string[] info = System.IO.File.ReadAllLines(itemFile);
                    if (info[0] == pass)
                    {
                        currentUser.name     = UsernameBox.Text;
                        currentUser.password = info[0];
                        currentUser.ID       = long.Parse(info[1]);
                        currentUser.wallet   = double.Parse(info[2]);
                        currentUser.address  = info[3];
                    }
                    else
                    {
                        MessageBox.Show("Please retry login.");
                        tries++;
                        if (tries > 3)
                        {
                            MessageBox.Show("Too many tries attempted, now exiting...");
                            Environment.Exit(0);
                        }
                        return;
                    }
                }
            }
            if (exists == false)
            {
                MessageBox.Show("Please retry login.");
                return;
            }
            this.Hide();
            StorePage store = new StorePage(currentUser);

            store.Closed += (s, args) => this.Close();
            store.Show();
        }