示例#1
0
        public string UpdatePwd(string uname, string oldPwd, string newPwd)
        {
            try
            {
                string encodePwd = CEncoder.Encode(oldPwd);
                using (var sql = SugarDbContext.GetInstance())
                {
                    var id = sql.Queryable <Opers>().Where(s => s.userName == uname && s.password == encodePwd)
                             .Select(s => s.Id).First();
                    if (id == 0)
                    {
                        return("原始密码错误!!!");
                    }
                    string newEncodePwd = CEncoder.Encode(newPwd);

                    sql.Updateable <Opers>().UpdateColumns(s => new Opers()
                    {
                        password = newEncodePwd
                    })
                    .Where(s => s.Id == id).ExecuteCommand();
                }
            }
            catch (Exception ex)
            {
                LogNHelper.Exception(ex);
                return("密码修改失败!!!");
            }

            return(string.Empty);
        }
示例#2
0
 public override void DoCancel(IButtonInfo sender)
 {
     if (Msg.AskQuestion("要取消修改吗?"))
     {
         _DataProxy.DataBinder.Rows[0][tb_sys_DbLink.FNumber] = sHead + txtNum.Text;
         _DataProxy.DataBinder.Rows[0][tb_sys_DbLink.FPwd]    = CEncoder.Encode(txtPwd.Text);
         base.DoCancel(sender);
     }
 }
        /// <summary>
        /// 保存登录信息
        /// </summary>
        private void SaveLoginInfo()
        {
            string  cfgINI = AppDomain.CurrentDomain.BaseDirectory + SerivceFiguration.INI_CFG;
            IniFile ini    = new IniFile(cfgINI);

            ini.IniWriteValue("Login", "User", UserName);
            ini.IniWriteValue("Login", "Password", CEncoder.Encode(Password));
            ini.IniWriteValue("Login", "SaveInfo", UserChecked ? "Y" : "N");
        }
示例#4
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                this.SetButtonEnable(false);
                this.Update();//必须
                this.ShowLoginInfo("正在验证用户名及密码");

                bllUser.ValidateLogin(txtUser.Text, txtPwd.Text);//检查登录信息

                string    userID    = txtUser.Text;
                string    password  = CEncoder.Encode(txtPwd.Text);    /*常规加密*/
                string    dataSetID = cmbDataset.EditValue.ToString(); //帐套编号
                string    dataSetDB = GetDataSetDBName();
                string    DbType    = GetDataDbType();
                string    dbName    = GetDBName();
                LoginUser loginUser = new LoginUser(userID, password, dataSetID, dataSetDB);
                loginUser.DbType = DbType;
                loginUser.DBName = dbName;

                Loginer.CurrentUser.DbType = DbType;
                Loginer.CurrentUser.DBName = dbName;

                if (_CurrentAuthorization.Login(loginUser)) //调用登录策略
                {
                    //if (chkSaveLoginInfo.Checked)
                    this.SaveLoginInfo();                                 //跟据选项保存登录信息
                    SystemAuthentication.Current = _CurrentAuthorization; //授权成功, 保存当前授权模式
                    Program.MainForm             = new frmMain();         //登录成功创建主窗体
                    Program.MainForm.InitUserInterface(new LoadStatus(lblLoadingInfo));

                    this.DialogResult = DialogResult.OK; //成功
                    this.Close();                        //关闭登陆窗体
                }
                else
                {
                    this.ShowLoginInfo("登录失败,请检查用户名和密码!");
                    Msg.Warning("登录失败,请检查用户名和密码!");
                }
            }
            catch (CustomException ex)
            {
                this.SetButtonEnable(true);
                this.ShowLoginInfo(ex.Message);
                Msg.Warning(ex.Message);
            }
            catch (Exception ex)
            {
                this.SetButtonEnable(true);
                this.ShowLoginInfo("登录失败,请检查用户名和密码!" + ex.Message);
                Msg.Warning("登录失败,请检查用户名和密码!" + ex.Message);
            }

            this.Cursor = Cursors.Default;
        }
示例#5
0
        private void SaveLoginInfo()
        {
            //存在用户配置文件,自动加载登录信息
            string cfgINI = Application.StartupPath + BridgeFactory.INI_CFG;

            IniFile ini = new IniFile(cfgINI);

            ini.IniWriteValue("LoginWindow", "User", txtUser.Text);
            ini.IniWriteValue("LoginWindow", "DataSetID", txtDataset.EditValue.ToString());
            ini.IniWriteValue("LoginWindow", "Password", CEncoder.Encode(txtPwd.Text));
            ini.IniWriteValue("LoginWindow", "SaveLogin", chkSaveLoginInfo.Checked ? "Y" : "N");
        }
