using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CS440_Final_Exam_Gonzalez.RegistrationForm { public partial class regform : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; } protected void MiddleName_TextChanged(object sender, EventArgs e) { } protected void Registration_Choice_SelectedIndexChanged(object sender, EventArgs e) { if (isstudent.SelectedValue == "1") { if (Int32.Parse(Registration_Choice_Student.SelectedValue) != 50) { preconflab.Visible = true; preconf.Visible = true; } else { preconflab.Visible = false; preconf.Visible = false; } } else { if (Int32.Parse(Registration_Choice.SelectedValue) != 50) { preconflab.Visible = true; preconf.Visible = true; } else { preconflab.Visible = false; preconf.Visible = false; } } } protected void isstudent_SelectedIndexChanged(object sender, EventArgs e) { if (Int32.Parse(isstudent.SelectedValue) == 1) { Registration_Choice_Student.Visible = true; Registration_Choice.SelectedIndex = 0; Registration_Choice.Visible = false; preconflab.Visible = true; preconf.Visible = true; } else { Registration_Choice_Student.SelectedIndex = 0; Registration_Choice_Student.Visible = false; Registration_Choice.Visible = true; preconflab.Visible = true; preconf.Visible = true; } } protected void preconf_SelectedIndexChanged(object sender, EventArgs e) { } private Boolean AddOrder() { try { ADODB.Connection objConnect = new ADODB.Connection(); ADODB.Recordset objRS = new ADODB.Recordset(); string strConnection = "Server=csis-sql.elmhurst.edu;Initial Catalog=CS440_Spring2022_Final_Exam;User ID=cs440;Password=Elmhurst1871;Provider=msoledbsql;"; string SQL = "SELECT * FROM [Thomas_Gonzalez]"; objConnect.Open(strConnection); objRS.Open(SQL, objConnect, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic); objRS.AddNew(); objRS.Fields["OrderID"].Value = Guid.NewGuid().ToString(); objRS.Fields["First_Name"].Value = FirstName.Text; objRS.Fields["Middle_name"].Value = MiddleName.Text; objRS.Fields["Last_name"].Value = LastName.Text; objRS.Fields["Phone_number"].Value = PhoneNumber.Text; objRS.Fields["Email"].Value = Email.Text; objRS.Fields["Country"].Value = Country.Text; objRS.Fields["State"].Value = State.Text; objRS.Fields["city"].Value = City.Text; objRS.Fields["address"].Value = Address.Text; objRS.Fields["zip"].Value = ZipCode.Text; if (Int32.Parse(isstudent.SelectedValue) == 1) { if (Int32.Parse(Registration_Choice_Student.SelectedValue) == 50) { objRS.Fields["preconference"].Value = "yes"; } else if (Int32.Parse(preconf.SelectedValue) == 1) { objRS.Fields["preconference"].Value = "yes"; } else { objRS.Fields["preconference"].Value = "no"; } objRS.Fields["regcost"].Value = Registration_Choice_Student.SelectedValue; } else { if (Int32.Parse(Registration_Choice.SelectedValue) == 50) { objRS.Fields["preconference"].Value = "yes"; } else if (Int32.Parse(preconf.SelectedValue) == 1) { objRS.Fields["preconference"].Value = "yes"; } else { objRS.Fields["preconference"].Value = "no"; } objRS.Fields["regcost"].Value = Registration_Choice.SelectedValue; } objRS.Fields["billingcountry"].Value = bill_country.Text; objRS.Fields["billingstate"].Value = bill_state.Text; objRS.Fields["billingcity"].Value = bill_city.Text; objRS.Fields["billingzip"].Value = bill_zip.Text; objRS.Fields["billingaddress"].Value = bill_address.Text; objRS.Fields["DateTmeCreated"].Value = DateTime.Now.ToString(); objRS.Update(); objRS.Close(); objConnect.Close(); objRS = null; objConnect = null; return true; } catch { return false; } } protected void submit_button_Click(object sender, EventArgs e) { if (IsValid) { if (AddOrder() == true) { Response.Redirect("thankyou.aspx"); } else Response.Redirect("errorpage.aspx"); } } protected void billaddresscheck_CheckedChanged(object sender, EventArgs e) { if (billaddresscheck.Checked == true) { bill_country.Text = Country.Text; bill_state.Text = State.Text; bill_city.Text = City.Text; bill_zip.Text = ZipCode.Text; bill_address.Text = Address.Text; bill_country.ReadOnly = true; bill_state.ReadOnly = true; bill_city.ReadOnly = true; bill_zip.ReadOnly = true; bill_address.ReadOnly = true; } else { bill_country.ReadOnly = false; bill_state.ReadOnly = false; bill_city.ReadOnly = false; bill_zip.ReadOnly = false; bill_address.ReadOnly = false; } } protected void bill_country_TextChanged(object sender, EventArgs e) { } } }