Esempio n. 1
0
        private void Login_Load(object sender, System.EventArgs e)
        {
            if (File.Exists("dac.accdb") == false || SubjectRegister.IsUserNameUsed("admin") == false || SubjectRegister.IsUserNameUsed("security_officer") == false)//若数据库文件不存在或则管理员账号不存在,则创建新的文件或者管理员帐号并退出
            {
                if (File.Exists("dac.accdb") == false)
                {
                    CreatDb();
                }
                if (SubjectRegister.IsUserNameUsed("admin") == false)
                {
                    //设置管理员账号及密码
                    MessageBox.Show(this, "未设置管理员账号,按确定设置管理员账号及密码", "设置管理员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text       = "设置管理员账号及密码";
                    register.getIsAdmin = true;
                    register.ShowDialog();
                    Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
                }
                if (SubjectRegister.IsUserNameUsed("security_officer") == false)
                {
                    //设置安全员账号及密码
                    MessageBox.Show(this, "未设置安全员账号,按确定设置安全员员账号及密码", "设置安全员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置安全员账号及密码";
                    register.GetIsSecurityOfficer = true;
                    register.ShowDialog();
                    Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
                }
            }
            Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
        }
Esempio n. 2
0
        private void 注册ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SubjectRegister.IsUserNameUsed("admin") == false || SubjectRegister.IsUserNameUsed("security_officer") == false)//若数据库文件不存在或则管理员账号不存在,则创建新的文件或者管理员帐号并退出
            {
                if (SubjectRegister.IsUserNameUsed("admin") == false)
                {
                    MessageBox.Show(this, "未设置管理员账号,按确定设置管理员账号及密码", "设置管理员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text       = "设置管理员账号及密码";
                    register.getIsAdmin = true;
                    register.ShowDialog();

                    return;
                }
                if (SubjectRegister.IsUserNameUsed("security_officer") == false)
                {
                    MessageBox.Show(this, "未设置安全员账号,按确定设置安全员员账号及密码", "设置安全员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置安全员账号及密码";
                    register.GetIsSecurityOfficer = true;
                    register.ShowDialog();

                    return;
                }
            }
            else
            {
                SubjectRegister register = new SubjectRegister();
                register.Text    = "设置普通用户账号及密码";
                register.isAdmin = false;
                register.ShowDialog();
            }
        }
Esempio n. 3
0
        private void btn_register_Click_1(object sender, System.EventArgs e)
        {
            if (SubjectRegister.IsUserNameUsed("admin") == false || SubjectRegister.IsUserNameUsed("security_officer") == false)//若数据库文件不存在或则管理员账号不存在,则创建新的文件或者管理员帐号并退出
            {
                if (SubjectRegister.IsUserNameUsed("admin") == false)
                {
                    MessageBox.Show(this, "未设置管理员账号,按确定设置管理员账号及密码", "设置管理员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text       = "设置管理员账号及密码";
                    register.getIsAdmin = true;
                    register.ShowDialog();
                    Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
                    return;
                }
                if (SubjectRegister.IsUserNameUsed("security_officer") == false)
                {
                    MessageBox.Show(this, "未设置安全员账号,按确定设置安全员员账号及密码", "设置安全员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置安全员账号及密码";
                    register.GetIsSecurityOfficer = true;
                    register.ShowDialog();
                    Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
                    return;
                }
            }
            else
            {
                SubjectRegister register = new SubjectRegister();
                register.Text    = "设置普通用户账号及密码";
                register.isAdmin = false;
                register.ShowDialog();
                Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
            }
        }
Esempio n. 4
0
        private void Login_Load(object sender, System.EventArgs e)
        {
            if (File.Exists("dac.accdb") == false || SubjectRegister.IsUserNameUsed("admin") == false||  SubjectRegister.IsUserNameUsed("security_officer") == false)//若数据库文件不存在或则管理员账号不存在,则创建新的文件或者管理员帐号并退出
            {
                if (File.Exists("dac.accdb") == false)
                {
                    CreatDb();
                }
                if (SubjectRegister.IsUserNameUsed("admin") == false)
                {
                    //设置管理员账号及密码
                    MessageBox.Show(this, "未设置管理员账号,按确定设置管理员账号及密码", "设置管理员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置管理员账号及密码";
                    register.getIsAdmin = true;
                    register.ShowDialog();
                    Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
                }
                if (SubjectRegister.IsUserNameUsed("security_officer") == false)
                {
                    //设置安全员账号及密码
                    MessageBox.Show(this, "未设置安全员账号,按确定设置安全员员账号及密码", "设置安全员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置安全员账号及密码";
                    register.GetIsSecurityOfficer = true;
                    register.ShowDialog();
                    Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
                }
            }
            Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
        }
Esempio n. 5
0
        private void btn_register_Click_1(object sender, System.EventArgs e)
        {
            if (SubjectRegister.IsUserNameUsed("admin") == false || SubjectRegister.IsUserNameUsed("security_officer")==false)//若数据库文件不存在或则管理员账号不存在,则创建新的文件或者管理员帐号并退出
            {
                if (SubjectRegister.IsUserNameUsed("admin") == false)
                {
                    MessageBox.Show(this, "未设置管理员账号,按确定设置管理员账号及密码", "设置管理员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置管理员账号及密码";
                    register.getIsAdmin = true;
                    register.ShowDialog();
                    Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
                    return;

                }
                if (SubjectRegister.IsUserNameUsed("security_officer") == false)
                {
                    MessageBox.Show(this, "未设置安全员账号,按确定设置安全员员账号及密码", "设置安全员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置安全员账号及密码";
                    register.GetIsSecurityOfficer = true;
                    register.ShowDialog();
                    Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
                    return;
                }
            }
            else
            {
                SubjectRegister register = new SubjectRegister();
                register.Text = "设置普通用户账号及密码";
                register.isAdmin = false;
                register.ShowDialog();
                Refresh_UserInfo();//将数据库中用户信息添加到用户列表中
            }
        }
Esempio n. 6
0
        private void 注册ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SubjectRegister.IsUserNameUsed("admin") == false || SubjectRegister.IsUserNameUsed("security_officer") == false)//若数据库文件不存在或则管理员账号不存在,则创建新的文件或者管理员帐号并退出
            {
                if (SubjectRegister.IsUserNameUsed("admin") == false)
                {
                    MessageBox.Show(this, "未设置管理员账号,按确定设置管理员账号及密码", "设置管理员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置管理员账号及密码";
                    register.getIsAdmin = true;
                    register.ShowDialog();

                    return;

                }
                if (SubjectRegister.IsUserNameUsed("security_officer") == false)
                {
                    MessageBox.Show(this, "未设置安全员账号,按确定设置安全员员账号及密码", "设置安全员账号及密码", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    SubjectRegister register = new SubjectRegister();
                    register.Text = "设置安全员账号及密码";
                    register.GetIsSecurityOfficer = true;
                    register.ShowDialog();
                    return;

                }

            }
            else
            {

                SubjectRegister register = new SubjectRegister();
                register.Text = "设置普通用户账号及密码";
                register.isAdmin = false;
                register.ShowDialog();

            }
        }
Esempio n. 7
0
        //登录
        private void btn_enter_Click(object sender, System.EventArgs e)
        {
            bool isLogin = false;

            if (SubjectRegister.IsUserNameUsed(userCombox.Text) == false)
            {
                MessageBox.Show(this, "数据库中找不到这样的账号", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (userCombox.Text.Length == 0 || pwd.Text.Length == 0)
            {
                MessageBox.Show(this, "账户名称及密码不能为空", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            OleDbConnection oleDB = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=dac.accdb");

            oleDB.Open();
            OleDbCommand conn = new OleDbCommand();

            conn.Connection  = oleDB;
            conn.CommandText = "select *  from  [主体信息表] where 主体名称=" + "'" + userCombox.Text.ToLower() + "'";
            OleDbDataReader dr = conn.ExecuteReader();

            if (dr.HasRows == true)
            {
                while (dr.Read())
                {
                    if (dr[1].ToString().CompareTo(pwd.Text.GetHashCode().ToString()) == 0)//找到相应的记录,置登录标志为真
                    {
                        isLogin = true;
                    }
                }
            }
            dr.Close();
            oleDB.Close();
            if (isLogin == false)
            {
                MessageBox.Show(this, "密码错误" + pwd.Text.GetHashCode().ToString(), "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else
            {
                MessageBox.Show(this, "登录成功,按确定进入", "登录成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            this.Visible = false;

            switch (this.userCombox.Text.ToLower())//选择不同的窗口
            {
            case "admin":
            {
                Admin a = new Admin();
                a.ShowDialog();
                break;
            }

            case "security_officer":
            {
                Security_Officer s = new Security_Officer();
                s.ShowDialog();
                break;
            }

            default:
            {
                CommonUser c = new CommonUser();
                c.GetUserName = this.userCombox.Text.ToLower();
                c.ShowDialog();
                break;
            }
            }
            this.Visible = true;
        }