示例#6
0
        /// <summary>
        /// 将配置写入INI文件
        /// </summary>
        public void Write()
        {
            IniFile cfg = new IniFile(_iniFile);

            if (cfg != null)
            {
                cfg.IniWriteValue("SQL Configuration", "SqlServer", _ServerName);
                cfg.IniWriteValue("SQL Configuration", "Database", _InitialCatalog);
                cfg.IniWriteValue("SQL Configuration", "SqlUser", _UserName);
                cfg.IniWriteValue("SQL Configuration", "SqlPwd", CEncoder.Encode(_Password)); //加密
            }
        }
示例#7
0
        /// <summary>
        /// 写入配置
        /// </summary>
        public void Write()
        {
            RegistryKey key = Registry.LocalMachine.CreateSubKey(_keyPath);

            if (key != null)
            {
                key.SetValue("SqlServer", _ServerName);
                key.SetValue("SqlDatabase", _InitialCatalog);
                key.SetValue("SqlUser", _UserName);
                key.SetValue("SqlPwd", CEncoder.Encode(_Password));
                key.Close();
            }
        }
示例#8
0
        /// <summary>
        /// 保存登录信息
        /// </summary>
        private void SaveLoginInfo(string name, string pwd)
        {
            string strPath = AppDomain.CurrentDomain.BaseDirectory + "config\\";
            string cfgINI  = AppDomain.CurrentDomain.BaseDirectory + SerivceFiguration.INI_CFG;

            if (!Directory.Exists(strPath))
            {
                Directory.CreateDirectory(strPath);
            }
            IniFile ini = new IniFile(cfgINI);

            ini.IniWriteValue("Login", "User", name);
            ini.IniWriteValue("Login", "Password", CEncoder.Encode(pwd));
        }
示例#9
0
        private void sbtnOK_Click(object sender, EventArgs e)
        {
            string sUserID, sPwd, sBookID = "屠宰管理", sBooksName = "";

            sUserID = tUserID.Text;
            // sUserName = tUserName.Text;
            sPwd = tPwd.Text;

            if (String.IsNullOrEmpty(sUserID))
            {
                YIEternalMIS.Common.Msg.ShowInformation("请输入登录用户名!!!");
                tUserID.Focus();
            }

            if (String.IsNullOrEmpty(sPwd))
            {
                YIEternalMIS.Common.Msg.ShowInformation("请输入登录密码!!!");
                tPwd.Focus();
            }


            IWriteSQLConfigValue cfgNormal = new INIFileWriter(Application.StartupPath + SqlConfiguration.INI_CFG_PATH);

            //设置配置信息
            SqlConfiguration.SetSQLConfig(cfgNormal);
            sPwd = CEncoder.Encode(sPwd.Trim());
            var user = _loginApp.Login(sUserID.Trim(), sPwd);

            if (user == null)
            {
                Msg.ShowInformation("您输入的用户名和密码不匹配!!!");
                return;
            }
            //登录成功
            Loginer.CurrentUser = user;
            //初始化导航条
            MenuHelper.InitMenu();
            DialogResult = System.Windows.Forms.DialogResult.OK;
            //登录策略
            //Business.LoginAuthorization login = new Business.LoginAuthorization();
            //SystemAuthentication.Current = login;
            YIEternalMIS.Common.SystemConfig.CurrentConfig.LoginSave     = true;
            YIEternalMIS.Common.SystemConfig.CurrentConfig.LastLoginPWD  = sPwd;
            YIEternalMIS.Common.SystemConfig.CurrentConfig.LastLoginUser = sUserID;
            YIEternalMIS.Common.SystemConfig.WriteSettings(YIEternalMIS.Common.SystemConfig.CurrentConfig);
            this.Hide();
            this.Close();
        }
        /// <summary>
        /// 编辑用户
        /// </summary>
        private void EditUser()
        {
            try
            {
                user.Password = CEncoder.Encode(user.Password);
                UserInfoDal.Modify(user);
                App.Current.Properties["User"] = user;

                IsPopupOpen = false;
            }
            catch (Exception ex)
            {
                ErrorDialogViewModel.getInstance().show(ex);
            }

        }
