Пример #1
0
 private void btnExit_Click(object sender, EventArgs e)
 {
     if (checkBoxForgetMe.Checked == true)
     {
         MMUtils.SetRegistry("", "RememberMe", "0");
     }
 }
Пример #2
0
        public void m_cmdLogin_Click()
        {
            DialogResult result = DialogResult.None;

            ////// LOG IN ///////////////////////////

            if (logged == false)
            {
                if (MMUtils.GetRegistry("", "RememberMe") == "1")
                {
                    MMUtils.SetRegistry("", "CurrentUserName", MMUtils.GetRegistry("", "RememberedUserName"));
                    MMUtils.SetRegistry("", "CurrentUserEmail", MMUtils.GetRegistry("", "RememberedUserEmail"));
                }
                else
                {
                    using (LogInDlg _dlg = new LogInDlg())
                        result = _dlg.ShowDialog(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd));
                    if (result == DialogResult.Cancel)
                    {
                        return;
                    }
                }

                // Check for Places
                bool _noplaces = false;
                using (PlacesDB _db = new PlacesDB())
                {
                    DataTable _dt = _db.ExecuteQuery("select * from PLACES");
                    if (_dt.Rows.Count == 0) // No places yet
                    {
                        _noplaces = true;
                    }
                }
                if (_noplaces)
                {
                    using (FirstUserDlg _dlg = new FirstUserDlg())
                    {
                        result = _dlg.ShowDialog(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd));
                        if (result == DialogResult.Cancel)
                        {
                            return;
                        }

                        System.Windows.Forms.MessageBox.Show(MMUtils.GetString("places.placecreated.message"));
                    }
                }

                SUtils.currentUserName  = MMUtils.GetRegistry("", "CurrentUserName");
                SUtils.currentUserEmail = MMUtils.GetRegistry("", "CurrentUserEmail");

                logged = true;
                SynergyRibbon.Visible = true;
                SendKeys.SendWait("%(S)"); // Opens Synergy Ribbon Tab
            }

            //////// LOG OUT ////////////////////////////
            else
            {
                using (LogOutDlg _dlg = new LogOutDlg())
                {
                    result = _dlg.ShowDialog(new WindowWrapper((IntPtr)MMUtils.MindManager.hWnd));
                }
                if (result == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                // Close all Synergy maps
                bool _closeMaps = false;

                foreach (Document _doc in MMUtils.MindManager.AllDocuments)
                {
                    if (_doc.HasAttributesNamespace[SUtils.SYNERGYNAMESPACE])
                    {
                        if (_closeMaps)
                        {
                            docstoclose.Add(_doc);
                            continue;
                        }

                        if (MessageBox.Show(MMUtils.GetString("maps.userlogout.message"), "",
                                            System.Windows.Forms.MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            return;
                        }

                        _closeMaps = true;
                        docstoclose.Add(_doc);
                    }
                }

                logged = false;
                SynergyRibbon.Visible = false;
            }

            login_timer.Start();
        }
Пример #3
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool   passed       = false;
            bool   userfound    = false;
            string loginoremail = "LOGIN";

            aEmail = txtEmail.Text;

            if (txtEmail.Text == "")
            {
                lblEmail.ForeColor = System.Drawing.Color.Red;
            }
            else if (txtPassword.Text == "")
            {
                lblPassword.ForeColor = System.Drawing.Color.Red;
            }
            else
            {
                if (Internet.EmailIsValid(txtEmail.Text) == true)
                {
                    loginoremail = "EMAIL";
                }

                UsersDB   _db = new UsersDB();
                DataTable _dt = _db.ExecuteQuery("select * from USERS");
                foreach (DataRow _row in _dt.Rows)
                {
                    if (_row[loginoremail].ToString() == txtEmail.Text) // user found
                    {
                        userfound = true;
                        aName     = _row["NAME"].ToString();
                        aEmail    = _row["EMAIL"].ToString();
                        if (_row["PASS"].ToString() == txtPassword.Text) // TODO password decrypt?
                        {
                            passed = true;
                            MMUtils.SetRegistry("", "CurrentUserName", aName);
                            MMUtils.SetRegistry("", "CurrentUserEmail", aEmail);
                            if (checkBoxRemember.Checked == true)
                            {
                                MMUtils.SetRegistry("", "RememberMe", "1");
                                MMUtils.SetRegistry("", "RememberedUserName", aName);
                                MMUtils.SetRegistry("", "RememberedUserEmail", aEmail);
                            }
                            break;
                        }
                        else //password wrong
                        {
                            string _arg = MMUtils.GetString("loginDlg.login.text");
                            if (loginoremail == "EMAIL")
                            {
                                _arg = MMUtils.GetString("loginDlg.Email.text");
                            }
                            lblPasswordNoMatch.Text = String.Format(MMUtils.GetString("loginDlg.wrongpassword.text"), _arg);
                        }
                    }
                }

                _db.Dispose();

                if (!userfound)
                {
                    lblUserNoExists.Text = MMUtils.GetString("loginDlg.usernoexists.text");
                }

                if (passed)
                {
                    this.DialogResult = DialogResult.OK;
                }
            }
        }