Beispiel #1
0
        private bool isUserExist(string userName)
        {
            bool result = false;

            try
            {
                string sql = string.Format("SELECT * FROM M_USERS WHERE LOWER(USERID) = '{0}'", userName.ToLower());
                var    res = SQLiteCommon.ExecuteSqlWithResult(sql);

                if (res != null && res.HasRows)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }

            return(result);
        }
Beispiel #2
0
        private bool isDeviceExist(string macAddress)
        {
            bool result = false;

            try
            {
                string sql = string.Format("SELECT * FROM M_DEVICES WHERE LOWER(MACADDRESS) = '{0}'", macAddress.ToLower());
                var    res = SQLiteCommon.ExecuteSqlWithResult(sql);

                if (res != null && res.HasRows)
                {
                    result = true;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }

            return(result);
        }
Beispiel #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string userName = this.txtUserName.Text.Trim();
                string passWord = this.txtPassword.Text.Trim();

                if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(passWord))
                {
                    ShowMsg(MessageBoxIcon.Warning, "Please input UserName Or Password!");
                    this.txtUserName.Focus();
                    return;
                }

                string sql    = string.Format("SELECT * FROM M_USERS WHERE LOWER(USERID)='{0}' AND PASSWORD='******'", userName.ToLower(), passWord);
                var    result = SQLiteCommon.ExecuteSqlWithResult(sql);

                if (result != null && result.HasRows)
                {
                    CURRENT_USER = userName;
                    MainForm mainForm = new MainForm();
                    mainForm.Show();
                    this.Hide();
                }
                else
                {
                    ShowMsg(MessageBoxIcon.Warning, "UserName Or Password Wrong! Please input this again!");
                    this.txtUserName.Focus();
                    this.txtPassword.Text = string.Empty;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                ShowMsg(MessageBoxIcon.Error, ex.Message);
            }
        }