示例#11
0
        /// <summary>
        /// 保存登录信息
        /// </summary>
        private void SaveLoginInfo()
        {
            string        cfgINI = AppDomain.CurrentDomain.BaseDirectory + LocalConfiguration.INI_CFG;
            IniFileHelper ini    = new IniFileHelper(cfgINI);

            ini.IniWriteValue("Login", "Account", Account);
            if (UserChecked)
            {
                ini.IniWriteValue("Login", "Password", CEncoder.Encode(Password));
                ini.IniWriteValue("Login", "SaveInfo", "Y");
            }
            else
            {
                ini.IniWriteValue("Login", "Password", string.Empty);
                ini.IniWriteValue("Login", "SaveInfo", "N");
            }
        }
示例#12
0
        public override async void Edit <T>(T CurrentUser)
        {
            if (!this.GetButtonAuth(Authority.EDIT))
            {
                return;
            }

            if (CurrentUser != null)
            {
                try
                {
                    UserDialogViewModel view = new UserDialogViewModel();
                    view.Title = Configuration.USER_EDIT_TITLE;
                    var request = await ZFSBridge.BridgeFactory.BridgeManager.GetUserManager().GetModelByAccount((CurrentUser as tb_User).Account);

                    view.User          = request.Results;
                    view.User.Password = CEncoder.Decode(view.User.Password);/*解密*/
                    var dialog = ServiceProvider.Instance.Get <IModelDialog>("UserViewDlg");
                    dialog.BindViewModel(view);
                    var taskResult = await dialog.ShowDialog(
                        null,
                        view.ExtendedClosingEventHandler);

                    if (taskResult)
                    {
                        ZFSInterface.User.IUser userSerivce = await Task.Run(() => ZFSBridge.BridgeFactory.BridgeManager.GetUserManager());

                        view.User.Password = CEncoder.Encode(view.User.Password);/*加密*/
                        var req = await userSerivce.UpdateEntity(view.User);

                        if (req.Success)
                        {
                            var mod = GridModelList.FirstOrDefault(t => t.isid.Equals(view.User.isid));
                            GridModelList.Remove(mod);
                            GridModelList.Add(view.User);
                            Msg.Info(Configuration.ADD_MSG);
                        }
                    }
                }
                catch (Exception ex)
                { Msg.Error(ex.Message, false); }
            }
        }
示例#13
0
        public override void DoSave(IButtonInfo sender)
        {
            try
            {
                UpdateLastControl();

                //保存數據前如修改了原始數據,必需復製數據用于保存.
                _DataProxy.DataBinder.AcceptChanges();
                DataTable forSave = _DataProxy.DataBinder.Copy();
                if (!ValidatingData(forSave.Rows[0]))
                {
                    return;
                }

                //新增用户时可设置密码,修改状态不支持改密码。
                if (UpdateType.Add == _UpdateType)
                {
                    forSave.Rows[0][tb_sys_User.FPassword] = CEncoder.Encode(txtPassword2.Text); //可以选择MD5加密

                    forSave.Rows[0][tb_sys_User.FID] = BridgeFactory.CreateCommonServiceBridge().GetTableID(tb_sys_User.__TableName, tb_sys_User.__KeyName);
                }

                bool ret = _DataProxy.Update(forSave, _UpdateType);
                if (ret)
                {
                    UpdateSummaryRow(forSave.Rows[0]); //刷新表格内的数据.
                    _DataProxy.SummaryTable.AcceptChanges();
                    string sFdes = (_UpdateType == UpdateType.Add ? "新增" : "修改") + "用户" + forSave.Rows[0][tb_sys_User.FUserName] + "(" + forSave.Rows[0][tb_sys_User.FAccount] + ")";
                    bllComDataBaseTool.WriteLogOp(_FunctionID, "0", sFdes);
                    base.DoSave(sender);
                    Msg.ShowInformation("保存成功!");
                }
                else
                {
                    Msg.Warning("保存失败!");
                }
            }
            catch (Exception ex)
            {
                Msg.ShowException(ex);
            }
        }
