private void barBtnSave_ItemClick(object sender, ItemClickEventArgs e)
 {
     if (chkCheckValidAll.CheckState == CheckState.Unchecked)
     {
         var strMessageChangePass = string.Format(SEDConst.CHANGEPASS_MESSAGE_CHECK_VALID, chkCheckValidAll.Text);
         SEDFuncCall.MessageWarning(strMessageChangePass, SEDConst.TITLE_WARNING);
     }
     try
     {
         using (var permissionContext = new PermissionDataContext())
         {
             var accountNew = new Account
             {
                 FullName = txtFullName.Text,
                 Address = txtAddress.Text,
                 Phone = txtPhone.Text,
                 UserName = txtUserName.Text,
                 Password = new SEDDataEncrypt().EncodeOneWay(txtPassword.Text),
                 Email = txtEmail.Text,
                 Permission = (chkSetPermission.Checked ? 1 : 0),
                 Status = (chkSetStatus.Checked ? 1 : 0)
             };
             permissionContext.Accounts.InsertOnSubmit(accountNew);
             permissionContext.SubmitChanges();
             SEDFuncCall.MessageSuccess(SEDConst.ACCOUNTCRUD_MESSAGE_CREATE_SUCCSESS
                 , SEDConst.TITLE_NOTE);
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show(ex.Message, SEDConst.TITLE_WARNING, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 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>
 ///     [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);
     }
 }
예제 #4
0
 /// <summary>
 ///     [EN] barBtnLogout_ItemClick
 ///     Create By: ManhNV1 -Date: 02/22/2016
 ///     Description: Show Form Logout
 /// </summary>
 /// <param name="sender">Object</param>
 /// <param name="e">ItemClickEventArgs Click</param>
 /// >
 private void barBtnLogout_ItemClick(object sender, ItemClickEventArgs e)
 {
     var result = XtraMessageBox.Show(SEDConst.MAIN_MESSAGE_LOG_OUT, SEDConst.TITLE_NOTE
         , MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     if (result == DialogResult.Yes)
     {
         SetEnableAllButton(false);
         barBtnLogin.Enabled = true;
         var logWriteLogout = new Log
         {
             UserId = A01FrmAuthentication.Id,
             Action = SEDConst.WRITE_LOG_OUT_SYSTEM,
             Time = SEDConst.WRITE_DATETIME_NOW
         };
         try
         {
             using (var permissionContex = new PermissionDataContext())
             {
                 permissionContex.Logs.InsertOnSubmit(logWriteLogout);
                 permissionContex.SubmitChanges();
                 foreach (var f in MdiChildren)
                 {
                     f.Close();
                 }
             }
         }
         catch
         {
             XtraMessageBox.Show(SEDConst.AUTHENTICATION_WARING_BEHAVIOR_DATABASE, SEDConst.TITLE_NOTE
                 , MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
         FrmAuthenShow();
     }
 }