private void BtnCreatAcct_Click(object sender, EventArgs e) { try { duplicateemail(); checkage(); emailregex(); if (emailformat == true && agecheck == true && emaildup == false) { //Customer is a class for all user information and ticket types this.Hide(); Customer.name = txtName.Text; Customer.age = int.Parse(txtAge.Text); Customer.email = txtEmail.Text; Customer.password = txtPassword.Text; string CustomerRecord = Customer.name + "," + Customer.age + "," + Customer.email + "," + Customer.password; File.AppendAllText("CustomerInfo.txt", CustomerRecord + "\r\n"); frmOrder OrderForm = new frmOrder(); OrderForm.ShowDialog(); this.Close(); } } catch { MessageBox.Show("All fields are required"); } }
private void BtnLogin_Click(object sender, EventArgs e) { try { this.Hide(); string LoginEmail = txtEmail.Text; string Loginpassword = txtPassword.Text; bool valid = false; //CustomerLogin collect user info to be put in the Customer class var CustomerLogin = from customer in CustomerInfo let login = customer.Split(',') let name = login[0] let age = login[1] let email = login[2] let password = login[3] select new { name, age, email, password }; foreach (var i in CustomerLogin) { if (i.email == LoginEmail && i.password == Loginpassword) { Customer.email = i.email; Customer.name = i.name; Customer.age = int.Parse(i.age); valid = true; frmOrder OrderForm = new frmOrder(); OrderForm.ShowDialog(); this.Close(); break; } } if (valid == false) { MessageBox.Show("The email or password is incorrect."); } } catch { MessageBox.Show("All fields are required"); } }