示例#14
0
        private void SaveLoginInfo()
        {
            //存在用户配置文件,自动加载登录信息
            string cfgINI = Application.StartupPath + BridgeFactory.INI_CFG;

            IniFile ini = new IniFile(cfgINI);

            ini.IniWriteValue("LoginWindow", "SaveLogin", chkSaveLoginInfo.Checked ? "Y" : "N");
            if (chkSaveLoginInfo.Checked)
            {
                ini.IniWriteValue("LoginWindow", "OrganizationID", cmbOrg.EditValue.ToString());
                ini.IniWriteValue("LoginWindow", "DataSetID", cmbDataset.EditValue.ToString());

                if (rdUser.Checked) //用户名登录
                {
                    ini.IniWriteValue("LoginWindow", "User", txtUser.Text);
                    ini.IniWriteValue("LoginWindow", "Password", CEncoder.Encode(txtPwd.Text));
                    ini.IniWriteValue("LoginWindow", "LoginMode", "0");
                }
                else //刷卡登录
                {
                    ini.IniWriteValue("LoginWindow", "User", "");
                    ini.IniWriteValue("LoginWindow", "Password", "");
                    ini.IniWriteValue("LoginWindow", "LoginMode", "1");
                }
            }
            else
            {
                ini.IniWriteValue("LoginWindow", "OrganizationID", "-1");
                ini.IniWriteValue("LoginWindow", "DataSetID", "-1");
                ini.IniWriteValue("LoginWindow", "User", "");
                ini.IniWriteValue("LoginWindow", "Password", "");
                if (rdUser.Checked) //用户名登录
                {
                    ini.IniWriteValue("LoginWindow", "LoginMode", "0");
                }
                else //刷卡登录
                {
                    ini.IniWriteValue("LoginWindow", "LoginMode", "1");
                }
            }
        }
        public async Task <IActionResult> AddUser([FromBody] UserAddViewModel viewModel)
        {
            if (viewModel == null)
            {
                return(Ok(new BaseResponse()
                {
                    success = false, message = "提交的数据有误!"
                }));
            }

            try
            {
                var newUser = mapper.Map <UserAddViewModel, User>(viewModel); //Map转换
                newUser.Password      = CEncoder.Encode(newUser.Password);
                newUser.CreateTime    = DateTime.Now;
                newUser.LastLoginTime = DateTime.Now;
                newUser.LastLogouTime = DateTime.Now;
                repository.AddUserAsync(newUser);

                if (!await work.SaveAsync())
                {
                    return(Ok(new BaseResponse()
                    {
                        success = false, message = "save error!"
                    }));
                }
                return(Ok(new BaseResponse()
                {
                    success = true
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new BaseResponse()
                {
                    success = false, message = ex.Message
                }));
            }
        }
示例#16
0
        public override void DoSave(IButtonInfo sender)
        {
            try
            {
                UpdateLastControl();

                //保存數據前如修改了原始數據,必需復製數據用于保存.
                _DataProxy.DataBinder.AcceptChanges();
                DataTable forSave = _DataProxy.DataBinder.Copy();
                if (!ValidatingData(forSave.Rows[0]))
                {
                    return;
                }

                //新增用户时可设置密码,修改状态不支持改密码。
                if (UpdateType.Add == _UpdateType)
                {
                    forSave.Rows[0][TUser.Password] = CEncoder.Encode(txtPassword2.Text); //可以选择MD5加密
                }

                bool ret = _DataProxy.Update(forSave, _UpdateType);
                if (ret)
                {
                    UpdateSummaryRow(forSave.Rows[0]); //刷新表格内的数据.
                    _DataProxy.SummaryTable.AcceptChanges();
                    base.DoSave(sender);
                    Msg.ShowInformation("保存成功!");
                }
                else
                {
                    Msg.Warning("保存失败!");
                }
            }
            catch (Exception ex)
            {
                Msg.ShowException(ex);
            }
        }
示例#17
0
        public override async void Add <T>(T obj)
        {
            UserDialogViewModel viewModel = new UserDialogViewModel();

            viewModel.Title = Configuration.USER_ADD_TITLE;
            var dialog = ServiceProvider.Instance.Get <IModelDialog>("UserViewDlg");

            dialog.BindViewModel(viewModel);
            var taskResult = await dialog.ShowDialog(
                null,
                viewModel.ExtendedClosingEventHandler);

            if (taskResult)
            {
                try
                {
                    ZFSInterface.User.IUser userSerivce = ZFSBridge.BridgeFactory.BridgeManager.GetUserManager();
                    viewModel.User.Password     = CEncoder.Encode(viewModel.User.Password);/*加密*/
                    viewModel.User.IsLocked     = 0;
                    viewModel.User.FlagAdmin    = "0";
                    viewModel.User.FlagOnline   = "0";
                    viewModel.User.LoginCounter = 0;
                    viewModel.User.CreateTime   = DateTime.Now;

                    var req = await userSerivce.AddEntity(viewModel.User);

                    if (req.Success)
                    {
                        GridModelList.Add(viewModel.User);
                        Msg.Info(Configuration.ADD_MSG);
                    }
                }
                catch (Exception ex)
                {
                    Msg.Error(ex.Message, false);
                }
            }
        }
示例#18
0
        void editpwd()
        {
            if (!InitValidationRules())
            {
                return;
            }

            string msg = _loginApp.UpdatePwd(Loginer.CurrentUser.Account.Trim(), told.Text.Trim(), tnew.Text.Trim());

            if (string.IsNullOrEmpty(msg))
            {
                if (SystemConfig.CurrentConfig.LoginSave)
                {
                    Common.SystemConfig.CurrentConfig.LastLoginPWD = CEncoder.Encode(tnew.Text.Trim());
                    Common.SystemConfig.WriteSettings(Common.SystemConfig.CurrentConfig);
                }
                Msg.ShowInformation("密码修改成功");
            }
            else
            {
                Msg.ShowError(msg);
            }
        }
示例#19
0
        /// <summary>
        /// 登录系统
        /// </summary>
        private void Login()
        {
            IsCancel = false;
            if (string.IsNullOrWhiteSpace(Account))
            {
                Report = "请输入账号";
                return;
            }
            if (string.IsNullOrWhiteSpace(Password))
            {
                Report = "请输入密码";
                return;
            }
            try
            {
                bool canLogin = false;
                Task task     = new Task(() =>
                {
                    //UserInfo u = new UserInfo();
                    //u.ID = Guid.NewGuid();
                    //u.Account = "admin";
                    //u.UserName = "******";
                    //u.Password = CEncoder.Encode("123456");
                    //u.CreateTime = DateTime.Now;
                    //u.IsAdmin = "1";
                    //UserInfoDal.Add(u);

                    App.Current.Dispatcher.Invoke((Action)(() =>
                    {
                        Report = "正在验证登录 . . .";
                    }));
                    UserInfo user = new UserInfo();
                    user          = UserInfoDal.GetModel(u => u.Account.Equals(Account));
                    if (user == null)
                    {
                        App.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            Report = "账号不存在,请确认";
                        }));
                        return;
                    }

                    user = UserInfoDal.Login(Account, CEncoder.Encode(Password));
                    if (user == null)
                    {
                        App.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            Report = "账号或密码错误,请确认";
                        }));
                    }
                    else
                    {
                        // 保存登录信息
                        try
                        {
                            SaveLoginInfo();
                        }
                        catch (Exception ex)
                        {
                            App.Current.Dispatcher.Invoke((Action)(() =>
                            {
                                Report = ex.Message;
                            }));
                            return;
                        }

                        App.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            Report = "初始化首页 . . .";
                        }));

                        App.Current.Properties["User"] = user;
                        canLogin = true;
                        App.Current.Dispatcher.Invoke((Action)(() =>
                        {
                            Application.Current.Windows[0].Visibility = Visibility.Hidden;
                        }));
                    }
                });
                task.Start();
                task.ContinueWith(t =>
                {
                    App.Current.Dispatcher.Invoke((Action)(() =>
                    {
                        if (canLogin)
                        {
                            RegionManager.RequestNavigate("MainRegion", "MainPage", NavigationComplete);
                        }
                    }));
                });
            }
            catch (Exception ex)
            {
                App.Current.Dispatcher.Invoke((Action)(() =>
                {
                    Report = ex.Message;
                }));
            }
            finally
            {
            }
        }
