private void btnForgotID_Click(object sender, EventArgs e) { //check for only alphabetical names if (!Regex.IsMatch(txtName.Text, "^[a-zA-Z ]")) { MessageBox.Show("Please Enter A Valid Name"); } else { //check for 10 digit phone number with dashes if (!phoneNumpattern.IsMatch(txtPhone.Text)) { MessageBox.Show("Please enter a valid phone number using this format: 555-555-5555"); } else { //search for forgotton id membType string selectMembershipString = "SELECT MEMBERSHIP_ID " + "FROM MEMBERSHIP_TYPE " + "WHERE(DESCRIPTION = 'Forgotton ID') "; command = new SqlCommand(selectMembershipString, connection); int id = 0; try { connection.Open(); SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection); //grabs the id of forgotton id membType while (reader.Read()) { id = int.Parse(reader["MEMBERSHIP_ID"].ToString()); } } catch (Exception ex) { MessageBox.Show("Error: " + ex); } finally { connection.Close(); //set vars for relevant information string userName = Program.currentUser.name; string name = txtName.Text; string phone = txtPhone.Text; //instantiate an object of type LiabilityWaiver called frmLiabilityWaiver LiabilityWaiver frmLiabilityWaiver = new LiabilityWaiver(userName, name, phone, 0, id, "Y", "N", 0); //reset text boxes txtName.Text = ""; txtPhone.Text = ""; //Displays the select membership form in modal format frmLiabilityWaiver.ShowDialog(); txtName.Focus(); } } } }
private void loadLiability() { dataPass.CardNum = 0; LiabilityWaiver frmLiabilityWaiver = new LiabilityWaiver(dataPass.ActiveUser, dataPass.CustomerName, dataPass.CustomerPhone, dataPass.CardNum, dataPass.SelectedMembership, dataPass.NewMemb, dataPass.NeedsSync, dataPass.TransactCost); this.Close(); frmLiabilityWaiver.ShowDialog(); }
private void btnPurchase_Click(object sender, EventArgs e) { //if user is existing member, check textbox for valid integer if (dataPass.NewMemb == "N") { int cardNum; dataPass.NeedsSync = "Y"; if ((int.TryParse(txtCardNum.Text.Trim(), out cardNum)) && cardNum < 10000 && cardNum > 999) { //textBox value is a number and within proper range dataPass.CardNum = cardNum; //If statement that checks whether the user has selected a membership type yet if (memSelected) { LiabilityWaiver frmLiabilityWaiver = new LiabilityWaiver(dataPass.ActiveUser, dataPass.CustomerName, dataPass.CustomerPhone, dataPass.CardNum, dataPass.SelectedMembership, dataPass.NewMemb, dataPass.NeedsSync, dataPass.TransactCost); this.Close(); frmLiabilityWaiver.ShowDialog(); } else { MessageBox.Show("Please select a membership type by clicking one of the boxes"); } } else { //not a number MessageBox.Show("Please enter a valid card number."); } } else //new member { dataPass.CardNum = 0; dataPass.NeedsSync = "N"; //If statement that checks whether the user has selected a membership type yet if (memSelected) { LiabilityWaiver frmLiabilityWaiver = new LiabilityWaiver(dataPass.ActiveUser, dataPass.CustomerName, dataPass.CustomerPhone, dataPass.CardNum, dataPass.SelectedMembership, dataPass.NewMemb, dataPass.NeedsSync, dataPass.TransactCost); this.Close(); frmLiabilityWaiver.ShowDialog(); } else { MessageBox.Show("Please select a membership type by clicking one of the boxes"); } } }