private void btnSignUp_Click(object sender, EventArgs e) { try { Member member = new Member(); member.joindate = DateTime.Now.ToString(); member.firstname = txtFName.Text; member.lastname = txtLName.Text; member.address = txtAddress.Text; member.city = txtCity.Text; member.state = txtState.Text; member.zipcode = txtZipcode.Text; member.phone = maskedTextBox1.Text; member.member_status = "A"; member.login_name = txtUsername.Text; member.password = txtPass.Text; member.email = txtEmail.Text; member.contact_method = "1"; member.subscription_id = "1"; member.photo = ""; MemberDB.AddMember(member); MessageBox.Show("Welcome to Meramec OnLine Movie Kiosk " + member.login_name); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ActionResult Register(RegisterViewModel registerUser) { if (ModelState.IsValid) { if (MemberDB.IsUsernameTaked(registerUser)) { ModelState.AddModelError("UsernameTaken", "Username has been already taken!"); return(View(registerUser)); } Member m = new Member() { Username = registerUser.Username, EmailAddress = registerUser.Email }; MemberDB.AddMember(m); SessionHelper.LogUserIn(m.Username); // redirect to home page return(RedirectToAction("Index", "Home")); } return(View(registerUser)); }
public IActionResult Register(Member mem) { if (ModelState.IsValid) { MemberDB.AddMember(mem, _context); SessionHelper.LogUserIn(mem.MemberId, _accessor); return(RedirectToAction("Index", "Home")); } return(View(mem)); }
private void btnAdd_Click(object sender, EventArgs e) { //Validate the UI //if (string.IsNullOrEmpty(txtNumberber.Text.Trim())) //{ // MessageBox.Show("Please enter a member id."); // txtNumberber.Focus(); // return; //} if (string.IsNullOrEmpty(txtJoinDate.Text.Trim())) { MessageBox.Show("Please enter a member name."); txtJoinDate.Focus(); return; } Member objMember = new Member(); //objMember.number = txtNumber.Text.Trim(); objMember.joindate = txtJoinDate.Text.Trim(); objMember.firstname = txtFirstname.Text.Trim(); objMember.lastname = txtLastname.Text.Trim(); objMember.address = txtAddress.Text.Trim(); objMember.city = txtCity.Text.Trim(); objMember.state = txtState.Text.Trim(); objMember.zipcode = txtZipcode.Text.Trim(); objMember.phone = txtPhone.Text.Trim(); objMember.member_status = GetRadioButtonSelected(gbMemberStatus).Tag.ToString(); objMember.login_name = txtLoginName.Text.Trim(); objMember.password = txtPassword.Text.Trim(); objMember.email = txtEmailAddress.Text.Trim(); objMember.contact_method = GetRadioButtonSelected(gbContactMethod).Tag.ToString(); objMember.subscription_id = ((Subscription)cbSubscription.SelectedItem).ID.ToString(); objMember.photo = Path.GetFileName(pictureBoxPhoto.ImageLocation); try { bool status = MemberDB.AddMember(objMember); SavePhoto(); if (status) //You can use this syntax as well..if (status ==true) { MessageBox.Show("Member added to the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Member was not added to database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (!(validateUI(btnSubmit))) { return; } try { Member newMember = new Member(); newMember.member_status = "A"; int newMemberNumber = 1; bool isValidKey = true; while (isValidKey == true) { Member testMember = MemberDB.GetMember(newMemberNumber); if (testMember == null) { isValidKey = false; } else { newMemberNumber++; } } newMember.member_number = newMemberNumber; newMember.firstname = SignUpForm.newMemberFirstName; newMember.lastname = SignUpForm.newMemberLastName; newMember.email = SignUpForm.newMemberEmail; newMember.cell_phone = SignUpForm.newMemberCellPhone; newMember.zipcode = SignUpForm.newMemberZipCode; newMember.joindate = DateTime.Now; newMember.username = txtUsername.Text.Trim(); newMember.password = txtPassword.Text.Trim(); bool status = MemberDB.AddMember(newMember); if (status) //returns true { MessageBox.Show("Sign Up Successful, Welcome " + newMember.firstname + "!", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); new RentalSearchForm(newMember.member_number).Show(); } else //returns false { MessageBox.Show("Member was not added to the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnAdd_Click(object sender, EventArgs e) { if (!(validateUI(btnAdd))) { return; } try { Member myMember = new Member(); if (radioButton1.Checked) { myMember.member_status = "A"; } if (radioButton2.Checked) { myMember.member_status = "I"; } myMember.member_number = Convert.ToInt32(txtMemberNumber.Text.Trim()); myMember.joindate = Convert.ToDateTime(txtJoinDate.Text.Trim()); myMember.firstname = txtFirstName.Text.Trim(); myMember.lastname = txtLastName.Text.Trim(); myMember.zipcode = txtZipCode.Text.Trim(); myMember.cell_phone = txtCellPhone.Text.Trim(); myMember.username = txtUsername.Text.Trim(); myMember.password = txtPassword.Text.Trim(); myMember.email = txtEmail.Text.Trim(); bool status = MemberDB.AddMember(myMember); if (status) //returns true { MessageBox.Show("Member added to the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); //Automatically refresh the data grid this.btnBrowse_Click(null, null); } else //returns false { MessageBox.Show("Member was not added to the database.", "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Information); //Automatically refresh the data grid this.btnBrowse_Click(null, null); } } catch (Exception ex) { MessageBox.Show(ex.Message, "MeramecNetFlix", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_Add_Click(object sender, EventArgs e) { try { Member newMem = GetMemberObjFromUI(); if (newMem != null) { //check if the username is taken bool memberExists = false; foreach (Member m in MemberDB.GetMembers()) { if (m.login_name.ToLower() == newMem.login_name.ToLower()) //if that login name is in use { memberExists = true; MessageBox.Show("Sorry, but that login name is already in use. Please choose a different one."); break; //break out of the for loop, so we don't spend time looking at each account } } //if the username is not taken, attempt to add the new member to the database if (!memberExists) { if (MemberDB.AddMember(GetMemberObjFromUI())) { MessageBox.Show("Your account has been successfully created. You may now login to your new account"); Close(); } else { MessageBox.Show("Account creation failed. Make sure all information has been entered, and try again. If you continue " + "receiving this error message, please contact technical support."); } } } } catch (Exception ex) { MessageBox.Show("There was a technical error during the operation.\n\nMessage:\n" + ex.Message + "\n\nStack Trace:\n" + ex.StackTrace); } }
private void btn_Add_Click(object sender, EventArgs e) { try { Member m = GetMemberObjFromUI(); if (m != null) { if (MemberDB.AddMember(GetMemberObjFromUI())) { MessageBox.Show("Add Successful."); } else { MessageBox.Show("Add Failed. Make sure all information has been entered."); } } } catch (Exception ex) { MessageBox.Show("There was a technical error during the operation.\n\nMessage:\n" + ex.Message + "\n\nStack Trace:\n" + ex.StackTrace); } }
private void btnAdd_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtMemberNumber.Text.Trim())) { try { List <Member> memberList = new List <Member>(); memberList = MemberDB.GetMembers(); int num = 1; foreach (Member member in memberList) { if (num <= member.memberNumber) { num = member.memberNumber + 1; } } txtMemberNumber.Text = num.ToString(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } foreach (Control control in groupBoxMemberData.Controls) { if (string.IsNullOrEmpty(control.Text.Trim())) { MessageBox.Show("Please enter a value for " + control.Name.ToString()); control.Focus(); return; } } Member objMember = new Member(); objMember.memberNumber = Convert.ToInt32(txtMemberNumber.Text); objMember.joinDate = txtJoinDate.Text; objMember.firstName = txtFirstName.Text; objMember.lastName = txtLastName.Text; objMember.address = txtAddress.Text; objMember.city = txtCity.Text; objMember.state = txtState.Text; objMember.zipcode = Convert.ToInt32(txtZipCode.Text); objMember.phoneNumber = txtPhoneNumber.Text.ToString(); objMember.status = RadioStatus(); objMember.login = txtLogin.Text; objMember.password = txtPassword.Text; objMember.email = txtEmail.Text; objMember.contact_method = ContactMethod(); objMember.subscription_id = 1; objMember.photo = "Photo"; //if(lblPicture.Text != string.Empty) //{ // objMember.photo = lblPicture.Text; //} try { bool status = MemberDB.AddMember(objMember); if (status) //You can use this syntax as well..if (status ==true) { Reload_Data(); MessageBox.Show("Member added to the database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Member was not added to database.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } }