private void btnLoginCardScan_Click(object sender, System.EventArgs e) { if((g_COMPORT != cbConfigureCardScan.Text.ToString())&&(cbConfigureCardScan.Text != "NO COMPORTS")) { g_COMPORT = cbConfigureCardScan.Text.ToString(); RK = Registry.CurrentUser.OpenSubKey("Software\\Carver Lab\\Oyster V2.0\\Data",true); RK.SetValue("COMPORT",g_COMPORT); } FrmParent.Msg("Scan User Identification Card"); string CardNumber = CardSwipe.Scan(g_COMPORT); if(CardNumber == "")return; CardNumber = FormatCardNumber(CardNumber); tryagain2:{} FrmParent.Msg("Searching for server please wait..."); try { OSystem = new OysterClassLibrary.Oyster(); FrmParent.Msg("Authenticating User..."); try { LoginUser = OSystem.Login(CardNumber); } catch (Exception Err) { string peek = Err.Message; MessageBox.Show("Unrecognized Access Card.","Oyster Executive: Login Message"); return; } //LoginUser = OSystem.Login(g_sLoginName,g_sLoginPassword); if(LoginUser != null) { if(!CheckForValidLicense(LoginUser)) { FrmParent.Msg("All available login slots are currently in use."); LoginUser = null; return; } FrmParent.Msg("User authenticated."); } } catch(Exception Err) { if(Err.Message == "SQL Server does not exist or access denied.") { DialogResult DR = MessageBox.Show("Do you wish to try to locate the server manually","Unable to establish a connection to Oyster Server",System.Windows.Forms.MessageBoxButtons.YesNo); if(DR == DialogResult.No) { this.DialogResult = DialogResult.Abort; return; } frmServerLocation SL = new frmServerLocation(); DR = SL.ShowDialog(this); if(DR != DialogResult.OK) { this.DialogResult = DialogResult.Abort; return; } //FrmParent.Msg("Searching for server please wait..."); goto tryagain2; } else { this.Opacity = 100; MessageBox.Show("Error received while attempting to login user.","Unknown Error"); MessageBox.Show("Application will now close","Oyster Executive"); this.DialogResult = DialogResult.Abort; return; } } if(OSystem.SystemAdminLoginDenied == true) { MessageBox.Show("Someone has already logged in with System Administrator access...\nYour SYSTEM priviledges are being set to READONLY Access.\nFor Full Access please try to login again at a later time.","System Administrator account in use!"); } FrmParent.Msg("User authenticated."); this.DialogResult = DialogResult.OK; }
private void btnLoginName_Click(object sender, System.EventArgs e) { string g_sLoginName = tbLoginName.Text; string g_sLoginPassword = tbLoginPassword.Text; FrmParent.Msg("Authenticating User..."); tryagain:{} try { try { //OSystem = new OysterClassLibrary.Oyster(serveraddress,password); //OSystem = new OysterClassLibrary.Oyster(); OSystem = new OysterClassLibrary.Oyster(ConnectionString); } catch(Exception Err) { if(Err.Message == "SQL Server does not exist or access denied.") { DialogResult DR = MessageBox.Show("Do you wish to try to locate the server manually","Unable to establish a connection to Oyster Server",System.Windows.Forms.MessageBoxButtons.YesNo); if(DR == DialogResult.No) { this.DialogResult = DialogResult.Abort; return; } frmServerLocation SL = new frmServerLocation(); DR = SL.ShowDialog(this); if(DR != DialogResult.OK) { this.DialogResult = DialogResult.Abort; return; } goto tryagain; } } try { LoginUser = OSystem.Login(g_sLoginName,g_sLoginPassword); } catch (Exception Err) { string peek = Err.Message; MessageBox.Show("Invalid Login ID or Password.","Oyster Executive: Login Message"); return; } if(LoginUser != null) { if(!CheckForValidLicense(LoginUser)) { LoginUser = null; return; } //Splash.Dispose(); FrmParent.Msg("User authenticated."); } if(OSystem.SystemAdminLoginDenied == true) { MessageBox.Show("Someone has already logged in with System Administrator access...\nYour SYSTEM priviledges are being set to READONLY Access.\nFor Full Access please try to login again at a later time.","System Administrator account in use!"); } } catch(Exception Err) { //Splash.Dispose(); if(Err.Message == "SQL Server does not exist or access denied.") { DialogResult DR = MessageBox.Show("Do you wish to try to locate the server manually","Unable to establish a connection to Oyster Server",System.Windows.Forms.MessageBoxButtons.YesNo); if(DR == DialogResult.No) { this.DialogResult = DialogResult.Abort; return; } frmServerLocation SL = new frmServerLocation(); DR = SL.ShowDialog(this); if(DR != DialogResult.OK) { this.DialogResult = DialogResult.Abort; return; } goto tryagain; } else { this.Opacity = 100; MessageBox.Show("Unknown error occurred while attempting to login to system","Unknown Error"); MessageBox.Show("Application will now close","Oyster Executive"); this.DialogResult = DialogResult.Abort; return; } } if(g_COMPORT != cbConfigureCardScan.Text.ToString()) { g_COMPORT = cbConfigureCardScan.Text.ToString(); RK = Registry.LocalMachine.OpenSubKey("Software\\Carver Lab\\Oyster V2.0\\Data",true); RK.SetValue("COMPORT",g_COMPORT); } this.DialogResult = DialogResult.OK; }