Esempio n. 1
0
        private void btnlogin_Click(object sender, EventArgs e)
        {
            // check login admin
            if (txtUser.Text == Constant.username && txtPassword.Text == Constant.password)
            {
                User.updateStatusLoginAdmin(1);
                closeThread();
                GlobalSystem.is_admin = 1;
                Helper.roleWindown(true);
                Home frmHome = new Home("");
                this.Hide();
                frmHome.ShowDialog(this);
                this.Close();

                Slide2 frm1 = new Slide2();
                frm1.Close();
                return;
            }
            if (this.checkConnectServer() == true)
            {
                //login on server
                string username = txtUser.Text.Trim();
                string password = txtPassword.Text.Trim();
                processLogin(username, password);
            }
            else
            {
                MessageBox.Show(this.rm.GetString("checkconecthost", culture));
            }
        }
Esempio n. 2
0
        public void goToHome(String json)
        {
            if (GlobalSystem.socket != null)
            {
                GlobalSystem.socket.Disconnect();
                GlobalSystem.socket.Close();
            }
            Home frmHome = new Home(json);

            this.Hide();
            frmHome.ShowDialog(this);
            this.Close();
            Slide2 frm1 = new Slide2();

            frm1.Close();
        }
Esempio n. 3
0
 public void closingFormHome()
 {
     this.Invoke(new MethodInvoker(delegate
     {
         Logger.LogDebugFile("Set null and logout delegate");
         GlobalSystem.isLogout     = 1;
         GlobalSystem.islogin      = 0;
         GlobalSystem.user         = null;
         GlobalSystem.timeGameUser = null;
         Slide2 frm = new Slide2();
         this.Hide();
         frm.ShowDialog(this);
         this.Close();
     }));
     return;
 }
Esempio n. 4
0
        private void unLock()
        {
            if (this.t != null)
            {
                this.t.Abort();
            }
            Home frmHome = new Home("");

            this.Hide();
            frmHome.ShowDialog(this);
            this.Close();

            Slide2 frm1 = new Slide2();

            frm1.Close();
        }
Esempio n. 5
0
        private void gotoHomeByAdmin()
        {
            User.updateStatusLoginAdmin(1);
            closeThread();
            GlobalSystem.is_admin = 1;
            GlobalSystem.islogin  = 1;
            Helper.roleWindown(true);
            Home frmHome = new Home("");

            this.Hide();
            frmHome.ShowDialog(this);
            this.Close();

            Slide2 frm1 = new Slide2();

            frm1.Close();
            return;
        }
Esempio n. 6
0
        private void btnchangepass_Click(object sender, EventArgs e)
        {
            try
            {
                string pass        = txtpass.Text;
                string passComfirm = txtComfirmPass.Text;
                if (string.IsNullOrEmpty(pass) || string.IsNullOrEmpty(passComfirm))
                {
                    MessageBox.Show("Phải nhập mật khẩu khóa máy");
                    return;
                }
                if (!passComfirm.Equals(pass))
                {
                    MessageBox.Show("Mật khẩu nhập lại không trùng với mật khẩu trên");
                    return;
                }

                GlobalSystem.user.pass_lock_computer = pass;
                GlobalSystem.islogin = 1;
                // an cac form truoc
                for (int i = Application.OpenForms.Count - 1; i >= 0; i += -1)
                {
                    if (!object.ReferenceEquals(Application.OpenForms[i], this))
                    {
                        Application.OpenForms[i].Hide();
                    }
                }
                this.Hide();
                Slide2 frm = new Slide2();
                frm.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi hệ thống!");
                Logger.LogThisLine("Lỗi hệ thống!: " + ex.Message);
                this.Close();
            }
        }
