/// <summary> /// [EN] FrmAuthentication_Load /// Create By: ManhNV1 -Date: 02/20/2016 /// </summary> /// <param name="sender">Object</param> /// <param name="e">EventArgs Load</param> private void FrmAuthentication_Load(object sender, EventArgs e) { var checkExist = File.Exists(SEDConst.PATH_USER_LOGIN); if (checkExist) { var strAccount = File.ReadAllText(SEDConst.PATH_USER_LOGIN, Encoding.UTF8); var account = JsonConvert.DeserializeObject<UserLoginRemember>(strAccount); var decodeData = new SEDDataEncrypt(); txtUserName.Text = decodeData.DecodeTwoWay(account.UserLogin); txtPassword.Text = decodeData.DecodeTwoWay(account.Password); } }
private void chkPassOld_CheckedChanged(object sender, EventArgs e) { if (chkPassOld.Checked) { if (txtPassOld.Text.Equals(SEDConst.STRING_EMPTY)) { XtraMessageBox.Show(SEDConst.CHANGEPASS_MESSAGE_INPUT, SEDConst.TITLE_NOTE , MessageBoxButtons.OK, MessageBoxIcon.Asterisk); SEDFuncCall.SetCheckEditStatus(chkPassOld, 0); } var strEncodePassOldInput = new SEDDataEncrypt().EncodeOneWay(txtPassOld.Text); if (!strEncodePassOldInput.Equals(passOld)) { SEDFuncCall.MessageWarning(SEDConst.CHANGEPASS_MESSAGE_NOTMATCH_PASSWORD , SEDConst.TITLE_WARNING); SEDFuncCall.SetCheckEditStatus(chkPassOld, 0); } else { txtPassOld.ReadOnly.Equals(true); SEDFuncCall.MessageSuccess(SEDConst.CHANGEPASS_MESSAGE_MATCH_PASSWORD, SEDConst.TITLE_NOTE); } } }
private void barBtnSave_ItemClick(object sender, ItemClickEventArgs e) { if (chkValidAll.CheckState == CheckState.Unchecked) { XtraMessageBox.Show(string.Format(SEDConst.CHANGEPASS_MESSAGE_CHECK_VALID, chkValidAll.Text) , SEDConst.TITLE_WARNING , MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { // Encrypt Password_New and Update Pass, WriteLog => Database var passNew = new SEDDataEncrypt().EncodeOneWay(txtPassNew.Text); using (var permissionContext = new PermissionDataContext()) { var accoutCurrent = permissionContext.Accounts.SingleOrDefault(a => (a.Id == A01FrmAuthentication.Id)); accoutCurrent.Password = passNew; // Write Log var logUpdateAction = new Log { UserId = A01FrmAuthentication.Id, Action = SEDConst.WRITE_LOG_UPDATE_PASSWORD, Time = SEDConst.WRITE_DATETIME_NOW }; permissionContext.Logs.InsertOnSubmit(logUpdateAction); permissionContext.SubmitChanges(); XtraMessageBox.Show(SEDConst.CHANGEPASS_MESSAGE_UPDATE, SEDConst.TITLE_NOTE , MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
/// <summary> /// Create By: ManhNV1 -Date: 02/22/2016 /// Description: Progress Remember Password after Login Success /// </summary> /// <param name="userName">String UserName</param> /// <param name="passWord">String Password</param> private void ProcessMeAccount(string userName, string passWord) { // Progress Encode Data var userEncrypt = new SEDDataEncrypt(); var strUserLoginEncode = userEncrypt.EncodeTwoWay(userName); var strPasswordEncode = userEncrypt.EncodeTwoWay(passWord); var userLoginRemember = new UserLoginRemember { UserLogin = strUserLoginEncode, Password = strPasswordEncode, LogTime = DateTime.Now.ToLongTimeString() }; var userJsonSave = JsonConvert.SerializeObject(userLoginRemember, Formatting.Indented); // Write Information UserLogin File.WriteAllText(SEDConst.PATH_USER_LOGIN, userJsonSave, Encoding.UTF8); }
/// <summary> /// [EN] btnLogin_CheckedChanged /// Create by: ManhNV1 -Date: 02/22/2016 /// Description: System Progress Login /// </summary> /// <param name="sender">Object default</param> /// <param name="e">EventArgs Changed</param> private void btnLogin_CheckedChanged(object sender, EventArgs e) { if (txtPassword.TextTrim().Equals(SEDConst.STRING_EMPTY) || txtUserName.TextTrim().Equals(SEDConst.STRING_EMPTY)) { XtraMessageBox.Show(SEDConst.MAIN_MESSAGE_EMPTY, SEDConst.TITLE_NOTE , MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } try { using (var permissionContext = new PermissionDataContext()) { // Check Valid Login var strEncodeUserName = new SEDDataEncrypt().EncodeOneWay(txtPassword.Text); var account = permissionContext.Accounts .SingleOrDefault(a => a.UserName.Equals(txtUserName.Text.ToLower()) && a.Password.Equals(strEncodeUserName)); if (null == account) { XtraMessageBox.Show(SEDConst.AUTHENTICATION_MESSAGE_LOGINFAIL, SEDConst.TITLE_WARNING , MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (account.Status == 0) { XtraMessageBox.Show(SEDConst.AUTHENTICATION_ACCOUNT_EXPIRE, SEDConst.TITLE_WARNING , MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Write Log var logWriteLoginSuccess = new Log { UserId = account.Id, Action = SEDConst.WRITE_LOG_UPDATE_LOGIN, Time = SEDConst.WRITE_DATETIME_NOW }; permissionContext.Logs.InsertOnSubmit(logWriteLoginSuccess); permissionContext.SubmitChanges(); ProgressLoginSuccess(account); } } catch (Exception ex) { //SEDConst.AUTHENTICATION_NOT_FIND_DATA XtraMessageBox.Show(ex.Message, SEDConst.TITLE_WARNING , MessageBoxButtons.OK, MessageBoxIcon.Error); } }