private void btnBack_Click(object sender, EventArgs e) { Shopping forthForm = new Shopping(); forthForm.Show(); this.Hide(); }
private void btnLogin_Click(object sender, EventArgs e) { string memberUsername; string memberPass; string managerUser; string managerPass; memberUsername = txtMemberUsername.Text; memberPass = txtPassword.Text; managerUser = txtMemberUsername.Text; managerPass = txtPassword.Text; FileStream inFile3 = new FileStream(FILENAME, FileMode.Open, FileAccess.Read); // reading the file again to user members data to login StreamReader reader3 = new StreamReader(inFile3); bool found = false; string loginFullName = ""; for (int y = 0; y < custCount; ++y) // reading the file and using the username and password to login s { fullName[y] = reader3.ReadLine(); newUsername[y] = reader3.ReadLine(); newPassword[y] = reader3.ReadLine(); address1[y] = reader3.ReadLine(); address2[y] = reader3.ReadLine(); city[y] = reader3.ReadLine(); zip[y] = reader3.ReadLine(); state[y] = reader3.ReadLine(); country[y] = reader3.ReadLine(); if (memberUsername == newUsername[y] && memberPass == newPassword[y]) { found = true; loginFullName = fullName[y]; break; } } if (found) { Shopping forthform = new Shopping(); forthform.loginName = loginFullName; forthform.Show(); this.Hide(); } if (managerUser == MANAGER_USERNAME && managerPass == MANAGER_PASSWORD) { ManagerReport managerForm = new ManagerReport(); managerForm.Show(); this.Hide(); } else { txtMemberUsername.Clear(); txtMemberUsername.Focus(); txtPassword.Clear(); lblError.Text = ("Sorry! Username or password you have entered is incorrect!"); } }
private void btnSave_Click(object sender, EventArgs e) { FileStream outFile = new FileStream(FILENAME1, FileMode.Create, FileAccess.Write); // writing the input string guestName; string guestAddress1; string guestAddress2; string guestCity; string guestZip; string guestState; string guestCountry; guestName = txtName.Text; guestAddress1 = txtAddress1.Text; guestAddress2 = txtAddress2.Text; guestCity = txtCity.Text; guestZip = txtZip.Text; guestState = txtState.Text; //guestCountry = txtCountry.Text; guestCountry = comboxCountry.Text; txtName.Clear(); txtAddress1.Clear(); txtAddress2.Clear(); txtCity.Clear(); txtZip.Clear(); txtState.Clear(); txtName.Focus(); StreamWriter writer = new StreamWriter(outFile); // connecting with the file if (guestName != "" && guestAddress1 != "" && guestCity != "" && guestZip != "" && guestState != "" && guestCountry != "") { writer.WriteLine(guestName); writer.WriteLine(guestAddress1); writer.WriteLine(guestAddress2); writer.WriteLine(guestCity); writer.WriteLine(guestZip); writer.WriteLine(guestState); writer.WriteLine(guestCountry); } else { MessageBox.Show(" Sorry! But one of fields was empty. Please make sure you fill all the field (Address 2 is optional!"); } writer.Close(); outFile.Close(); Shopping forthForm = new Shopping(); forthForm.loginName = guestName; forthForm.Show(); this.Hide(); }
private void btnCreateAcct_Click(object sender, EventArgs e) { FileStream outFile = new FileStream(FILENAME, FileMode.Append, FileAccess.Write); string userUsername; string firstPass; string retypePass; string userAddress1; string userAddress2; string userCity; string userZip; string userState; string userCountry; userFullName = txtFullName.Text; userUsername = txtNewUser.Text; firstPass = txtNewPass.Text; retypePass = txtRetypePass.Text; userAddress1 = txtMemAddress1.Text; userAddress2 = txtMemAddress2.Text; userCity = txtMemCity.Text; userZip = txtMemZip.Text; userState = txtMemState.Text; userCountry = combCountry.Text; txtFullName.Clear(); txtNewUser.Clear(); txtNewPass.Clear(); txtRetypePass.Clear(); txtMemAddress1.Clear(); txtMemAddress2.Clear(); txtMemCity.Clear(); txtMemZip.Clear(); txtMemState.Clear(); StreamWriter writer = new StreamWriter(outFile); if (userFullName != "" && userUsername != "" && firstPass != "" && retypePass != "" && (firstPass == retypePass) && userAddress1 != "" && userCity != "" && userZip != "" && userState != "" && userCountry != "") { writer.WriteLine(userFullName); writer.WriteLine(userUsername); writer.WriteLine(retypePass); writer.WriteLine(userAddress1); writer.WriteLine(userAddress2); writer.WriteLine(userCity); writer.WriteLine(userZip); writer.WriteLine(userState); writer.WriteLine(userCountry); Shopping forthForm = new Shopping(); forthForm.loginName = userFullName; forthForm.Show(); this.Hide(); } else { MessageBox.Show("Sorry! but one or more fields are empty!"); } writer.Close(); outFile.Close(); }