示例#1
0
        private void LogInForm_Activated(object sender, EventArgs e)
        {
            //bat timer check internet
            CheckInternet_timer.Interval = 50;
            CheckInternet_timer.Enabled  = true;

            this.Name_textbox.Focus();
            //DataTable SavedAccount = new DataTable();
            //SavedAccount = SupportUtility.FindSavedAccount();
            //if(SavedAccount.Rows.Count>0)
            //{
            //    Name_textbox.Text = SavedAccount.Rows[0]["UserName"].ToString();
            //    Pass_textbox.Text = SavedAccount.Rows[0]["PassWord"].ToString();
            //    Save_checkbox.Checked = true;
            //}
            //else
            //{
            //    Save_checkbox.Checked = false;
            //}
            string UserNameSaved = "";
            string PassSave      = "";

            SupportUtility.FindSavedAccount(ref UserNameSaved, ref PassSave);
            if (UserNameSaved != null)
            {
                Name_textbox.Text     = UserNameSaved;
                Pass_textbox.Text     = PassSave;
                Save_checkbox.Checked = true;
            }
        }
示例#2
0
 private void Save_checkbox_CheckedChanged(object sender, EventArgs e)
 {
     if (Save_checkbox.Checked)
     {
         if (SupportUtility.IsCorrectAccount(Name_textbox.Text, Pass_textbox.Text))
         {
             SupportUtility.SaveAccount(Name_textbox.Text, Pass_textbox.Text);
         }
         else
         {
             MessageBox.Show("Tài khoản không tồn tại hoặc mật khẩu sai", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             Save_checkbox.Checked = false;
         }
     }
     else
     {
         //string dataSava = "";
         //DataTable savedAccount = SupportUtility.FindSavedAccount();
         //if(savedAccount.Rows.Count>0)
         //{
         //    SupportUtility.UnSaveAccount(savedAccount.Rows[0]["UserName"].ToString());
         //}
         SupportUtility.UnSaveAccount();
     }
 }
        private void SendCode_button_Click(object sender, EventArgs e)
        {
            if (SupportUtility.IsExistEmail(Email_textbox.Text))
            {
                verifyCode = rdcode.Next(100000, 999999).ToString();

                Thread newThread = new Thread(
                    delegate()
                {
                    SupportUtility.SendConfirmEmailToResetPassword(Email_textbox.Text, verifyCode);
                });
                newThread.Start();
                //SupportUtility.SendConfirmEmailToResetPassword(Email_textbox.Text, verifyCode);
                SendCode_button.Enabled       = false;
                Email_textbox.Enabled         = false;
                ResetPass_button.Enabled      = true;
                ResendCountdown_timer.Enabled = true;
                CountdownResend_label.Visible = true;
                AcceptButton = ResetPass_button;
            }
            else
            {
                MessageBox.Show("Tài khoản không tồn tại", "Thộng báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 private void ResetPass_button_Click(object sender, EventArgs e)
 {
     if (NewPass_textbox.Text == ConfirmPass_textbox.Text)
     {
         if (NewPass_textbox.Text != "" && ConfirmCode_textbox.Text != "" && ConfirmPass_textbox.Text != "")
         {
             if (verifyCode == ConfirmCode_textbox.Text)
             {
                 SupportUtility.ResetPassword(Email_textbox.Text, NewPass_textbox.Text);
                 logInForm.Show();
                 logInForm.Name_textbox.Text = SupportUtility.FindNameFromEmail(Email_textbox.Text);
                 logInForm.Pass_textbox.Text = NewPass_textbox.Text;
                 this.Dispose();
             }
             else
             {
                 MessageBox.Show("Mã xác nhận không hợp lệ", "Thộng báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         else
         {
             MessageBox.Show("Chưa nhập đầy đủ thông tin", "Thộng báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     else
     {
         MessageBox.Show("Mật khẩu không trùng khớp", "Thộng báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        private void RoomChose_FormClosing(object sender, FormClosingEventArgs e)
        {
            Mycnt.Open();
            string query = string.Format("update roomlist set HostID = '', Isclosed = '0', IsReady = '0',IsStart ='0' where hostid = '{0}'"
                                         + " update roomlist set GuestID = '', Isclosed = '0', IsReady = '0',IsStart ='0' where GuestID = '{0}'" +
                                         " delete from Roomlist where HostID = '' and GuestID = ''" + " delete from roomquestions where exists (select * from roomlist where guestid ='' and hostid ='' )" +
                                         " delete from roomquestions where roomid not in (select roomid from roomlist) " + " delete from RoomResult where  roomid not in (select roomid from roomlist)" +
                                         " update RoomList set HostID = GuestID, GuestID = '', Isclosed = '0', IsReady = '0',IsStart ='0' where HostID = '' and GuestID != ''", PlayerName);
            SqlCommand cmd = new SqlCommand(query, Mycnt);

            cmd.ExecuteNonQuery();
            Mycnt.Close();
            SupportUtility.UnSignIn(PlayerName);
        }
        private void Resend_button_Click(object sender, EventArgs e)
        {
            signUpForm.verifyCode = rdCode.Next(100000, 999999).ToString();
            Thread newThread = new Thread
                               (
                delegate()
            {
                SupportUtility.SendConfirmEmailToCreateAccount(signUpForm.Email_textbox.Text, signUpForm.verifyCode);
            }
                               );

            newThread.Start();
            Resend_button.Enabled         = false;
            CountDownResend_label.Visible = true;
            Resend_timer.Enabled          = true;
        }
 private void Confirm_button_Click(object sender, EventArgs e)
 {
     if (TypeCode_textbox.Text == signUpForm.verifyCode)
     {
         SupportUtility.CreateAccount(signUpForm.Email_textbox.Text, signUpForm.Name_textbox.Text, signUpForm.Pass_textbox.Text);
         roomChose = new RoomChose(signUpForm.Name_textbox.Text, signUpForm.logInForm);
         this.signUpForm.logInForm.inRoom = roomChose;
         roomChose.Show();
         signUpForm.Dispose();
         this.Dispose();
     }
     else
     {
         MessageBox.Show("Mã xác nhận sai!");
     }
 }
 private void SignUp_button_Click(object sender, EventArgs e)
 {
     if (Email_textbox.Text != "" && Name_textbox.Text != "" && Pass_textbox.Text != "" && ConfirmPass_textbox.Text != "")
     {
         if (!SupportUtility.IsExistEmail(Email_textbox.Text))
         {
             if (!SupportUtility.IsExistAccount(Name_textbox.Text))
             {
                 if (ConfirmPass_textbox.Text == Pass_textbox.Text)
                 {
                     verifyCode = rdCode.Next(100000, 999999).ToString();
                     try
                     {
                         SupportUtility.SendConfirmEmailToCreateAccount(Email_textbox.Text, verifyCode);
                         confirmNewAccount = new ConfirmNewAccount(this);
                         confirmNewAccount.Show();
                         this.Hide();
                     }
                     catch (Exception)
                     {
                         MessageBox.Show("Không thể gửi mail", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     }
                 }
                 else
                 {
                     MessageBox.Show("Mật khẩu không trùng khớp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
             else
             {
                 MessageBox.Show("Tên người dùng đã được sử dụng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             MessageBox.Show("Email đã được sử dụng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         MessageBox.Show("Vui lòng nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#9
0
 //--------------------------
 // Handle Event
 private void SignIn_button_Click(object sender, EventArgs e)
 {
     if (this.Name_textbox.Text != "" && this.Pass_textbox.Text != "")
     {
         if (SupportUtility.IsExistAccount(this.Name_textbox.Text))
         {
             if (SupportUtility.IsCorrectAccount(this.Name_textbox.Text, this.Pass_textbox.Text))
             {
                 if (!SupportUtility.IsSignIn(Name_textbox.Text))
                 {
                     //inRoom = new RoomChose(this.Name_textbox.Text);
                     inRoom = new RoomChose(this.Name_textbox.Text, this);
                     this.Hide();
                     inRoom.Show();
                     SupportUtility.SetSignIn(Name_textbox.Text);
                 }
                 else
                 {
                     MessageBox.Show("Tài khoản đang được sử dụng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                 }
             }
             else
             {
                 MessageBox.Show("Mật khẩu không đúng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
         else
         {
             MessageBox.Show("Tài khoản không tồn tại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         MessageBox.Show("Vui lòng nhập đủ thông tin", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#10
0
 private void CheckInternet_timer_Tick(object sender, EventArgs e)
 {
     if (SupportUtility.IsConnectedToInternet())
     {
         parent.canRunTimer = true;
     }
     else
     {
         parent.canRunTimer          = false;
         CheckInternet_timer.Enabled = false;
         DialogResult result = MessageBox.Show("Mất kết nói, nhấn \"OK \" để quay lại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         if (result == DialogResult.OK)
         {
             if (inRoom != null)
             {
                 parent.IsSignIn = inRoom.PlayerName;
                 using (StreamWriter sw = File.CreateText("SignInName.txt"))
                 {
                     sw.WriteLine(parent.IsSignIn);
                 }
                 if (inRoom.room != null)
                 {
                     if (inRoom.room.check_timer != null)
                     {
                         inRoom.room.check_timer.Enabled = false;
                     }
                     if (inRoom.room.game != null)
                     {
                         if (inRoom.room.game.timer != null)
                         {
                             inRoom.room.game.timer.Enabled = false;
                         }
                         if (inRoom.room.game.timer3 != null)
                         {
                             inRoom.room.game.timer3.Enabled = false;
                         }
                         if (inRoom.room.game.timer2 != null)
                         {
                             inRoom.room.game.timer2.Enabled = false;
                         }
                         inRoom.room.game.Dispose();
                     }
                     inRoom.room.Dispose();
                 }
                 inRoom.Dispose();
             }
             else if (resetPass != null)
             {
                 resetPass.Dispose();
             }
             else if (signUpForm != null)
             {
                 if (signUpForm.confirmNewAccount != null)
                 {
                     signUpForm.confirmNewAccount.Dispose();
                 }
                 signUpForm.Dispose();
             }
             parent.Show();
             this.Dispose();
         }
     }
 }
示例#11
0
 private void Logout_button_Click(object sender, EventArgs e)
 {
     loginForm.Show();
     SupportUtility.UnSignIn(PlayerName);
     this.Close();
 }