using System; using System.Windows.Forms; namespace CSC330_CSharp_Midterm { public partial class RegistrationMemberForm : Form { public RegistrationMemberForm() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (textBox1.Text != "" && textBox2.Text != "" && textBox5.Text != "") // if main fields are filled { // instantiate an object of the member class Member member = new Member(); member.Name = textBox1.Text; member.DOB = dateTimePicker1.Value.Date; member.Address = textBox2.Text; member.Weight = Convert.ToInt32(numericUpDown1.Value); member.Height = textBox4.Text; member.Goal = textBox3.Text; member.Month = Convert.ToInt32(numericUpDown3.Value); member.Cost = member.Month * 20; member.NumberOfCreditCard = textBox5.Text; string message = Requests.Request("INSERT INTO [Member] ([Name], [DOB], [Address], [Month], [Cost], [Weight], [Height], [Goal], [NumberOfCreditCard]) VALUES ('" + member.Name + "', '" + member.DOB + "', '" + member.Address + "', '" + member.Month + "', '" + member.Cost + "', '" + member.Weight + "', '" + member.Height + "', '" + member.Goal + "', '" + member.NumberOfCreditCard + "')"); // pass the method request to the database. If the method returns an empty string, it means that it worked without errors if (message == "") { MessageBox.Show("Welcome to the Presidential Fitness family! You have been charged $" + member.ShowCost(member), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error during check!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Close(); // close the registration form } else // if main fields are not filled { MessageBox.Show("Fill in all the fields!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } private void dateTimePicker1_ValueChanged(object sender, EventArgs e) { } } }