/// <summary> /// Request from server to check username in the database /// </summary> /// <param name="sender">Check username availability button</param> /// <param name="e">Button_Click</param> private void usernameAvailabilityBtn_Click(object sender, EventArgs e) { usernameTxt.Text = usernameTxt.Text.Trim(); if (usernameTxt.Text == "") { MessageBox.Show("Username property can't be null !", "Information Missing", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } InstanceContext instanceContext = new InstanceContext(this); eShopServiceReference.SignUpServiceClient client = new eShopServiceReference.SignUpServiceClient(instanceContext); client.CheckUsernameAvailability(usernameTxt.Text); client.Close(); }
/// <summary> /// Checks the username and id availability before signing up /// </summary> /// <returns>True - if they are not in use. False otherwise</returns> private bool checkIfValidUsernameAndId() { bool validInformation = true; switch (idAvailablity) { // The id availability was not checked case -1: InstanceContext instanceContext = new InstanceContext(this); eShopServiceReference.SignUpServiceClient client = new eShopServiceReference.SignUpServiceClient(instanceContext); client.CheckIdAvailability(Int32.Parse(idTxt.Text)); // The id is already in use if (idAvailablity == 0) { IdAvailabilityResponse(1); validInformation = false; } break; // The id was checked and already in use case 0: IdAvailabilityResponse(1); validInformation = false; break; } switch (usernameAvailablity) { // The username availability was not checked case -1: InstanceContext instanceContext = new InstanceContext(this); eShopServiceReference.SignUpServiceClient client = new eShopServiceReference.SignUpServiceClient(instanceContext); client.CheckUsernameAvailability(usernameTxt.Text); // The username is already in use if (usernameAvailablity == 0) { UsernameAvailabilityResponse(1); validInformation = false; } break; // The username was checked and already in use case 0: validInformation = false; break; } return(validInformation); }
private void submitBtn_Click(object sender, EventArgs e) { if (!checkIfOnlyNumric()) { return; } if (!checkIfTextBoxesNotNull()) { MessageBox.Show("You need to enter all the information in order to sign up", "Information is missing", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // The information is valid, request sign-up InstanceContext instanceContext = new InstanceContext(this); eShopServiceReference.SignUpServiceClient signUpClient = new eShopServiceReference.SignUpServiceClient(instanceContext); signUpClient.SignUp(usernameTxt.Text, passwordTxt.Text, Int32.Parse(idTxt.Text), fNameTxt.Text, lNameTxt.Text, addressTxt.Text, phoneTxt.Text, Int32.Parse(balanceTxt.Text)); signUpClient.Close(); }