示例#20
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                this.SetButtonEnable(false);
                this.Update();//必须
                this.ShowLoginInfo("正在验证用户名及密码");

                bllUser.ValidateLogin(txtUser.Text, txtPwd.Text);//检查登录信息

                string userID    = txtUser.Text;
                string password  = CEncoder.Encode(txtPwd.Text);    /*常规加密*/
                string dataSetID = txtDataset.EditValue.ToString(); //帐套编号
                string dataSetDB = GetDataSetDBName();

                LoginUser loginUser = new LoginUser(userID, password, dataSetID, dataSetDB);

                if (_CurrentAuthorization.Login(loginUser)) //调用登录策略
                {
                    if (chkSaveLoginInfo.Checked)
                    {
                        this.SaveLoginInfo();                             //跟据选项保存登录信息
                    }
                    SystemAuthentication.Current = _CurrentAuthorization; //授权成功, 保存当前授权模式
                    frmBoot form1 = new frmBoot();
                    form1.StartPosition = FormStartPosition.CenterScreen;
                    form1.Show();
                    Application.DoEvents();
                    Program.MainForm = new frmMain();    //登录成功创建主窗体
                    Program.MainForm.InitUserInterface(new LoadStatus(form1.lblLoadingInfo, form1.progressBarControl1));
                    this.DialogResult = DialogResult.OK; //成功
                    this.Hide();
                    this.Close();                        //关闭登陆窗体

                    while (form1.Opacity > 0)
                    {
                        form1.Opacity = form1.Opacity - 0.05;
                        Application.DoEvents();
                        Thread.Sleep(100);
                    }
                    form1.Close();
                }
                else
                {
                    this.ShowLoginInfo("登录失败,请检查用户名和密码!");
                    Msg.Warning("登录失败,请检查用户名和密码!");
                }
            }
            catch (CustomException ex)
            {
                this.SetButtonEnable(true);
                this.ShowLoginInfo(ex.Message);
                Msg.Warning(ex.Message);
            }
            catch (Exception ex)
            {
                this.SetButtonEnable(true);
                this.ShowLoginInfo("登录失败,请检查用户名和密码!");
                Msg.Warning("登录失败,请检查用户名和密码!");
            }

            this.Cursor = Cursors.Default;
        }
