public void LoginButton_Click(object sender, EventArgs e) { string user = UsernameText.Text; string pass = PasswordText.Text; con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|/payroll_db.accdb"); cmd = new OleDbCommand(); con.Open(); cmd.Connection = con; cmd.CommandText = "SELECT * FROM login where username='******' AND password='******'"; dr = cmd.ExecuteReader(); if (dr.Read()) { id = UsernameText.Text; new Form1().Show(); Hide(); } else { MessageBox.Show("Username or password is incorrect"); ErrorLabel.Show(); } con.Close(); }
private void regbtn1_Click(object sender, EventArgs e) { string regpnr = pnrtextbox1.Text; string regfirstname = firstnametextbox1.Text; string reglastname = lastnametextbox1.Text; string regpassword = passwordtextbox1.Text; if (string.IsNullOrEmpty(regpnr) && string.IsNullOrEmpty(regfirstname) || string.IsNullOrEmpty(reglastname) || string.IsNullOrEmpty(regpassword)) { ErrorLabel.ForeColor = System.Drawing.Color.Red; ErrorLabel.Text = " Kontrollera att personnummer stämmer och att rutorna är ifyllda!"; var t1 = new Timer(); t1.Interval = 7000; t1.Tick += (s, e1) => { ErrorLabel.Hide(); t1.Stop(); }; t1.Start(); ErrorLabel.Show(); } else { if (call.AddCustomer(Convert.ToString(regpnr), regfirstname, reglastname, regpassword)) { ErrorLabel.ForeColor = System.Drawing.Color.Green; this.ErrorLabel.Text = "Konto skapat!"; //Registration reg = new Registration(); //this.Hide(); } else { ErrorLabel.ForeColor = System.Drawing.Color.Red; ErrorLabel.Text = "Personnummret finns redan, se till att det är rätt ifyllt! "; } } var t = new Timer(); t.Interval = 7000; t.Tick += (s, e1) => { ErrorLabel.Hide(); t.Stop(); }; t.Start(); ErrorLabel.Show(); pnrtextbox1.Clear(); firstnametextbox1.Clear(); lastnametextbox1.Clear(); passwordtextbox1.Clear(); }
private void ChangeCashDispenserStateButton_Click(object sender, EventArgs e) { // Connect with database try { if (this.ChangeCashDispenserValueValueTextBox.TextLength == 0) { ErrorLabel.Show(); ErrorLabel.Text = "Niedozwolona Wartość Kwoty"; throw new Exception(); } MockPhysicalMoneyRepository mockPhysicalMoneyRepository = new MockPhysicalMoneyRepository(SystemSettings._PlatformType); // Update cash dispenser state mockPhysicalMoneyRepository.UpdateInCurrency( currencyRate: CashWithdrawalProperties.exchangeRates.PLN_exchangeRate, physicalMoneyVAL: new PhysicalMoneyVAL( value: decimal.Parse(this.ChangeCashDispenserValueValueTextBox.Text, CultureInfo.InvariantCulture), currency: Currency.PLN)); // Redirect to administrator change cash dispenser state result panel AdministratorChangeCashDispenserStateResultPanel administratorChangeCashDispenserStateResultPanel = new AdministratorChangeCashDispenserStateResultPanel(); administratorChangeCashDispenserStateResultPanel.ShowDialog(); // Update local cash dispenser state this.cashDispenserStateInPln = mockPhysicalMoneyRepository.GetInCurrency( currencyRate: CashWithdrawalProperties .exchangeRates.PLN_exchangeRate, currency: Currency.PLN)._Value; // Show cash dispenser state after change this.CashDispenserStateValueLabel.Text = (String.Format("{0:0.00}", this.cashDispenserStateInPln)); } catch (MockPhysicalMoneyRepository_Exception mpmr_e) { this.ErrorLabel.Text = mpmr_e.What(); this.ErrorLabel.Show(); } catch (PhysicalMoneyVAL_Exception pm_e) { this.ErrorLabel.Text = pm_e.What(); this.ErrorLabel.Show(); } catch (Exception ex) { } }
private void LoginButton_Click(object sender, EventArgs e) { if (UsernameText.Text == "iTecCrawley" && PasswordText.Text == "admin") { Form1 form = new Payroll.Form1(); form.Show(); this.Hide(); } else { ErrorLabel.Show(); } }
private void SaveButton_Click(object sender, EventArgs e) { // Checks whether or not a valid name has been entered. if (!string.IsNullOrWhiteSpace(NameText.Text)) { Response = NameText.Text; // Sets the DialogResult of this Dialog window to "OK", meaning the parent form of this form will know that something has occured. DialogResult = System.Windows.Forms.DialogResult.OK; // Closes the form. Close(); } // If a valid name hasn't been entered, display an error message stating that a valid name must be entered. ErrorLabel.Show(); }
private void ConvertButton_Click(object sender, EventArgs e) { //Make sure we can actually convert, and set the error label if not. if (CurrencyFromSelector.SelectedIndex == 0) { //No Currency Selected in the 'From' field. CurrencyFromSelector.ForeColor = Color.Red; ErrorLabel.Text = "Error: No currency selected to convert from."; ErrorLabel.Show(); } else if (CurrencyToSelector.SelectedIndex == 0) { //No Currency Seleceted int the 'To' field. CurrencyToSelector.ForeColor = Color.Red; ErrorLabel.Text = "Error: No currency selected to convert to."; ErrorLabel.Show(); } else { //Nothing wrong with the currency combo boxes, hide any error currently showing. ErrorLabel.Hide(); //Put the input into a string so we can remove any currency symbols the user might of entered. string userInput = ConversionInput.Text; if (userInput.Contains('$')) { userInput = userInput.Replace("$", ""); } else if (userInput.Contains('£')) { userInput = userInput.Replace("£", ""); } else if (userInput.Contains("€")) { userInput = userInput.Replace("€", ""); } try { /* Attempt to convert the string to a double. If it fails, the user has entered something other than a number. * I am not producing an error for negative amounts, in case someone wants to work out their debt in another currency. ¯\_(ツ)_/¯ */ double userAmount = Double.Parse(userInput); Convert(userAmount, CurrencyFromSelector.GetItemText(CurrencyFromSelector.SelectedItem), CurrencyToSelector.GetItemText(CurrencyToSelector.SelectedItem)); } catch { //Input wasn't a number, or had extra characters in it, show an error and let the user try again. ErrorLabel.Text = "Error: Amount Entered was not a valid number"; ErrorLabel.Show(); } } }
private void RegisterButton_Click(object sender, EventArgs e) { if (IDTextField.Text != "" && NameTextField.Text != "" && UsernameTextField.Text != "" && PasswordField.Text != "" && CPasswordField.Text != "") { if (PasswordField.Text.Equals(CPasswordField.Text)) { using (SqlCommand cmd = new SqlCommand("AddAdmin_SP", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", IDTextField.Text); cmd.Parameters.AddWithValue("@name", NameTextField.Text); cmd.Parameters.AddWithValue("@username", UsernameTextField.Text); cmd.Parameters.AddWithValue("@password", PasswordField.Text); cmd.Parameters.AddWithValue("@phone", PhoneTextField.Text); con.Open(); try { cmd.ExecuteNonQuery(); MessageBox.Show("Successfully registered - your username is :" + UsernameTextField.Text); IDTextField.Text = ""; NameTextField.Text = ""; UsernameTextField.Text = ""; PasswordField.Text = ""; CPasswordField.Text = ""; PhoneTextField.Text = ""; } catch (Exception z) { ErrorLabel.Text = "Error occured!"; ErrorLabel.Show(); MessageBox.Show("" + z); } con.Close(); } } else { ErrorLabel.Text = "Passwords do not match!"; ErrorLabel.Show(); } } else { ErrorLabel.Text = "Values cannot be empty!"; ErrorLabel.Show(); } GC.Collect(); }
/// <summary> /// This method makes or remakes the song by clearing all notes and adding the ones from NoteTextBox /// </summary> private void MakeSong() { try { ErrorLabel.Hide(); DisablePlayButton(); Autoplayer.ClearAllNotes(); Autoplayer.AddNotesFromString(NoteTextBox.Text); } catch (AutoplayerNoteCreationFailedException e) { ErrorLabel.Text = $"ERROR: {e.Message}"; ErrorLabel.Show(); } }
public void Starter() { try { string connectionString = "server=localhost;user=root;database=inda;password=;"; MySqlConnection connection = new MySqlConnection(connectionString); connection.Open(); connection.Close(); } catch { label1.Hide(); label2.Hide(); label3.Hide(); ErrorLabel.Show(); } }
private void pnrtextbox1_KeyPress_1(object sender, KeyPressEventArgs e) { { if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && (e.KeyChar != '.') && (e.KeyChar != ',')) { ErrorLabel.Text = "Endast siffror"; ErrorLabel.ForeColor = System.Drawing.Color.Red; e.Handled = true; var tim = new Timer(); tim.Interval = 7000; tim.Tick += (s, e1) => { ErrorLabel.Hide(); tim.Stop(); }; tim.Start(); ErrorLabel.Show(); } } }
private void AcceptButton_Click(object sender, EventArgs e) { // Pin Code PinVAL pinCode = null; // Validate Pin Code try { pinCode = new PinVAL(PinCodeTextBox.Text); } catch (PinVAL_Exception p_e) { ErrorLabel.Text = p_e.What(); ErrorLabel.Show(); } if (pinCode != null) { // Login basic user if (pinCode._Value.Length == 4) { try { // Connect with basic users database MockBasicUsersRepository mockBasicUsersRepository = new MockBasicUsersRepository(SystemSettings._PlatformType); // Get information about basic user with respectively pin code // from database BasicUserPanelVM basicUserPanelVM = new BasicUserPanelVM { basicUser = mockBasicUsersRepository.GetAll().FirstOrDefault( (singleBasicUser) => singleBasicUser._Pin._Value == pinCode._Value) }; // Check basic user's find result if (basicUserPanelVM.basicUser != null) { // Redirect to Basic User Panel basicUserPanelVM.loginPanel = this; BasicUserPanel basicUserPanel = new BasicUserPanel(basicUserPanelVM); this.PinCodeTextBox.Clear(); this.ErrorLabel.Hide(); basicUserPanel.Show(); this.Hide(); } else { ErrorLabel.Text = "!!! Użytkownik O Podanym Pinie Nie Istnieje !!!"; ErrorLabel.Show(); } } catch (MockBasicUsersRepository_Exception mbur_e) { ErrorLabel.Text = mbur_e.What(); ErrorLabel.Show(); } } // Login administrator else if (pinCode._Value.Length == 6) { try { // Connect with administrators database MockAdministratorsRepository mockAdministratorsRepository = new MockAdministratorsRepository(SystemSettings._PlatformType); // Get information about administrator with respectively pin code // from database AdministratorPanelVM administratorPanelVM = new AdministratorPanelVM { administrator = mockAdministratorsRepository.GetAll(). FirstOrDefault((singleAdministrator) => singleAdministrator._Pin._Value == pinCode._Value) }; // Check administrator's find result if (administratorPanelVM.administrator != null) { // Redirect to administrator panel administratorPanelVM.loginPanel = this; AdministratorPanel administratorPanel = new AdministratorPanel(administratorPanelVM); this.PinCodeTextBox.Clear(); this.ErrorLabel.Hide(); administratorPanel.Show(); this.Hide(); } else { ErrorLabel.Text = "!!! Użytkownik O Podanym Pinie Nie Istnieje !!!"; ErrorLabel.Show(); } } catch (MockAdministratorsRepository_Exception mar_e) { ErrorLabel.Text = mar_e.What(); ErrorLabel.Show(); } } } }
private void SetError(string msg) { ErrorLabel.Text = msg; ErrorLabel.Show(); }
/// <summary> /// This method will handle exceptions thrown from other threads than the current one /// This was added because I had some problems with exceptions from other threads not being catched /// </summary> private void ExceptionHandler(AutoplayerException exception) { ErrorLabel.Text = exception.Message; ErrorLabel.Show(); }