示例#1
0
        private void lblMenu_Click(object sender, EventArgs e)
        {
            ProfileForm pf = new ProfileForm(null, this);

            pf.MdiParent = MForm.MdiParent;
            pf.Show();
            pf.Location = new Point(0, 0);
            MForm.Close();
        }
示例#2
0
        /// <summary>
        /// логирање доколку играчот има постоечки акаунт + база на податоци.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            string userName = tbUsername.Text;

            Username = tbUsername.Text;
            string password = tbPass.Text;

            if (tbUsername.Text == "" && tbPass.Text == "")
            {
                MessageBox.Show("Enter username or password");
                flag = true;
            }
            else
            {
                string query = "SELECT * FROM PlayerTable WHERE username = '******'";
                cmd = new SqlCeCommand(query, con);

                con.Open();
                try
                {
                    rdr = cmd.ExecuteReader();
                    rdr.Read();


                    string probaUser = rdr[0].ToString().Trim();
                    string probaPass = rdr[1].ToString().Trim();

                    con.Close();
                    //погрешна лозинка
                    if (userName.Equals(probaUser.ToString()) && !password.Equals(probaPass.ToString()))
                    {
                        MessageBox.Show("The password is incorrect.");
                        tbPass.Select(0, tbPass.Text.Length);
                    }

                    // се е во ред.
                    else
                    {
                        ProfileForm PF = new ProfileForm(this, null);
                        PF.MdiParent = this.MdiParent;
                        PF.Show();
                        PF.Location = new Point(0, 0);
                    }
                }
                catch
                {
                    if (!flag)
                    {
                        MessageBox.Show("The user name or password is incorrect.");
                    }
                    tbUsername.Select(0, tbUsername.Text.Length);
                }
            }
        }