示例#21
0
        public override void DoSave(IButtonInfo sender)
        {
            try
            {
                if (txtNum.Text == string.Empty)
                {
                    Msg.ShowError("编号不能为空!");
                    txtNum.Focus();
                    return;
                }
                if (txtName.Text == string.Empty)
                {
                    Msg.ShowError("名称不能为空!");
                    txtName.Focus();
                    return;
                }

                if (_UpdateType == UpdateType.Add)
                {
                    if (bllComDataBaseTool.GetTableFieldValue(tb_sys_DbLink.__TableName, tb_sys_DbLink.__KeyName, tb_sys_DbLink.FNumber + "='" + sHead + txtNum.Text + "'") != string.Empty)
                    {
                        Msg.ShowError("编号不能相同,请重新输入编号!");
                        txtNum.Focus();
                        return;
                    }
                }

                UpdateLastControl();

                //保存數據前如修改了原始數據,必需復製數據用于保存.
                _DataProxy.DataBinder.AcceptChanges();
                DataTable forSave = _DataProxy.DataBinder.Copy();
                string    sType   = txtDbType.GetColumnValue("Sign").ToString();
                if (!bllComDataBaseTool.TestConnection(sType, txtServer.Text, lookUpDataBase.Text, txtUserName.Text, txtPwd.Text))
                {
                    Msg.ShowError("测试没有通过,不能保存!");
                    return;
                }
                //新增用户时可设置密码,修改状态不支持改密码。
                string sSaveDesc = "";
                forSave.Rows[0][tb_sys_DbLink.FNumber] = sHead + txtNum.Text;
                forSave.Rows[0][tb_sys_DbLink.FPwd]    = CEncoder.Encode(txtPwd.Text); //可以选择MD5加密
                forSave.Rows[0][tb_sys_DbLink.FUserID] = Loginer.CurrentUser.Fid;
                if (_UpdateType == UpdateType.Add)
                {
                    forSave.Rows[0][tb_sys_DbLink.__KeyName] = bllComDataBaseTool.GetTableID(tb_sys_DbLink.__TableName, tb_sys_DbLink.__KeyName);
                    sSaveDesc = "新增";
                }
                else
                {
                    sSaveDesc = "修改";
                }
                sSaveDesc += forSave.Rows[0][tb_sys_DbLink.FName] + "(" + forSave.Rows[0][tb_sys_DbLink.FNumber] + ")成功";
                bool ret = _DataProxy.Update(forSave, _UpdateType);
                if (ret)
                {
                    UpdateSummaryRow(forSave.Rows[0]); //刷新表格内的数据.
                    _DataProxy.DataBinder.Rows[0][tb_sys_DbLink.FNumber] = sHead + txtNum.Text;
                    _DataProxy.DataBinder.Rows[0][tb_sys_DbLink.FPwd]    = CEncoder.Encode(txtPwd.Text);
                    _DataProxy.SummaryTable.AcceptChanges();
                    base.DoSave(sender);
                    bllComDataBaseTool.WriteLogOp(_FunctionID, "0", sSaveDesc); //日志
                    Msg.ShowInformation("保存成功!");
                }
                else
                {
                    Msg.Warning("保存失败!");
                }
            }
            catch (Exception ex)
            {
                Msg.ShowException(ex);
            }
        }
