protected void createCustomer_Click1(object sender, EventArgs e) { using (ChallengeLINQDataContext Data = new ChallengeLINQDataContext()) { string cusName = custNameText.Text; string cusGender = custGenderText.Text; string PaymentMethod = custPaymentText.Text; string course = custCourseName.SelectedItem.Text; string hostel = custHostelName.SelectedItem.Text; CustomerClass theCustomer = new CustomerClass(cusName, cusGender, course, hostel, PaymentMethod); List <string> customerDetails = new List <string>(theCustomer.addToList()); foreach (string measurement in customerDetails) { summaryList.Items.Add(measurement); } CustomerTable TableCustomer = new CustomerTable(); //This enters the formdata into the database, specifically the CustomerTable TableCustomer.customerName = cusName; TableCustomer.customerGender = cusGender; TableCustomer.paymentMethod = PaymentMethod; TableCustomer.courseName = course; TableCustomer.hostelName = hostel; Data.CustomerTables.InsertOnSubmit(TableCustomer); Data.SubmitChanges(); } }
protected void Button1_Click1(object sender, EventArgs e) { using (ChallengeLINQDataContext data = new ChallengeLINQDataContext()) { string user = userBox.Text; string pass = passBox.Text; try { var theUser = data.StaffTables.Single(StaffTable => StaffTable.username == user); //using the == function to make sure it's an exact match var thePass = data.StaffTables.Single(StaffTable => StaffTable.password == pass); // string successMessage = "Welcome! " + theUser.name; //using "" to have text appear before the staffName // logInMessage.Text = successMessage; Server.Transfer("Customer.aspx"); //This code would take you straight to the Customer screen on a successful Log In } catch { string errorMessage = "Something's not quite right! Please try again."; //Error message if the information entered doesn't match the staff table exactly logInMessage.Text = errorMessage; } } }