private void btnLogin_Click(object sender, EventArgs e) { string inputuserID, inputPassword; bool flag = false; int foundSub = 0; FileStream outFile = new FileStream(FILENAME2, FileMode.Open, FileAccess.Write); StreamWriter writer = new StreamWriter(outFile); inputuserID = txtUserID.Text; inputPassword = txtPassword.Text; if (inputuserID == ADMIN && inputPassword == ADMINPASSWORD) { frmAdmin admin = new frmAdmin(); admin.Show(); this.Hide(); } else { for (int y = 0; y < arraySize; ++y) { if (inputuserID == userID[y] && inputPassword == password[y]) { flag = true; foundSub = y; } } if (flag) { writer.WriteLine(Convert.ToString(userNumber[foundSub]) + DELIM + userID[foundSub]); writer.Close(); outFile.Close(); frmBuild frm = new frmBuild(); frm.Show(); this.Hide(); } else { MessageBox.Show("Incorrect User ID or Password. Please try again."); writer.Close(); outFile.Close(); txtUserID.Text = null; txtPassword.Text = null; txtUserID.Focus(); } } }
private void button1_Click(object sender, EventArgs e) { frmAdmin frm = new frmAdmin(); frm.Show(); }