Esempio n. 7
0
        public void processLogin(string username, String password, String token = "")
        {
            try
            {
                if (GlobalSystem.islogin == 0)
                {
                    GlobalSystem.timeStart = DateTime.Now;
                }

                string myParameters = "username="******"&password="******"&token=" + token;

                string URI = Constant.serverHost + Constant.methodLogin;
                using (WebClient wc = new WebClient())
                {
                    wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                    string HtmlResult = wc.UploadString(URI, myParameters);
                    Logger.LogDebugFile("Login json tra ve: " + HtmlResult);
                    dynamic data = JObject.Parse(HtmlResult);
                    Logger.LogDebugFile("check status login: "******"Login last_time_request: " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " |Tong tien" + data.data.total_monney);
                        objUser.last_time_request = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                        //thời gian này dùng để công thêm 3 phút rồi gọi lên server
                        objUser.last_request_time = data.data.last_request_time;

                        //them truong check có phải may thi đấu hay không
                        objUser.in_competitive = data.data.in_competitive;

                        objUser.conversation_id = data.data.conversation_id;
                        Logger.LogDebugFile("Start check group_user_info");
                        if (data.data.group_user_info != null)
                        {
                            Logger.LogDebugFile("Data group_user_info: " + data.data.group_user_info.promotion_percent);
                            objUser.promotion_percent = data.data.group_user_info.promotion_percent;
                        }
                        else
                        {
                            if (InvokeRequired)
                            {
                                this.Invoke(new MethodInvoker(delegate
                                {
                                    Helper.showMessageError("Lỗi đăng nhập. User không thuộc nhóm user nào");
                                }));
                            }
                        }
                        Logger.LogDebugFile("End check group_user_info");
                        Logger.LogDebugFile("Start check group_computer_info");
                        if (data.data.group_computer_info != null)
                        {
                            Logger.LogDebugFile("Data group_computer_info: " + data.data.group_computer_info.price);
                            objUser.price = data.data.group_computer_info.price;
                        }
                        else
                        {
                            if (InvokeRequired)
                            {
                                this.Invoke(new MethodInvoker(delegate
                                {
                                    Helper.showMessageError("Lỗi đăng nhập. máy tính hiện tại chưa được cấu hình vào nhóm máy");
                                }));
                            }
                        }
                        Logger.LogDebugFile("End check group_computer_info");
                        // check tiền có hay không
                        var totalMonney = Int32.Parse(objUser.total_monney.ToString()) + Int32.Parse(objUser.total_discount.ToString());
                        Logger.LogDebugFile("Total Monney: " + totalMonney);
                        objUser.total_money_login_session = totalMonney;

                        Logger.LogDebugFile("Set updateGlobalTimeGame");
                        Helper.updateGlobalTimeGame(HtmlResult);
                        Logger.LogDebugFile("End set updateGlobalTimeGame");
                        GlobalSystem.user = objUser;
                        Home frmHome = new Home(HtmlResult);
                        this.Hide();
                        frmHome.ShowDialog(this);
                        this.Close();

                        Slide2 frm1 = new Slide2();
                        frm1.Close();
                    }
                    else if (data.status == 401)
                    {
                        //check xem co may nao da login tren tai khoan nay chua
                        String ip        = data.data[0].ip.ToString();
                        String _username = data.data[0].username.ToString();
                        Helper.logoutCliendWithAccount(ip, "1", _username);
                        ShowProcessLoad frmAlert = new ShowProcessLoad("Tài khoản bạn đang đăng nhập nơi khác, vui lòng đăng nhập lại sau vài giây nữa!");
                        frmAlert.ShowDialog(this);
                        return;
                    }
                    else
                    {
                        if (InvokeRequired)
                        {
                            this.Invoke(new MethodInvoker(delegate
                            {
                                String message = data.message;
                                Helper.showMessageError(message);
                            }));
                        }
                        else
                        {
                            String message = data.message;
                            Helper.showMessageError(message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (InvokeRequired)
                {
                    this.Invoke(new MethodInvoker(delegate
                    {
                        Logger.LogThisLine("processLogin: "******"processLogin: "******"processLogin: "******"processLogin: " + ex.Message);
                }
            }
        }