Exemplo n.º 1
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     label1.Text = duration.ToString();
     if (duration == 0)
     {
         timer1.Stop();
         Users_options uo = new Users_options(return_back);
         this.Hide();
         uo.Show();
     }
     duration--;
 }
Exemplo n.º 2
0
        private void Bt_Player2_continue_Click(object sender, EventArgs e) /* login player 2 */
        {
            if (Program.Test_Insert_Text(TB_user_name2.Text) == false || Program.Test_Insert_Text(TB_password2.Text) == false)
            {
                MessageBox.Show("Only English Characters And Numbers Allowed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (TB_user_name2.Text == Program.user1)
            {
                MessageBox.Show(Program.user1 + " Is allready conected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (GameBox.Program.User_Check(TB_user_name2.Text) == false || GameBox.Program.Password_Check(TB_password2.Text) == false) /* check if name and password a valid */
            {
                MessageBox.Show("Invalid Input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (COB_user2.Text == "Sign In")                                               /* if combo box is on login */
            {
                if (GameBox.Program.Check_NAME_exsist(TB_user_name2.Text, "Players") == 0) /* check if name exisist in database */
                {
                    MessageBox.Show("Invalid User Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (GameBox.Program.Check_Password_Is_correct(TB_user_name2.Text, TB_password2.Text, "Players") == false) /* check if password is correct */
                {
                    MessageBox.Show("Invalid Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else if (COB_user2.Text == "Sign Up")                                                        /* if conbo box is on sign up */
            {
                if (GameBox.Program.Insert_User_PLayers(TB_user_name2.Text, TB_password2.Text) == false) /* insurt user to players database */
                {
                    MessageBox.Show("User Name alreay exsist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                GameBox.Program.Insert_User__Scores(TB_user_name2.Text);  /*insurt user to score database */
                MessageBox.Show("User Created!", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            GameBox.Program.user2       = TB_user_name2.Text;          /* save users name */
            GameBox.Program.cnt_players = 2;                           /* count players update */
            GameBox.Program.InsertLogin(TB_user_name2.Text, "Player"); /* insert login time to login database*/
            Users_options uo = new Users_options(this);

            TB_password2.Text  = "";
            TB_user_name2.Text = "";
            this.Hide(); /* open nex screen */
            uo.Show();   /* hide this screen */
        }
Exemplo n.º 3
0
 private void Bt_User_login_Click(object sender, EventArgs e) /* Player login */
 {
     if (Program.Test_Insert_Text(Tb_user_name.Text) == false)
     {
         MessageBox.Show("Only english characters and numbers allowed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (Program.Test_Insert_Text(Tb_user_password.Text) == false)
     {
         MessageBox.Show("Only english characters and numbers allowed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (GameBox.Program.User_Check(Tb_user_name.Text) == false)/* check if name and password a valid */
     {
         MessageBox.Show("Invalid User Name - Wrong Input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (GameBox.Program.Password_Check(Tb_user_password.Text) == false)
     {
         MessageBox.Show("Invalid Password - Wrong Input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
     if (comboBox1.Text == "Sign in")                                              /* if combo box is on login */
     {
         if (GameBox.Program.Check_NAME_exsist(Tb_user_name.Text, "Players") == 0) /* check if name exisist in database */
         {
             MessageBox.Show("User Name Does not Exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (GameBox.Program.Check_Password_Is_correct(Tb_user_name.Text, Tb_user_password.Text, "Players") == false) /* check if password is correct */
         {
             MessageBox.Show("Invalid Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
     }
     else if (comboBox1.Text == "Sign up")                                                           /* if combo box is on sign up */
     {
         if (GameBox.Program.Insert_User_PLayers(Tb_user_name.Text, Tb_user_password.Text) == false) /* insurt user to players database */
         {
             MessageBox.Show("User Name alreay exsist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             return;
         }
         GameBox.Program.Insert_User__Scores(Tb_user_name.Text); /*insurt user to score database */
         MessageBox.Show("User Created!", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
     GameBox.Program.user1    = Tb_user_name.Text;             /* save users name */
     GameBox.Program.TypeUser = true;
     GameBox.Program.InsertLogin(Tb_user_name.Text, "Player"); /* insert login time to login database*/
     Tb_user_name.Text     = "";
     Tb_user_password.Text = "";
     if (cob_players.SelectedIndex == 0)
     {
         Program.cnt_players = 1; /* count players update */
         Users_options us = new Users_options(this);
         us.Show();               /* open nex screen */
         this.Hide();             /* hide this screen */
     }
     else
     {
         Program.cnt_players = 2;
         login_form log = new login_form(this);
         log.Show();
         this.Hide();
     }
 }