示例#1
0
		private void btnLoginCardScan_Click(object sender, System.EventArgs e)
		{          
#if USE_CARDSCAN
			if((g_COMPORT != cbConfigureCardScan.Text.ToString())&&(cbConfigureCardScan.Text != "NO COMPORTS"))
			{
				g_COMPORT = cbConfigureCardScan.Text.ToString();
				RK = Registry.CurrentUser.OpenSubKey("Software\\" + sProductKey,true);
				RK.SetValue("COMPORT",g_COMPORT);
			}
			FrmParent.Msg("Scan User Identification Card");	
			this.Opacity = 0;
			string CardNumber = CardSwipe.Scan(g_COMPORT);
			if(CardNumber == "")return;
			CardNumber = FormatCardNumber(CardNumber);
			
			
			tryagain2:{}
			FrmParent.Msg("Authenticating User...");		
			try
			{	
				OSystem = new OysterClassLibrary.Oyster();				
				try
				{				
					LoginUser = OSystem.Login(CardNumber);
				}
				catch (Exception Err)
				{
					string peek = Err.Message;
					MessageBox.Show("Invalid Login ID or Password.","Oyster Hardcopy: Login Message");
					return;					
				}
				if(LoginUser != null)
				{
					if(!CheckForValidLicense(LoginUser))
					{
						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;
					}

					goto tryagain2;
				
				}
				else
				{
					this.Opacity = 100;
					MessageBox.Show("Possible license authentication error.","Unknown Error");
					MessageBox.Show("Application will now close","Oyster Hardcopy");
					this.DialogResult = DialogResult.Abort;
					return;					
				}	
			}
           
			if(OSystem.SystemAdminLoginDenied == true)
			{
				MessageBox.Show("Someone has already logged in with System Administrator access...\nYour SYSTEM privileges 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;
#endif
		}
示例#2
0
		private void btnLoginName_Click(object sender, System.EventArgs e)
		{			
			string g_sLoginName = tbLoginName.Text;
			string g_sLoginPassword = tbLoginPassword.Text;
			this.Opacity = 0;		
			FrmParent.Msg("Authenticating User...");	
			MyGlobals.Logger.WriteLog("authenticating {0}", g_sLoginName);
			
			tryagain:{}
			
				try
				{
					OSystem = new OysterClassLibrary.Oyster();    
				}
				catch (Exception Err)
				{
					this.Opacity = 100;

					if (Err.Message == "SQL Server does not exist or access denied.")
					{
						MyGlobals.Logger.WriteLog("SQL Server not found. Asking for server location.");
						DialogResult DR = MessageBox.Show("Do you wish to try to locate the server manually",
							CarverLab.Utility.AppInfo.Title + ": Server connection error.", 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
					{
						MyGlobals.Logger.WriteLog("SQL Server not found. Exception: {0}.", Err.ToString());
						MessageBox.Show(this, Err.Message, CarverLab.Utility.AppInfo.Title + ": Server connection error.");
						this.DialogResult = DialogResult.None;
						return;
					}
				}
				try
				{
					try
					{
						LoginUser = OSystem.Login(g_sLoginName,g_sLoginPassword);
					}
					catch (Exception Err)
					{
						string peek = Err.Message;
						MyGlobals.Logger.WriteLog("Login error. Exception: {0}.", Err.ToString());
						MessageBox.Show("Invalid Login ID or Password.", CarverLab.Utility.AppInfo.Title + ": Login Message");
						return;					
					}

					if(LoginUser != null)
					{
						if(!CheckForValidLicense(LoginUser))
						{
							LoginUser = null;
							return;
						}

						FrmParent.Msg("User authenticated.");
					}
					if(OSystem.SystemAdminLoginDenied == true)
					{
						MessageBox.Show("Someone has already logged in with System Administrator access...\nYour SYSTEM privileges are being set to READONLY Access.\nFor Full Access please try to login again at a later time.",CarverLab.Utility.AppInfo.Title + ": 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;
#if USE_LICENSING
						MessageBox.Show("Possible license authentication error.","Unknown Error");
#else
						MessageBox.Show(Err.Message, "Oyster Hardcopy Error");
#endif
						MessageBox.Show("Application will now close","Oyster Hardcopy");
						this.DialogResult = DialogResult.Abort;
						return;					
					}										
				}
				
#if USE_CARDSCAN
				if(g_COMPORT != cbConfigureCardScan.Text.ToString())
				{
					g_COMPORT = cbConfigureCardScan.Text.ToString();
					RK = Registry.CurrentUser.OpenSubKey("Software\\" + sProductKey,true);
					RK.SetValue("COMPORT",g_COMPORT);
				}
#endif			
				this.DialogResult = DialogResult.OK;			
		}