Example #1
0
        private void CheckLineConnection()
        {
            Online = new StateClass.ConnectionStr().ConnectionSuccess;

            if (Online)
            {
                if (OnlineMode.Checked)
                {
                    StateClass.SC_UserLogin login = new StateClass.SC_UserLogin();
                    login.UserName = Properties.Settings.Default.AppUser;
                    login.Password = Properties.Settings.Default.AppUserToken;

                    //If it is allowed to sign in automatically

                    login.IsToken = Properties.Settings.Default.KeepSignIn ? "1" : "2";

                    StateClass.LoginResult loginres = login.Login();
                    //Check first if it is secured. we need to login
                    if (loginres.Login)
                    {
                        Properties.Settings.Default.AppUserToken = loginres.Token;
                        return;
                    }

                    if (loginres.isSecured)
                    {
                        DialogResult res = new Login().ShowDialog();
                        if (res != DialogResult.OK)
                        {
                            this.Close();
                            return;
                        }
                    }
                }
            }
            else
            {
                OfflineMode.Checked = true;
                OnlineMode.Checked  = false;
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            StateClass.SC_UserLogin sclogin = new StateClass.SC_UserLogin();
            sclogin.UserName = textBox1.Text;
            sclogin.Password = textBox2.Text;
            StateClass.LoginResult result = sclogin.Login();

            if (result.Login)
            {
                Properties.Settings.Default.AppUser      = textBox1.Text;
                Properties.Settings.Default.AppUserToken = result.Token;
                Properties.Settings.Default.KeepSignIn   = checkBox1.Checked;
                Properties.Settings.Default.Save();
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                label3.Visible = true;
            }
        }