/** * User authentication */ public static void Authenticate(TextBox txtUser, TextBox txtPass, Form frmLogin) { try { using (DBAuditDataContext dc = new DBAuditDataContext()) { _strUser = txtUser.Text; int? intUSerId = null; string strPass = null; int? intDisabled = null; int? intLocked = null; string strFName = null; string strLName = null; var strEncPass = EncryptPassword(txtPass); dc.ProLoginData(_strUser, ref intUSerId, ref strPass, ref intDisabled, ref intLocked, ref strFName, ref strLName); if (strPass == strEncPass && intDisabled == 0 && intLocked == 0) { // Get Current User Details _staticIntUserId = Convert.ToInt32(intUSerId); _staticStrUserName = strFName + " " + strLName; // // Open Main Form & close the Login Form: new FrmMain().Show(); // Change Culture (Input language) to Arabic: CultureInfo ci = new CultureInfo("AR-EG"); Thread.CurrentThread.CurrentCulture = ci; Thread.CurrentThread.CurrentUICulture = ci; Application.CurrentCulture = ci; Application.CurrentInputLanguage = InputLanguage.FromCulture(ci); // // Add Login Process to Log string strLoginTime = DateTime.Now.ToString(CultureInfo.CurrentCulture); dc.ProAuditLogin(_staticIntUserId, strLoginTime); _staticStrLoginTime = strLoginTime; frmLogin.Close(); } else if (intDisabled == 1) { MessageBox.Show(@"عفواً تم تعطيل هذا الحساب يرجى الرجوع للإدارة", @"المراجع الذكي", MessageBoxButtons.OK, MessageBoxIcon.Hand); txtUser.Text = ""; txtPass.Text = ""; } else if (intLocked == 1) { MessageBox.Show(@"عفواً تم تعطيل هذا الحساب مؤقتاً يرجى الرجوع للإدارة", @"المراجع الذكي", MessageBoxButtons.OK, MessageBoxIcon.Hand); txtUser.Text = ""; txtPass.Text = ""; } else { MessageBox.Show(@"عفواً البيانات التي قمت بإدخالها غير صحيحة!", @"المراجع الذكي", MessageBoxButtons.OK, MessageBoxIcon.Error); _countLogin = _countLogin + 1; txtPass.Text = ""; if (_countLogin >= 3) { dc.ProAutoLockAccount(_strUser); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }