private void btnLogin_Click(object sender, EventArgs e) { oUser = new DataAccess.User(); oUtility = new CommonFunction.CommonFunction(); if (oUtility.Decrypt(oDefUser.USERNAME.Trim()) == txtUsername.Text && oUtility.Decrypt(oDefUser.PASSWORD.Trim()) == txtPassword.Text) //Default Login { this.Hide(); this.ShowInTaskbar = false; ePublicVariable.eVariable.sUsername = txtUsername.Text; ePublicVariable.eVariable.sPassword = txtPassword.Text; ePublicVariable.eVariable.sFullname = oUtility.Decrypt(oDefUser.FULLNAME); ePublicVariable.eVariable.sRole = oUtility.Decrypt(oDefUser.ROLE); oMainForm = new MAIN(); oMainForm.ShowDialog(); } else { #region CheckDatabase oDatabase = new DataAccess.SystemFunction(); if (!oDatabase.IsDatabaseExits()) { oFrmMsgBox = new frmMessageBox("DATABASE DOES NOT EXISTS. PLEASE RESTORE FIRST THE DATABASE. THANK YOU"); oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); Maintenance.frmBackupRestoreDB oFrm = new Maintenance.frmBackupRestoreDB(); oFrm.ShowDialog(); } #endregion #region DBLogin if (oUser.IsLogin(txtUsername.Text.Trim(), txtPassword.Text.Trim())) { this.ShowInTaskbar = false; this.Hide(); ePublicVariable.eVariable.sUsername = txtUsername.Text; ePublicVariable.eVariable.sPassword = txtPassword.Text; oMainForm = new MAIN(); oMainForm.ShowDialog(); } else { oFrmMsgBox = new Forms.frmMessageBox("PLEASE ENTER CORRECT USERNAME AND PASSWORD."); oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); txtUsername.Focus(); } #endregion } }
private void btnLogin_Click(object sender, EventArgs e) { oUser = new DataAccess.User(); oCommonFunction = new CommonFunction.CommonFunction(); if (oCommonFunction.Decrypt(oDefUser.USERNAME.Trim()) == txtUsername.Text && oCommonFunction.Decrypt(oDefUser.PASSWORD.Trim()) == txtPassword.Text) //Default Login { this.ShowInTaskbar = false; this.Hide(); oMainForm = new MAIN(txtUsername.Text, txtPassword.Text, oCommonFunction.Decrypt(oDefUser.FULLNAME), oCommonFunction.Decrypt(oDefUser.ROLE)); oMainForm.ShowDialog(); return; } else { #region CheckDatabase oDatabase = new DataAccess.BackupRestoreDB(); if (!oDatabase.IsDatabaseExits()) { oFrmMsgBox = new frmMessageBox(ePublicVariable.eVariable.TransactionMessage.THE_DATABASE_DOES_NOT_EXITS.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); Maintenance.frmBackupRestoreDB oFrm = new Maintenance.frmBackupRestoreDB(); oFrm.ShowDialog(); } #endregion #region DBLogin if (oUser.IsLogin(txtUsername.Text.Trim(), txtPassword.Text.Trim())) { foreach (DataRow row in oUser.GetUser("username", txtUsername.Text).Rows) { oMUser = new Model.User(); oMUser.USERNAME = row[0].ToString(); oMUser.FULLNAME = row[1].ToString(); oMUser.PASSWORD = row[2].ToString(); oMUser.ROLE = row[3].ToString(); oMUser.CONTACT_NO = row[4].ToString(); oMUser.ADDRESS = row[5].ToString(); } this.ShowInTaskbar = false; this.Hide(); oMainForm = new MAIN(oMUser); oMainForm.ShowDialog(); return; } else { lblNotification.Text = "THE USERNAME AND PASSWORD YOU HAVE ENTERED ARE INCORRECT"; txtUsername.Focus(); } #endregion } }