Beispiel #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtPassword.Text.Trim() == "")
            {
                MessageBox.Show("密码不能为空!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (txtSurePwd.Text.Trim() == "")
            {
                MessageBox.Show("确认密码不能为空!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            try
            {
                // _currentUser.Usr_Password = txtPassword.Text.Trim();

                /* MD5 md5 = MD5.Create();
                 * byte[] bytePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(txtPassword.Text.Trim()));
                 * byte[] byteSurePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(txtSurePwd.Text.Trim()));
                 * string resultPwd = System.Text.UTF8Encoding.Unicode.GetString(bytePwd);
                 * string resultSurePwd = System.Text.UTF8Encoding.Unicode.GetString(byteSurePwd);
                 * if(resultPwd == resultSurePwd)
                 * {
                 *   _currentUser.Usr_Password = resultPwd;
                 * }
                 * else
                 * {
                 *   MessageBox.Show("密码与确认密码不相等!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                 *   return;
                 * }*/
                string pwd     = CHelperClass.UserMd5(txtPassword.Text.Trim());
                string surePwd = CHelperClass.UserMd5(txtSurePwd.Text.Trim());
                if (pwd == surePwd)
                {
                    _currentUser.Usr_Password = pwd;
                }
                else
                {
                    MessageBox.Show("密码与确认密码不相等!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                _currentUser.Usr_Name  = txtName.Text.Trim();
                _currentUser.Usr_Email = txtEmail.Text.Trim();
                _currentUser.Update();
                MessageBox.Show("修改成功!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("系统错误:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void mobjButtonLogon_Click(object sender, EventArgs e)
        {
            /* MD5 md5 = MD5.Create();
             * byte[] bytePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(this.mobjTextPassword.Text.Trim()));
             * string resultPwd = System.Text.UTF8Encoding.Unicode.GetString(bytePwd);
             */
            string resultPwd = CHelperClass.UserMd5(this.mobjTextPassword.Text.Trim());

            if (mobjCheckSavePassword.Checked)
            {
                Context.Cookies["Username"] = this.mobjTextUsername.Text;
                Context.Cookies["Password"] = this.mobjTextPassword.Text;

                //Context.Cookies["Password"] = this.mobjTextPassword.Text;
                //Context.Cookies["Lang"] = this.mobjComboLanguage.SelectedIndex.ToString();
            }
            else
            {
                Context.Cookies["Username"] = "";
                Context.Cookies["Password"] = "";
                //Context.Cookies["Lang"] = "0";
            }

            try
            {
                CUserEntity user = new CUserEntity(MidLayerSettings.ConnectionString);
                user = user.Login(mobjTextUsername.Text, resultPwd);
                Context.Session["CurrentUser"] = user;
                //  Context.CurrentUICulture = ((LanguageOption)mobjComboLanguage.SelectedItem).Culture;
                mobjLabelMessage.Text      = "";
                Context.Session.IsLoggedOn = true;
            }
            catch (Exception ex)
            {
                mobjLabelMessage.Text = "Invalid username or password.";
                MessageBox.Show("µÇ¼ʧ°Ü£º" + ex.ToString(), "Îĵµ¹ÜÀíϵͳ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Context.Session.IsLoggedOn = false;
            }

            /*
             *          if(this.mobjTextUsername.Text=="webgui" && this.mobjTextPassword.Text=="webgui")
             *          {
             *                  Context.Session.IsLoggedOn = true;
             *                  Context.CurrentUICulture = ((LanguageOption)mobjComboLanguage.SelectedItem).Culture;
             *                  mobjLabelMessage.Text="";
             *          }
             *          else
             *          {
             *                  mobjLabelMessage.Text = "Invalid username or password.";
             *                  Context.Session.IsLoggedOn = false;
             *          }
             */
        }
Beispiel #3
0
        private void AddUser_Closed(object sender, EventArgs e)
        {
            UserForm userForm = (UserForm)sender;

            if (userForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                CUserEntity newUser = new CUserEntity(MidLayerSettings.ConnectionString);
                newUser.Usr_Member = userForm.Member;
                // newUser.Usr_Password = userForm.Password;

                /*MD5 md5 = MD5.Create();
                 * byte[] bytePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(userForm.Password));
                 * byte[] byteSurePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(userForm.Surepwd));
                 * string resultPwd = System.Text.UTF8Encoding.Unicode.GetString(bytePwd);
                 * string resultSurePwd = System.Text.UTF8Encoding.Unicode.GetString(byteSurePwd);
                 * if (resultPwd == resultSurePwd)
                 * {
                 *  newUser.Usr_Password = resultPwd;
                 * }
                 * else
                 * {
                 *  throw new Exception("密码与确认密码不相等!");
                 * }*/
                string pwd     = CHelperClass.UserMd5(userForm.Password);
                string surePwd = CHelperClass.UserMd5(userForm.Surepwd);
                if (pwd == surePwd)
                {
                    newUser.Usr_Password = pwd;
                }
                else
                {
                    MessageBox.Show("密码与确认密码不相等!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                newUser.Usr_Name     = userForm.UserName;
                newUser.Usr_Email    = userForm.Email;
                newUser.Usr_Organize = _currentUser.Usr_Organize;
                _currentUser.CreateNormalUser(newUser);
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建用户失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #4
0
        private void ModifyUser_Closed(object sender, EventArgs e)
        {
            UserForm userForm = (UserForm)sender;

            if (userForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                CUserEntity user = new CUserEntity(_currentUser.ConnString).Load((int)userListView.SelectedItems[0].Tag);
                user.Usr_Member = userForm.Member;
                //user.Usr_Password = userForm.Password;

                /* MD5 md5 = MD5.Create();
                 * byte[] bytePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(userForm.Password));
                 * byte[] byteSurePwd = md5.ComputeHash(Encoding.Unicode.GetBytes(userForm.Surepwd));
                 * string resultPwd = System.Text.UTF8Encoding.Unicode.GetString(bytePwd);
                 * string resultSurePwd = System.Text.UTF8Encoding.Unicode.GetString(byteSurePwd);
                 * if (resultPwd == resultSurePwd)
                 * {
                 *   user.Usr_Password = resultPwd;
                 * }
                 * else
                 * {
                 *   throw new Exception("密码与确认密码不相等!");
                 * }*/
                string pwd     = CHelperClass.UserMd5(userForm.Password);
                string surePwd = CHelperClass.UserMd5(userForm.Surepwd);
                if (pwd == surePwd)
                {
                    user.Usr_Password = pwd;
                }
                else
                {
                    throw new Exception("密码与确认密码不相等!");
                }

                user.Usr_Name  = userForm.UserName;
                user.Usr_Email = userForm.Email;
                _currentUser.ModifyUser(user);
                this.LoadUsers();
            }
            catch (Exception ex)
            {
                MessageBox.Show("修改用户失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        private void AddUser_Closed(object sender, EventArgs e)
        {
            UserForm userForm = (UserForm)sender;

            if (userForm.DialogResult != DialogResult.OK)
            {
                return;
            }

            try
            {
                CUserEntity newUser = new CUserEntity(_currentUser.ConnString);
                newUser.Usr_Member = userForm.Member;
                // newUser.Usr_Password = userForm.Password;

                string pwd     = CHelperClass.UserMd5(userForm.Password);
                string surePwd = CHelperClass.UserMd5(userForm.Surepwd);
                if (pwd == surePwd)
                {
                    newUser.Usr_Password = pwd;
                }
                else
                {
                    throw new Exception("密码与确认密码不相等!");
                }

                newUser.Usr_Name     = userForm.UserName;
                newUser.Usr_Email    = userForm.Email;
                newUser.Usr_Organize = _currentUser.Usr_Organize;
                if (userForm.UserType == (int)USERTYPE.ORGANIZEADMIN)
                {
                    _currentUser.CreateAdminlUser(newUser);
                }
                else
                {
                    _currentUser.CreateNormalUser(newUser);
                }
                this.LoadUsers();
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建用户失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #6
0
        private void btnInstall_Click(object sender, EventArgs e)
        {
            if (txtServer.Text == "" || txtUserId.Text == "" || txtPassword.Text == "" || txtInitialCatalog.Text == "" || txtPath.Text == "")
            {
                MessageBox.Show("数据库配置有未填写的项目!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            if (txtMember.Text == "")
            {
                MessageBox.Show("管理员账号不能为空!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            if (txtMemberPwd.Text == "" || txtSurePwd.Text == "")
            {
                MessageBox.Show("管理员密码或确认密码不能为空!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }

            _member = txtMember.Text;
            if (txtMemberPwd.Text != txtSurePwd.Text)
            {
                MessageBox.Show("管理员密码错误!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            _memberPwd   = CHelperClass.UserMd5(this.txtMemberPwd.Text);
            _memberName  = txtMemberName.Text;
            _memberEmail = txtEmail.Text;

            _serverName     = txtServer.Text;
            _userId         = txtUserId.Text;
            _password       = txtPassword.Text;
            _initialCatalog = txtInitialCatalog.Text;
            _orgName        = "主目录";// txtOrgName.Text;
            string pt = txtPath.Text;

            if (pt[2].ToString() == "/")
            {
                MessageBox.Show("文件路径格式不正确!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            else if (pt[pt.Length - 1].ToString() != "\\")
            {
                pt += "\\";
            }
            _path = pt;

            if (txtSysPwd.Text == "" || txtSysSurePwd.Text == "")
            {
                MessageBox.Show("本机管理员密码不能为空!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            if (txtSysPwd.Text != txtSysSurePwd.Text)
            {
                MessageBox.Show("本机管理员密码不正确!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
            _systemAdmin = txtSysAdmin.Text;
            _systemPwd   = txtSysPwd.Text;

            try
            {
                CreateDataBase();
                ChangeWebConfig();
                CreateTable(_connString);
                CreateOrganize(_orgName);
                CreateAdminlUser();
                CreateVisualWebExtensions(txtVirtualDir.Text);

                DialogResult result = MessageBox.Show("成功安装文档管理系统!", "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (result != DialogResult.OK)
                {
                    return;
                }
                //Application.Exit();
            }
            catch (Exception ex)
            {
                MessageBox.Show("安装失败:" + ex.Message, "文档管理系统", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }