コード例 #1
0
        private void LoginButton_Click(object sender, EventArgs e)
        {
            int         help = -1;
            List <User> U    = new List <User>();

            U = ShopDatabase.GetUser("Admin");
            string username = usernameTextBox.Text;
            string password = passwordTextBox.Text;

            for (int i = 0; i < U.Count; i++)
            {
                if (U[i].Username == username && U[i].Password == password)
                {
                    help = i;
                    this.Hide();
                    U[i].SetList(U[i]);
                    U[i].SetID(1);
                    MessageBox.Show(username + " successfully logged in");
                    Main sistema = new Main();
                    sistema.ShowDialog();
                    this.Close();
                }
            }
            if (help == -1)
            {
                MessageBox.Show("Wrong username or password");
            }
        }
コード例 #2
0
 private void Ref()
 {
     gamesList.Items.Clear();
     games = ShopDatabase.GetGames("Games");
     for (int i = 0; i < games.Count; i++)
     {
         gamesList.Items.Add(games[i].name + "    " + games[i].price + "$    " + games[i].year + " year");
     }
 }
コード例 #3
0
ファイル: AddGame.cs プロジェクト: dziugas84/PSI-PROJECT
 private void saveButton_Click(object sender, EventArgs e)
 {
     if (nameTextBox.Text != "" && Convert.ToString(yearBox1) != "" && Convert.ToString(priceTextBox) != "")
     {
         Game n = new Game();
         n.name  = nameTextBox.Text;
         n.price = Convert.ToDouble(priceTextBox.Text);
         n.year  = Convert.ToInt32(yearBox1.Text);
         ShopDatabase.SaveGames("Games", n);
         MessageBox.Show("Game has been added");
         Close();
     }
     else
     {
         MessageBox.Show("Fill in all text boxes");
     }
 }
コード例 #4
0
ファイル: Payment.cs プロジェクト: dziugas84/PSI-PROJECT
        private void payButton_Click(object sender, EventArgs e)
        {
            PaymentClass P = new PaymentClass {
                Amount = Convert.ToString(B[0].Payment(B)), Username = U.Username
            };
            List <PaymentClass> Plist = new List <PaymentClass>();

            Plist = ShopDatabase.GetPayment("Payment");
            if (Plist.Count == 0)
            {
                P.ID = 1;
                ShopDatabase.SavePayment("Payment", P);
            }
            else
            {
                P.ID = Plist[Plist.Count - 1].ID + 1;
                ShopDatabase.SavePayment("Payment", P);
            }
            MessageBox.Show("works");
        }
コード例 #5
0
ファイル: Registration.cs プロジェクト: dziugas84/PSI-PROJECT
 private void createUser_Click(object sender, EventArgs e)
 {
     if (nameTextBox.Text == "" || surnameTextBox.Text == "" || usernameTextBox.Text == "" || passwordTextBox.Text == "")
     {
         MessageBox.Show("Fill in all text boxes");
     }
     else
     {
         User u = new User();
         u.Name     = nameTextBox.Text;
         u.Surname  = surnameTextBox.Text;
         u.Username = usernameTextBox.Text;
         u.Password = passwordTextBox.Text;
         List <User> help = new List <User>();
         int         h    = 0;
         help = ShopDatabase.GetUser("User");
         for (int i = 0; i < help.Count; i++)
         {
             if (help[i].Username == u.Username)
             {
                 MessageBox.Show("This Username is already taken");
                 h = 1;
                 i = help.Count + 1;
             }
         }
         if (h == 0)
         {
             ShopDatabase.SaveUser("User", u);
             MessageBox.Show("New user has been created");
             Close();
         }
     }
     nameTextBox.Text     = "";
     surnameTextBox.Text  = "";
     usernameTextBox.Text = "";
     passwordTextBox.Text = "";
 }
コード例 #6
0
 private void delete_game_Click(object sender, EventArgs e)
 {
     if (gamesList.SelectedItem != null)
     {
         string item = Convert.ToString(gamesList.SelectedItem);
         for (int i = 0; i < games.Count; i++)
         {
             if (item.Contains(games[i].name))
             {
                 Game help = new Game();
                 help.name  = games[i].name;
                 help.price = games[i].price;
                 help.year  = games[i].year;
                 ShopDatabase.DeleteGames("Games", help);
                 MessageBox.Show("Game has been deleted");
                 Ref();
             }
         }
     }
     else
     {
         MessageBox.Show("Please select the game first");
     }
 }