示例#22
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (txtAccount.Text.Trim() == string.Empty)
            {
                Msg.Warning("请输入登录帐号!");
                txtAccount.Focus();
                return;
            }

            if (txtOldPwd.EditValue == null || txtOldPwd.EditValue.ToString().Trim() == string.Empty)
            {
                Msg.Warning("请输入旧密码!");
                txtOldPwd.Focus();
                return;
            }

            //取修改密码用户的资料
            DataTable dt = new bllUser().GetUserDirect(txtAccount.Text, _user.DataSetDBName);

            if (dt.Rows.Count > 0)
            {
                //管理员修改用户密码不需要验证旧密码
                if (false == Loginer.CurrentUser.IsAdmin())
                {
                    string pwd = CEncoder.Decode(dt.Rows[0][TUser.Password].ToString());
                    if (pwd != txtOldPwd.Text.Trim())
                    {
                        Msg.Warning("所输入旧密码不正确!");
                        txtOldPwd.Focus();
                        return;
                    }
                }
            }
            else
            {
                Msg.Warning("登录帐号'" + txtAccount.Text + "'不存在!");
                return;
            }

            if (txtPwdF.EditValue == null || txtPwdF.EditValue.ToString().Trim() == string.Empty)
            {
                Msg.Warning("请输入新密码!");
                txtPwdF.Focus();
                return;
            }

            if (txtPwdF.Text.Trim().Length < 3)
            {
                Msg.Warning("密码长度必须大于2位!");
                txtPwdF.Focus();
                return;
            }

            if (txtPwdS.EditValue == null || txtPwdS.EditValue.ToString().Trim() == string.Empty)
            {
                Msg.Warning("请确认新密码!");
                txtPwdS.Focus();
                return;
            }

            if (txtPwdF.EditValue.ToString() != txtPwdS.EditValue.ToString())
            {
                Msg.Warning("两次新密码不相同!");
                txtPwdF.Focus();
                return;
            }

            if (Msg.AskQuestion("要修改密码?"))
            {
                bool success = new bllUser().ModifyPasswordDirect(txtAccount.Text, CEncoder.Encode(txtPwdF.Text), _user.DataSetDBName);
                if (success)
                {
                    _user.Password = txtPwdF.Text;
                    Msg.ShowInformation("修改成功!");
                    this.Close();
                }
                else
                {
                    Msg.Warning("修改出错!");
                }
            }
        }
示例#23
0
        private void VerifyUserByCard()
        {
            try
            {
                timer1.Stop();
                if (string.IsNullOrEmpty(txtCardNo.Text))
                {
                    txtCardNo.Text = "";
                    txtCardNo.Focus();
                    lblInfo.Text = "请刷卡。。。";
                    timer1.Start();
                    return;
                }
                this.Cursor = Cursors.WaitCursor;
                this.SetButtonEnable(false);
                this.Update();//必须
                this.ShowLoginInfo("正在验证卡号");

                string    cardNo    = CEncoder.Encode(txtCardNo.Text); /*常规加密*/
                string    dataSetID = cmbDataset.EditValue.ToString(); //帐套编号
                string    dataSetDB = GetDataSetDBName();
                string    DbType    = GetDataDbType();
                string    dbName    = GetDBName();
                LoginUser loginUser = new LoginUser(cardNo, dataSetID, dataSetDB);
                loginUser.DbType = DbType;
                loginUser.DBName = dbName;

                Loginer.CurrentUser.DbType = DbType;
                Loginer.CurrentUser.DBName = dbName;

                if (_CurrentAuthorization.LoginByCard(loginUser)) //调用登录策略
                {
                    //if (chkSaveLoginInfo.Checked)
                    this.SaveLoginInfo();                                 //跟据选项保存登录信息
                    SystemAuthentication.Current = _CurrentAuthorization; //授权成功, 保存当前授权模式
                    Program.MainForm             = new frmMain();         //登录成功创建主窗体
                    Program.MainForm.InitUserInterface(new LoadStatus(lblLoadingInfo));

                    this.DialogResult = DialogResult.OK; //成功
                    this.Close();                        //关闭登陆窗体
                }
                else
                {
                    txtCardNo.Text = "";
                    txtCardNo.Focus();
                    lblInfo.Text = "登录失败,请检查卡号!";
                    timer1.Start();
                    this.ShowLoginInfo("登录失败,请检查卡号!");
                    //Msg.Warning("登录失败,请检查卡号!");
                }
            }
            catch (CustomException ex)
            {
                this.SetButtonEnable(true);
                this.ShowLoginInfo(ex.Message);
                Msg.Warning(ex.Message);

                txtCardNo.Text = "";
                txtCardNo.Focus();
                lblInfo.Text = "登录失败,请检查卡号!";
                timer1.Start();
            }
            catch (Exception ex)
            {
                this.SetButtonEnable(true);
                this.ShowLoginInfo("登录失败,请检查卡号!" + ex.Message);
                Msg.Warning("登录失败,请检查卡号!" + ex.Message);

                txtCardNo.Text = "";
                txtCardNo.Focus();
                lblInfo.Text = "登录失败,请检查卡号!";
                timer1.Start();
            }

            this.Cursor = Cursors.Default;
        }
