/// <summary> /// Validate the user. /// </summary> private void ValidateUser() { bool invalidUser = true; if (int.TryParse(tbxUser.Text, out int user) && int.TryParse(tbxPass.Text, out int pass)) { if (Login.LogIn(user, pass)) { invalidUser = false; FrmProduction production = new FrmProduction(); this.Hide(); SetTextBox(); DialogResult dialogResult = production.ShowDialog(); if (DialogResult.Abort == dialogResult) { this.Dispose(); } else if (DialogResult.Cancel == dialogResult) { SetTextBox(); this.Show(); } } } if (invalidUser) { MessageBox.Show("Incorrect operator number or password", "ERROR!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Validate the user. /// </summary> private void ValidateUser() { try { bool invalidUser = true; if (int.TryParse(tbxUser.Text, out int user) && int.TryParse(tbxPass.Text, out int pass)) { if (DAO.LoginOprator(user.ToString(), pass.ToString())) { invalidUser = false; FrmProduction production = new FrmProduction(); this.Hide(); SetTextBox(); DialogResult dialogResult = production.ShowDialog(); if (DialogResult.Abort == dialogResult) { this.Dispose(); } else if (DialogResult.Cancel == dialogResult) { SetTextBox(); this.Show(); } } } if (invalidUser) { throw new Exception("You must enter username and password"); } } catch (Exception ex) { throw new Exception(ex.Message); } }