示例#24
0
        /// <summary>
        /// 登陆系统
        /// </summary>
        public async void Login()
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(UserName) && !string.IsNullOrWhiteSpace(Password))
                {
                    this.IsCancel = false;
                    IUser user = ZFSBridge.BridgeFactory.BridgeManager.GetUserManager();
                    this.Report = "正在验证登录 . . .";
                    var LoginTask     = user.Login(UserName, CEncoder.Encode(Password));
                    var timeouttask   = Task.Delay(3000);
                    var completedTask = await Task.WhenAny(LoginTask, timeouttask);

                    if (completedTask == timeouttask)
                    {
                        this.Report = "系统连接超时,请联系管理员!";
                    }
                    else
                    {
                        var task = await LoginTask;
                        if (task.Success)
                        {
                            if (UserChecked)
                            {
                                SaveLoginInfo();
                            }

                            #region 设置用户基础信息
                            var req = task.Results as tb_User;
                            Loginer.LoginerUser.Account  = req.Account;
                            Loginer.LoginerUser.UserName = req.UserName;
                            Loginer.LoginerUser.IsAdmin  = req.FlagAdmin == "1" ? true : false;
                            Loginer.LoginerUser.Email    = req.Email;
                            #endregion

                            #region 加载用户资料
                            this.Report = "加载用户信息 . . .";
                            var response = await ZFSBridge.BridgeFactory.BridgeManager.GetUserManager().GetAuthority(Loginer.LoginerUser.Account);

                            Loginer.LoginerUser.UserAuthority = response.Results;

                            #endregion

                            #region 初始化首页
                            this.Report = "初始化首页 . . .";
                            MainViewModel model = new MainViewModel();
                            model.InitDefaultView();
                            var dialog = ServiceProvider.Instance.Get <IModelDialog>("MainViewDlg");
                            dialog.BindViewModel(model);
                            Messenger.Default.Send(string.Empty, "ApplicationHiding");
                            bool taskResult = await dialog.ShowDialog(null, model.ExtendedClosingEventHandler);

                            this.ApplicationShutdown();
                            #endregion
                        }
                        else
                        {
                            this.Report = task.Message;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.Report = ExceptionLibrary.GetErrorMsgByExpId(ex);
            }
            finally
            {
                this.IsCancel = true;
            }
        }
        /// <summary>
        /// 登陆系统
        /// </summary>
        public async void Login()
        {
            try
            {
                if (string.IsNullOrWhiteSpace(UserName) || string.IsNullOrWhiteSpace(Password))
                {
                    this.Report = "请输入用户名密码";
                    return;
                }

                #region login

                this.IsCancel = false;
                var user = ServiceProvider.Instance.Get <IUserService>();
                this.Report = "正在验证登录 . . .";
                var LoginTask     = user.LoginAsync(UserName, CEncoder.Encode(Password));
                var timeouttask   = Task.Delay(3000);
                var completedTask = await Task.WhenAny(LoginTask, timeouttask);

                if (completedTask == timeouttask)
                {
                    this.Report = "系统连接超时,请联系管理员!";
                }
                else
                {
                    var task = await LoginTask;
                    if (task.success)
                    {
                        if (task.user == null)
                        {
                            this.Report = task.message;
                            return;
                        }
                        if (UserChecked)
                        {
                            SaveLoginInfo();
                        }
                        var req = task.user;
                        #region 设置用户基础信息

                        Loginer.LoginerUser.Account  = req.Account;
                        Loginer.LoginerUser.UserName = req.UserName;
                        Loginer.LoginerUser.IsAdmin  = req.FlagAdmin == '1' ? true : false;
                        Loginer.LoginerUser.Email    = req.Email;
                        var result = await user.LoginUserAuthAsync(req.Account);

                        if (result.success && result.authorityEntity != null)
                        {
                            Loginer.LoginerUser.authorityEntity = result.authorityEntity;
                        }

                        this.Report = "加载用户信息 . . .";

                        var dialog = ServiceProvider.Instance.Get <IModelDialog>("MainViewDlg");
                        dialog.BindDefaultViewModel();
                        Messenger.Default.Send(string.Empty, "ApplicationHiding");
                        bool taskResult = await dialog.ShowDialog();

                        this.ApplicationShutdown();

                        #endregion
                    }
                    else
                    {
                        this.Report = task.message;
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                this.Report = ex.Message;
            }
            finally
            {
                this.IsCancel = true;
            }
        }