public bool OnGUI(GUISkin skin) { var changed = false; if (this.yearsArray == null || this.yearsArray.Length == 0) { var years = new List<string>(); years.Add("Any"); for (int i = 1900; i <= System.DateTime.Now.Year; ++i) { years.Add(i.ToString()); } this.yearsArray = years.ToArray(); } UnityEditor.EditorGUILayout.LabelField("Filter:", UnityEditor.EditorStyles.boldLabel); ME.CalendarGUI.DrawField("Date From", this.dateFrom, (date) => this.dateFrom = date); ME.CalendarGUI.DrawField("Date To", this.dateTo, (date) => this.dateTo = date); this.idFrom = UnityEditor.EditorGUILayout.LongField("User ID From", this.idFrom, skin.textField); this.idTo = UnityEditor.EditorGUILayout.LongField("User ID To", this.idTo, skin.textField); this.gender = (User.Gender)UnityEditor.EditorGUILayout.EnumPopup("Gender", this.gender); this.birthYearFrom = UnityEditor.EditorGUILayout.Popup("Birth Year From", this.birthYearFrom, this.yearsArray); this.birthYearTo = UnityEditor.EditorGUILayout.Popup("Birth Year To", this.birthYearTo, this.yearsArray); changed = GUI.changed; return changed; }
public bool OnGUI(GUISkin skin) { var changed = false; if (this.yearsArray == null || this.yearsArray.Length == 0) { var years = new List <string>(); years.Add("Any"); for (int i = 1900; i <= System.DateTime.Now.Year; ++i) { years.Add(i.ToString()); } this.yearsArray = years.ToArray(); } UnityEditor.EditorGUILayout.LabelField("Filter:", UnityEditor.EditorStyles.boldLabel); ME.CalendarGUI.DrawField("Date From", this.dateFrom, (date) => this.dateFrom = date); ME.CalendarGUI.DrawField("Date To", this.dateTo, (date) => this.dateTo = date); this.idFrom = UnityEditor.EditorGUILayout.LongField("User ID From", this.idFrom, skin.textField); this.idTo = UnityEditor.EditorGUILayout.LongField("User ID To", this.idTo, skin.textField); this.gender = (User.Gender)UnityEditor.EditorGUILayout.EnumPopup("Gender", this.gender); this.birthYearFrom = UnityEditor.EditorGUILayout.Popup("Birth Year From", this.birthYearFrom, this.yearsArray); this.birthYearTo = UnityEditor.EditorGUILayout.Popup("Birth Year To", this.birthYearTo, this.yearsArray); changed = GUI.changed; return(changed); }
public User GetUserById(int userId) { try { string query = "SELECT AccountType, FirstName, LastName, Birthdate, Sex, Email, Address, PostalCode, City, Status, Password " + "FROM [User] " + "WHERE [UserID] = @UserId"; _conn.Open(); SqlDataAdapter cmd = new SqlDataAdapter(); cmd.SelectCommand = new SqlCommand(query, _conn); cmd.SelectCommand.Parameters.Add("@UserId", SqlDbType.Int).Value = userId; DataTable dt = new DataTable(); cmd.Fill(dt); string accountType = dt.Rows[0].ItemArray[0].ToString(); string firstName = dt.Rows[0].ItemArray[1].ToString(); string lastName = dt.Rows[0].ItemArray[2].ToString(); DateTime birthDate = Convert.ToDateTime(dt.Rows[0].ItemArray[3].ToString()); User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), dt.Rows[0].ItemArray[4].ToString()); string email = dt.Rows[0].ItemArray[5].ToString(); string address = dt.Rows[0].ItemArray[6].ToString(); string postalCode = dt.Rows[0].ItemArray[7].ToString(); string city = dt.Rows[0].ItemArray[8].ToString(); bool status = Convert.ToBoolean(dt.Rows[0].ItemArray[9].ToString()); string password = dt.Rows[0].ItemArray[10].ToString(); if (accountType == "CareRecipient") { return(new CareRecipient(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.CareRecipient, password)); } else if (accountType == "Volunteer") { return(new CareRecipient(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.Volunteer, password)); } else if (accountType == "Admin") { return(new CareRecipient(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.Admin, password)); } else if (accountType == "Professional") { return(new Professional(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.Professional, password)); } return(null); } finally { _conn.Close(); } }
User.Gender CheckGender() { bool complete = false; string line; User.Gender gender = User.Gender.Male; while (complete == false) { line = Console.ReadLine(); if (line.ToLower() == "male" || line.ToLower() == "female") { switch (line) { case "male": gender = User.Gender.Male; complete = true; break; case "female": gender = User.Gender.Female; complete = true; break; default: break; } } else { Console.WriteLine("Invalid gender, try again."); Console.Write("Enter gender, and get it right this time: "); } } return(gender); }
public User getCurrentUserInfo(string email) { try { string query = "SELECT UserID, AccountType, FirstName, LastName, Birthdate, Sex, Email, Address, PostalCode, City, Status " + "FROM [User] " + "WHERE Email = @email"; _conn.Open(); SqlParameter emailParam = new SqlParameter(); emailParam.ParameterName = "@email"; SqlCommand cmd = new SqlCommand(query, _conn); emailParam.Value = email; cmd.Parameters.Add(emailParam); User currentUser = new Admin("a", "b", "c,", "d", "e", "f", Convert.ToDateTime("1988/12/20"), User.Gender.M, true, User.AccountType.CareRecipient); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string accountType = reader.GetString(1); User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), reader.GetString(5)); if (accountType == "Admin") { currentUser = new Admin(reader.GetInt32(0), reader.GetString(2), reader.GetString(3), reader.GetString(7), reader.GetString(9), reader.GetString(8), email, reader.GetDateTime(4), gender, reader.GetBoolean(10), User.AccountType.Admin); } else if (accountType == "Professional") { currentUser = new Professional(reader.GetInt32(0), reader.GetString(2), reader.GetString(3), reader.GetString(7), reader.GetString(9), reader.GetString(8), email, reader.GetDateTime(4), gender, reader.GetBoolean(10), User.AccountType.Professional); } else if (accountType == "Volunteer") { currentUser = new Volunteer(reader.GetInt32(0), reader.GetString(2), reader.GetString(3), reader.GetString(7), reader.GetString(9), reader.GetString(8), email, reader.GetDateTime(4), gender, reader.GetBoolean(10), User.AccountType.Volunteer); } else { currentUser = new CareRecipient(reader.GetInt32(0), reader.GetString(2), reader.GetString(3), reader.GetString(7), reader.GetString(9), reader.GetString(8), email, reader.GetDateTime(4), gender, reader.GetBoolean(10), User.AccountType.CareRecipient); } return(currentUser); } return(currentUser); } } catch (Exception e) { Console.WriteLine(e); throw; } finally { _conn.Close(); } }
public async Task <User> CreateUserAsync(string email, string password, User.Gender gender) { db.User.Add(new User { Email = email, Password = password, UserGender = gender }); await db.SaveChangesAsync(); return(await db.User.SingleAsync(x => x.Email == email)); }
public List <User> GetAllUsers() { string query = "SELECT UserID, AccountType, FirstName, LastName, Birthdate, Sex, Email, Address, PostalCode, City, Status " + "FROM [User]"; _conn.Open(); SqlCommand cmd = new SqlCommand(query, _conn); List <User> Users = new List <User>(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int userID = reader.GetInt32(0); string accountType = reader.GetString(1); string firstName = reader.GetString(2); string lastName = reader.GetString(3); DateTime birthDate = reader.GetDateTime(4); User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), reader.GetString(5)); string email = reader.GetString(6); string address = reader.GetString(7); string postalCode = reader.GetString(8); string city = reader.GetString(9); bool status = reader.GetBoolean(10); if (accountType == "CareRecipient") { User user = new CareRecipient(userID, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.CareRecipient); Users.Add(user); } else if (accountType == "Volunteer") { User user = new CareRecipient(userID, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.Volunteer); Users.Add(user); } else { User user = new CareRecipient(userID, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.Admin); Users.Add(user); } } } _conn.Close(); return(Users); }
public List <User> GetAllProfessionals() { try { List <User> professionalList = new List <User>(); SqlCommand cmd = new SqlCommand("SelectAllProfessionals", _conn); cmd.CommandType = CommandType.StoredProcedure; _conn.Open(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); foreach (DataRow dr in dt.Rows) { int userId = Convert.ToInt32(dr["UserID"]); string accountType = dr["AccountType"].ToString(); string firstName = dr["FirstName"].ToString(); string lastName = dr["LastName"].ToString(); DateTime birthDate = Convert.ToDateTime(dr["Birthdate"].ToString()); User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), dr["Sex"].ToString()); string email = dr["Email"].ToString(); string address = dr["Address"].ToString(); string postalCode = dr["PostalCode"].ToString(); string city = dr["City"].ToString(); bool status = Convert.ToBoolean(dr["Status"].ToString()); string password = dr["Password"].ToString(); User user = new Professional(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.Professional, password); professionalList.Add(user); } return(professionalList); } catch (Exception) { return(null); } finally { _conn.Close(); } }
private void btnAddUser_Click(object sender, EventArgs e) { if (tbPassword.Text != tbPassValidation.Text) { MessageBox.Show("Wachtwoord komt niet overeen!"); } else { if (UserLogic.CheckIfUserAlreadyExists(tbEmail.Text)) { if (UserLogic.IsEmailValid(tbEmail.Text)) { string accountType = "CareRecipient"; if (rbtnVolunteer.Checked) { accountType = "Volunteer"; } else if (rbtnCareRecipient.Checked) { accountType = "CareRecipient"; } User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), cboxSex.Text); UserLogic.AddNewUser(tbFirstName.Text, tbLastName.Text, dateOfBirth.Value, gender, tbEmail.Text, tbAddress.Text, tbPostalCode.Text, tbCity.Text, tbPassword.Text, accountType); ((MainForm)this.Parent.Parent).ReplaceForm(new LoginPrototype()); } else { MessageBox.Show("Email is verkeerd!"); } } else { MessageBox.Show("Gebruiker bestaat al!"); } } }
public override IEnumerator SetUserGender(User.Gender gender) { UnityEngine.Analytics.Gender output = UnityEngine.Analytics.Gender.Unknown; switch (gender) { case User.Gender.Female: output = UnityEngine.Analytics.Gender.Female; break; case User.Gender.Male: output = UnityEngine.Analytics.Gender.Male; break; case User.Gender.Any: output = UnityEngine.Analytics.Gender.Unknown; break; } UnityEngine.Analytics.Analytics.SetUserGender(output); yield return(false); }
private void btnSave_Click(object sender, EventArgs e) { User editUser = new Classes.CareRecipient("a", "b", "c,", "d", "e", "f", Convert.ToDateTime("1988/12/20"), User.Gender.M, true, User.AccountType.CareRecipient); string firstname = tbFirstName.Text; string lastname = tbLastName.Text; string address = tbAddress.Text; string city = tbCity.Text; string postalCode = tbPostalCode.Text; string email = tbEmail.Text; DateTime birthdate = dateOfBirth.Value; User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), cboxSex.Text); string password = tbPassword.Text; string passwordValidate = tbPassValidation.Text; if (LoginPrototype.currentUser.UserAccountType == User.AccountType.CareRecipient) { editUser = new Classes.CareRecipient(firstname, lastname, address, city, postalCode, email, birthdate, gender, true, User.AccountType.CareRecipient); } else if (LoginPrototype.currentUser.UserAccountType == User.AccountType.Volunteer) { editUser = new Classes.Volunteer(firstname, lastname, address, city, postalCode, email, birthdate, gender, true, User.AccountType.Volunteer); } if (password == passwordValidate) { UserLogic.EditUser(editUser, password); } else { MessageBox.Show("Het wachtwoord komt niet overeen"); return; } btnSave.Visible = false; }
public User CheckValidityUser(string emailAdress, string password) { try { string query = "SELECT UserID, AccountType, FirstName, LastName, Birthdate, Sex, Address, PostalCode, City, Status, Password " + "FROM [User] " + "WHERE [Email] = @Email"; _conn.Open(); SqlDataAdapter cmd = new SqlDataAdapter(); cmd.SelectCommand = new SqlCommand(query, _conn); cmd.SelectCommand.Parameters.Add("@Email", SqlDbType.VarChar).Value = emailAdress; cmd.SelectCommand.Parameters.Add("@Password", SqlDbType.VarChar).Value = password; DataTable dt = new DataTable(); cmd.Fill(dt); int userId = Convert.ToInt32(dt.Rows[0].ItemArray[0]); string accountType = dt.Rows[0].ItemArray[1].ToString(); string firstName = dt.Rows[0].ItemArray[2].ToString(); string lastName = dt.Rows[0].ItemArray[3].ToString(); DateTime birthDate = Convert.ToDateTime(dt.Rows[0].ItemArray[4]); User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), dt.Rows[0].ItemArray[5].ToString()); string address = dt.Rows[0].ItemArray[6].ToString(); string postalCode = dt.Rows[0].ItemArray[7].ToString(); string city = dt.Rows[0].ItemArray[8].ToString(); bool status = Convert.ToBoolean(dt.Rows[0].ItemArray[9]); string hashedPassword = dt.Rows[0].ItemArray[10].ToString(); if (!Hasher.SecurePasswordHasher.Verify(password, hashedPassword)) { throw new ArgumentException("Password invalid"); } switch (accountType) { case "CareRecipient": return(new CareRecipient(userId, firstName, lastName, address, city, postalCode, emailAdress, birthDate, gender, status, User.AccountType.CareRecipient, hashedPassword)); case "Volunteer": return(new CareRecipient(userId, firstName, lastName, address, city, postalCode, emailAdress, birthDate, gender, status, User.AccountType.Volunteer, hashedPassword)); case "Admin": return(new CareRecipient(userId, firstName, lastName, address, city, postalCode, emailAdress, birthDate, gender, status, User.AccountType.Admin, hashedPassword)); case "Professional": return(new Professional(userId, firstName, lastName, address, city, postalCode, emailAdress, birthDate, gender, status, User.AccountType.Professional, hashedPassword)); default: throw new AggregateException("User not found"); } } catch (Exception) { throw new ArgumentException("User cannot be checked"); } finally { _conn.Close(); } }
public List <User> GetAllUsers() { try { string query = "SELECT DISTINCT UserID, AccountType, FirstName, LastName, Birthdate, Sex, Email, Address, PostalCode, City, Status, Password, CP.ProfessionalID" + " FROM[User] U" + " LEFT JOIN CareRecipientProfessional CP ON CP.CareRecipientID = U.UserID "; _conn.Open(); SqlCommand cmd = new SqlCommand(query, _conn); List <User> users = new List <User>(); DataTable dt = new DataTable(); dt.Load(cmd.ExecuteReader()); _conn.Close(); foreach (DataRow dr in dt.Rows) { int userId = Convert.ToInt32(dr["UserID"]); string accountType = dr["AccountType"].ToString(); string firstName = dr["FirstName"].ToString(); string lastName = dr["LastName"].ToString(); DateTime birthDate = Convert.ToDateTime(dr["Birthdate"].ToString()); User.Gender gender = (User.Gender)Enum.Parse(typeof(User.Gender), dr["Sex"].ToString()); string email = dr["Email"].ToString(); string address = dr["Address"].ToString(); string postalCode = dr["PostalCode"].ToString(); string city = dr["City"].ToString(); bool status = Convert.ToBoolean(dr["Status"].ToString()); string password = dr["Password"].ToString(); int professionalId = 0; if (dr["ProfessionalID"] != DBNull.Value) { professionalId = Int32.Parse((dr["ProfessionalID"]).ToString()); } if (accountType == "CareRecipient") { if (professionalId != 0) { User professional = GetUserById(professionalId); User user = new CareRecipient(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.CareRecipient, password, professional); users.Add(user); } else { User user = new CareRecipient(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.CareRecipient, password); users.Add(user); } } else if (accountType == "Volunteer") { User user = new CareRecipient(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.Volunteer, password); users.Add(user); } else { User user = new CareRecipient(userId, firstName, lastName, address, city, postalCode, email, birthDate, gender, status, User.AccountType.Admin, password); users.Add(user); } } return(users); } catch (SqlException e) { Console.WriteLine(e); throw; } }
public override IEnumerator SetUserGender(User.Gender gender) { return(SetUserData(new StatSetUserGender(gender.ToString()))); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.LoginSignupLoL); TextView header = FindViewById<TextView>(Resource.Id.txtFirstScreenHeader); Header.headertext = Application.Context.Resources.GetString(Resource.String.createTitle); context = header.Context; Header.fontsize = 36f; ImageHelper.fontSizeInfo(context); header.SetTextSize(Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; q1 = q2 = q3 = false; AndroidData.imageFileName = ""; firstName = FindViewById<EditText>(Resource.Id.editFirst); lastName = FindViewById<EditText>(Resource.Id.editSurname); username = FindViewById<EditText>(Resource.Id.editUsername); description = FindViewById<EditText>(Resource.Id.editDescribe); password = FindViewById<EditText>(Resource.Id.editPassword); verify = FindViewById<EditText>(Resource.Id.editPasswordVerify); email = FindViewById<EditText>(Resource.Id.editEmail); int y = DateTime.Now.Year; int m = DateTime.Now.Month; int d = DateTime.Now.Day; Spinner month = FindViewById<Spinner>(Resource.Id.spinMonth); Spinner day = FindViewById<Spinner>(Resource.Id.spinDate); Spinner year = FindViewById<Spinner>(Resource.Id.spinYear); var adapterM = ArrayAdapter.CreateFromResource(this, Resource.Array.createMonths, Android.Resource.Layout.SimpleSpinnerItem); adapterM.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); month.Adapter = adapterM; month.SetSelection(m - 1); month.ItemSelected += (sender, e) => { m = month.SelectedItemPosition + 1; }; List<string> dates = new List<string>(); List<string> years = new List<string>(); for (int n = 1; n < 32; ++n) dates.Add(n.ToString()); for (int n = 0; n < 75; ++n) years.Add((y - 75 + n).ToString()); var yearsAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, years); yearsAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); year.Adapter = yearsAdapter; year.SetSelection(54); y -= 21; var daysAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, dates); daysAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); day.Adapter = daysAdapter; day.SetSelection(d - 1); day.ItemSelected += (sender, e) => { string dd = (string)day.GetItemAtPosition(e.Position); d = Convert.ToInt32(dd); }; year.ItemSelected += (sender, e) => { string yy = (string)year.GetItemAtPosition(e.Position); y = Convert.ToInt32(yy); }; register = FindViewById<Button>(Resource.Id.btnRegister); register.Enabled = false; takePic = FindViewById<Button>(Resource.Id.btnTakePic); choosePic = FindViewById<Button>(Resource.Id.btnChoosePic); picture = FindViewById<ImageView>(Resource.Id.imageView1); password.TextChanged += delegate { register.Enabled = password.Text == verify.Text ? true : false; }; verify.TextChanged += delegate { register.Enabled = password.Text == verify.Text ? true : false; }; gender = User.Gender.Unknown; ImageView female = FindViewById<ImageView>(Resource.Id.imgGenderFemale); female.Click += delegate { gender = User.Gender.Female; }; ImageView male = FindViewById<ImageView>(Resource.Id.imgGenderMale); male.Click += delegate { gender = User.Gender.Male; }; ImageView alien = FindViewById<ImageView>(Resource.Id.imgGenderAlien); alien.Click += delegate { gender = User.Gender.Alien; }; ImageView monster = FindViewById<ImageView>(Resource.Id.imgGenderMonster); monster.Click += delegate { gender = User.Gender.Monster; }; ImageView other = FindViewById<ImageView>(Resource.Id.imgGenderDunno); other.Click += delegate { gender = User.Gender.Unknown; }; CheckBox quest1 = FindViewById<CheckBox>(Resource.Id.checkQ1); quest1.Click += delegate { q1 = !q1; }; CheckBox quest2 = FindViewById<CheckBox>(Resource.Id.checkQ2); quest2.Click += delegate { q2 = !q2; }; CheckBox quest3 = FindViewById<CheckBox>(Resource.Id.checkQ3); quest3.Click += delegate { q3 = !q3; }; ImageButton rotateLeft = FindViewById<ImageButton>(Resource.Id.imgRotateLeft); ImageButton rotateRight = FindViewById<ImageButton>(Resource.Id.imgRotateRight); rotateLeft.Click += delegate { if (!string.IsNullOrEmpty(AndroidData.imageFileName)) picture.SetImageBitmap(ImageHelper.rotateImage(true)); }; rotateRight.Click += delegate { if (!string.IsNullOrEmpty(AndroidData.imageFileName)) picture.SetImageBitmap(ImageHelper.rotateImage()); }; bool[] camTest = new bool[2]; camTest = GeneralUtils.CamRec(); if (camTest [0] == false || camTest [1] == false) { takePic.Visibility = Android.Views.ViewStates.Invisible; choosePic.Visibility = Android.Views.ViewStates.Invisible; } takePic.Click += delegate(object s, EventArgs e) { Intent i = new Intent(this, typeof(CameraVideo.CameraTakePictureActivity)); i.PutExtra("camera", CAMMY); StartActivityForResult(i, CAMMY); }; choosePic.Click += delegate(object s, EventArgs e) { var imageIntent = new Intent(); imageIntent.SetType("image/*"); imageIntent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(imageIntent, "Choose Image"), PICCY); }; register.Click += delegate(object s, EventArgs e) { DisableAll(); dob = new DateTime(y, m, d); createUser(s, e); }; location = new double[2]; if (q1 && q2) { geocoder = new Geocoder(this); var locationManager = (LocationManager)GetSystemService(LocationService); var criteria = new Criteria(); criteria.Accuracy = Accuracy.NoRequirement; criteria.PowerRequirement = Power.NoRequirement; string bestProvider = locationManager.GetBestProvider(criteria, true); Location lastKnownLocation = locationManager.GetLastKnownLocation(bestProvider); if (lastKnownLocation != null) { location [0] = lastKnownLocation.Latitude; location [1] = lastKnownLocation.Longitude; } AndroidData.GeoLocationEnabled = true; } else { location [0] = location [1] = -999; AndroidData.GeoLocationEnabled = false; } }
//open Account public void CreateAccount() { try { List <String> arr = new List <string>(); Console.WriteLine("Enter You Name :"); arr.Add(Console.ReadLine()); Console.WriteLine("Enter You Email :"); arr.Add(Console.ReadLine()); Console.WriteLine("Enter You Date Of Birth :"); arr.Add(Console.ReadLine()); Console.WriteLine("Enter You Gender :"); arr.Add(Console.ReadLine()); Console.WriteLine("Enter Balance to Open Your Account with :"); arr.Add(Console.ReadLine()); //to check if the input is valid or not bool validNamee = checkvalidtyName(arr[0]); bool validEmail = CheckValidtyEmail(arr[1]); bool validAge = checkedValidtyAge(Convert.ToDateTime(arr[2])); bool validGender = CheckValidityGender(arr[3]); bool validBalance = CheckValidityBalance(Convert.ToDouble(arr[4])); if (validNamee && validEmail && validAge && validGender && validBalance) { User userobject = new User(); userobject.Name = arr[0].ToString(); userobject.Email = arr[1].ToString(); userobject.DOB = Convert.ToDateTime(arr[2]); userobject.Age = CalculateAge(userobject.DOB); User.Gender genderEnum = new User.Gender(); if (arr[3] == "") { Console.BackgroundColor = ConsoleColor.Red; String alert = "ERROR IN GENDER ! You didn't type your gender ! you should type it \n"; track.Append(alert); Console.ResetColor(); } else if (arr[3] == "M" || arr[3] == "m" || arr[3] == "male" || arr[3] == "MALE") { genderEnum = User.Gender.Male; userobject.gender = genderEnum; } else if (arr[3] == "F" || arr[3] == "f" || arr[3] == "female" || arr[3] == "FEMALE") { genderEnum = User.Gender.Female; userobject.gender = genderEnum; } else { Console.BackgroundColor = ConsoleColor.Red; String alert = "ERROR IN Gender !Your Gender should be : male/female or you can just type f or m ...! \n "; track.Append(alert); Console.ResetColor(); } Guid id = Guid.NewGuid(); userobject.account.AccountId = id; userobject.account.Balance = Convert.ToDouble(arr[4]); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Account has been created Successfuly and your Id is: {0}", userobject.account.AccountId); Console.ResetColor(); users.Add(userobject); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(" Mistakes in Your input Are :\n"); Console.WriteLine(track); Console.WriteLine("Correct Them Kindly !!"); Console.ResetColor(); if (!validNamee) { Console.WriteLine("Your Name Again:"); String name = Console.ReadLine(); bool yes = checkvalidtyName(name); while (!yes) { Console.WriteLine("Not Correct again ! type your name :"); String name1 = Console.ReadLine(); if (checkvalidtyName(name1)) { yes = !yes; } else { continue; } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Name Has been edited Successfully"); Console.ResetColor(); } if (!validEmail) { Console.WriteLine("Your Email Again :"); String email = Console.ReadLine(); bool yes = CheckValidtyEmail(email); while (!yes) { Console.WriteLine("Not Correct again ! type your email :"); String name1 = Console.ReadLine(); if (CheckValidtyEmail(name1)) { yes = !yes; } else { continue; } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Email Has been edited Successfully"); Console.ResetColor(); } if (!validGender) { Console.WriteLine("Your GENDER Again :"); String gender = Console.ReadLine(); bool yes = CheckValidityGender(gender); while (!yes) { Console.WriteLine("Not Correct again ! type your gender :"); String name1 = Console.ReadLine(); if (CheckValidityGender(name1)) { yes = !yes; } else { continue; } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Gender Has been edited Successfully"); Console.ResetColor(); } //else { } if (!validAge) { Console.WriteLine("Your DOB Again :"); DateTime date = Convert.ToDateTime(Console.ReadLine()); bool yes = checkedValidtyAge(date); while (!yes) { Console.WriteLine("Not Correct again ! type your Date Of Birth :"); DateTime date1 = Convert.ToDateTime(Console.ReadLine()); if (checkedValidtyAge(date1)) { yes = !yes; } else { continue; } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Date Of Birth Has been edited Successfully"); Console.ResetColor(); } //else { } if (!validBalance) { Console.WriteLine("Your Balance Again :"); double balance = Convert.ToDouble(Console.ReadLine()); bool yes = CheckValidityBalance(balance); while (!yes) { Console.WriteLine("Not Correct again ! type Balance more than 2000 :"); String name1 = Console.ReadLine(); if (checkvalidtyName(name1)) { yes = !yes; } else { continue; } } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Your Balance Has been edited Successfully"); Console.ResetColor(); } } } catch (Exception e) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("sth wrong"); Console.ResetColor(); } }
public static void SetUserGender(User.Gender gender) { Analytics.ForEachService <IAnalyticsService>(s => Analytics.instance.StartCoroutine(s.SetUserGender(gender))); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.AboutMe); string currentUserName = AndroidData.CurrentUser.FirstName + " " + AndroidData.CurrentUser.LastName; genders = new string[] { "Unknown", "Male", "Female", "Alien", "Monster" }; int d = 1, m = 1, yr = 1901; currentGender = AndroidData.CurrentUser.UserGender; ImageView btns = FindViewById<ImageView>(Resource.Id.imgNewLoginHeader); TextView header = FindViewById<TextView>(Resource.Id.txtFirstScreenHeader); context = header.Context; RelativeLayout relLayout = FindViewById<RelativeLayout>(Resource.Id.relativeLayout1); ImageHelper.setupTopPanel(btns, header, relLayout, context); Header.headertext = Application.Context.Resources.GetString(Resource.String.mainTitle); Header.fontsize = 36f; ImageHelper.fontSizeInfo(header.Context); header.SetTextSize(Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; ImageView myPic = FindViewById<ImageView>(Resource.Id.imgMe); if (AndroidData.CurrentUser.Picture.Length == 0) myPic.SetBackgroundResource(Resource.Drawable.defaultuserimage); else MD5Check = generateMD5(); fullName = FindViewById<TextView>(Resource.Id.txtFullName); fullName.Text = currentUserName; screenName = FindViewById<TextView>(Resource.Id.txtScreenName); screenName.Text = AndroidData.CurrentUser.UserName; emailAddress = FindViewById<TextView>(Resource.Id.txtEmail); emailAddress.Text = AndroidData.CurrentUser.EmailAddress; gender = FindViewById<TextView>(Resource.Id.txtGender); switch (currentGender) { case User.Gender.Alien: gender.Text = genders [3]; break; case User.Gender.Female: gender.Text = genders [2]; break; case User.Gender.Male: gender.Text = genders [1]; break; case User.Gender.Monster: gender.Text = genders [4]; break; case User.Gender.Unknown: gender.Text = genders [0]; break; } password = FindViewById<TextView>(Resource.Id.txtPassword); string pw = ""; for (int n = 0; n < AndroidData.CurrentUser.Password.Length; ++n) pw += "*"; password.Text = pw; birthday = FindViewById<TextView>(Resource.Id.txtDOB); birthday.Text = AndroidData.CurrentUser.DateOfBirth.ToShortDateString(); profDesc = FindViewById<TextView>(Resource.Id.txtProfile); profDesc.Text = AndroidData.CurrentUser.Description; CheckBox quest1 = FindViewById<CheckBox>(Resource.Id.checkedProQ1); quest1.Checked = AndroidData.CurrentUser.AllowLocationSearch; CheckBox quest2 = FindViewById<CheckBox>(Resource.Id.checkedProQ2); quest2.Checked = AndroidData.CurrentUser.ShowLocation; CheckBox quest3 = FindViewById<CheckBox>(Resource.Id.checkedProQ3); quest3.Checked = AndroidData.CurrentUser.AllowSearch; Button btnPicChange = FindViewById<Button>(Resource.Id.btnPicChange); Button btnChangeName = FindViewById<Button>(Resource.Id.btnChangeName); Button btnScreenName = FindViewById<Button>(Resource.Id.btnScreenName); Button btnEmail = FindViewById<Button>(Resource.Id.btnEmail); Button btnGender = FindViewById<Button>(Resource.Id.btnGender); Button btnPassword = FindViewById<Button>(Resource.Id.btnPassword); Button btnDOB = FindViewById<Button>(Resource.Id.btnDOB); Button btnProfDesc = FindViewById<Button>(Resource.Id.btnProfDesc); Button btnCancel = FindViewById<Button>(Resource.Id.btnCancel); Button btnOK = FindViewById<Button>(Resource.Id.btnAccept); ImageButton btnBack = FindViewById<ImageButton>(Resource.Id.btnBack); btnPicChange.Click += delegate { generateModal(0); }; btnChangeName.Click += delegate { generateModal(1); }; btnScreenName.Click += delegate { generateModal(2); }; btnEmail.Click += delegate { generateModal(3); }; btnGender.Click += delegate { generateModal(4); }; btnPassword.Click += delegate { generateModal(5); }; btnDOB.Click += delegate { generateModal(6); }; btnProfDesc.Click += delegate { generateModal(7); }; btnCancel.Click += delegate { Finish(); }; btnBack.Click += delegate { Intent i = new Intent(this, typeof(Main.HomeActivity)); i.AddFlags(ActivityFlags.ClearTop); StartActivity(i); }; btnOK.Click += delegate { if (checkText(fullName.Text, screenName.Text, emailAddress.Text, password.Text, profDesc.Text)) { string[] nameSplit = new string[2]; if (fullName.Text != currentUserName) { nameSplit = fullName.Text.Split(' '); AndroidData.CurrentUser.FirstName = nameSplit [0]; AndroidData.CurrentUser.LastName = nameSplit [1]; essentialHasAltered = true; } if (screenName.Text != AndroidData.CurrentUser.UserName) { AndroidData.CurrentUser.UserName = screenName.Text; nonessesentialHasAltered = true; } if (emailAddress.Text != AndroidData.CurrentUser.EmailAddress) { AndroidData.CurrentUser.EmailAddress = emailAddress.Text; essentialHasAltered = true; } if (password.Text != AndroidData.CurrentUser.Password) { AndroidData.CurrentUser.Password = password.Text; essentialHasAltered = true; } if (profDesc.Text != AndroidData.CurrentUser.Description) { AndroidData.CurrentUser.Description = profDesc.Text; nonessesentialHasAltered = true; } if (birthday.Text != AndroidData.CurrentUser.DateOfBirth.ToString()) { string[] splitter = new string[3]; splitter = birthday.Text.Split('/'); d = Convert.ToInt32(splitter [0]); m = Convert.ToInt32(splitter [1]); yr = Convert.ToInt32(splitter [2]); nonessesentialHasAltered = true; } if (quest1.Checked != AndroidData.CurrentUser.ShowLocation) { AndroidData.CurrentUser.ShowLocation = quest1.Checked; nonessesentialHasAltered = true; } if (quest2.Checked != AndroidData.CurrentUser.AllowLocationSearch) { AndroidData.CurrentUser.AllowLocationSearch = quest2.Checked; nonessesentialHasAltered = true; } if (quest3.Checked != AndroidData.CurrentUser.AllowSearch) { AndroidData.CurrentUser.AllowSearch = quest3.Checked; nonessesentialHasAltered = true; } if (quest1.Checked && quest2.Checked) AndroidData.GeoLocationEnabled = true; else AndroidData.GeoLocationEnabled = false; if (imageChanged) { imageHasAltered = true; } switch (gender.Text) { case "Unknown": AndroidData.CurrentUser.UserGender = User.Gender.Unknown; break; case "Male": AndroidData.CurrentUser.UserGender = User.Gender.Male; break; case "Female": AndroidData.CurrentUser.UserGender = User.Gender.Female; break; case "Alien": AndroidData.CurrentUser.UserGender = User.Gender.Alien; break; case "Monster": AndroidData.CurrentUser.UserGender = User.Gender.Monster; break; } if (essentialHasAltered || imageHasAltered || nonessesentialHasAltered) { LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint); if (essentialHasAltered) { service.UserUpdateCompulsoryDetailsCompleted += Service_UpdateCompulsoryCompleted; service.UserUpdateCompulsoryDetailsAsync(AndroidData.CurrentUser.AccountID, AndroidData.CurrentUser.FirstName, AndroidData.CurrentUser.LastName, AndroidData.CurrentUser.EmailAddress, password.Text, AndroidData.CurrentUser.AccountID, new Guid(AndroidData.ServiceAuthToken)); } if (imageHasAltered) { byte[] myNewPic = File.ReadAllBytes(AndroidData.imageFileName); service.UserUpdateImageCompleted += Service_UpdateImageCompleted; service.UserUpdateImageAsync(AndroidData.CurrentUser.AccountID, myNewPic, new Guid(AndroidData.ServiceAuthToken)); } if (nonessesentialHasAltered) { DateTime t = new DateTime(yr, m, d); service.UserUpdateRestDetailsCompleted += Service_UpdateRestCompleted; service.UserUpdateRestDetailsAsync(AndroidData.CurrentUser.AccountID, t, screenName.Text, profDesc.Text, AndroidData.CurrentUser.ShowLocation, AndroidData.CurrentUser.AllowLocationSearch, AndroidData.CurrentUser.AllowSearch, AndroidData.CurrentUser.UserGender, new Guid(AndroidData.ServiceAuthToken) ); } } } }; }
public static void AddNewUser(string firstName, string lastName, DateTime birthDate, User.Gender gender, string email, string address, string postalCode, string city, string password, string accountType) { if (accountType == "Volunteer") { Volunteer currentUser = new Volunteer(firstName, lastName, address, city, postalCode, address, birthDate, gender, true, User.AccountType.Volunteer); } else if (accountType == "Admin") { Admin currentUser = new Admin(firstName, lastName, address, city, postalCode, address, birthDate, gender, true, User.AccountType.Admin); } else if (accountType == "CareRecipient") { CareRecipient currentUser = new CareRecipient(firstName, lastName, address, city, postalCode, address, birthDate, gender, true, User.AccountType.CareRecipient); } else if (accountType == "Professional") { Professional currentUser = new Professional(firstName, lastName, address, city, postalCode, address, birthDate, gender, true, User.AccountType.Professional); } string genderString = gender.ToString(); userRepo.AddNewUser(firstName, lastName, birthDate, genderString, email, address, postalCode, city, password, accountType); }
public virtual IEnumerator SetUserGender(User.Gender gender) { yield return(false); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.LoginSignupLoLS2); TextView header = FindViewById<TextView>(Resource.Id.txtFirstScreenHeader); Header.headertext = Application.Context.Resources.GetString(Resource.String.createTitle); context = header.Context; Header.fontsize = 36f; ImageHelper.fontSizeInfo(context); header.SetTextSize(Android.Util.ComplexUnitType.Dip, Header.fontsize); header.Text = Header.headertext; username = base.Intent.Extras.GetString("username"); email = base.Intent.Extras.GetString("email"); password = base.Intent.Extras.GetString("password"); image = base.Intent.Extras.GetByteArray("image"); int y = DateTime.Now.Year; int m = DateTime.Now.Month; int d = DateTime.Now.Day; Spinner month = FindViewById<Spinner>(Resource.Id.spinMonth); Spinner day = FindViewById<Spinner>(Resource.Id.spinDate); Spinner year = FindViewById<Spinner>(Resource.Id.spinYear); var adapterM = ArrayAdapter.CreateFromResource(this, Resource.Array.createMonths, Android.Resource.Layout.SimpleSpinnerItem); adapterM.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); month.Adapter = adapterM; month.SetSelection(m - 1); month.ItemSelected += (sender, e) => { m = month.SelectedItemPosition + 1; }; List<string> dates = new List<string>(); List<string> years = new List<string>(); for (int n = 1; n < 32; ++n) dates.Add(n.ToString()); for (int n = 0; n < 75; ++n) years.Add((y - 75 + n).ToString()); var yearsAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, years); yearsAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); year.Adapter = yearsAdapter; year.SetSelection(54); y -= 21; var daysAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerItem, dates); daysAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); day.Adapter = daysAdapter; day.SetSelection(d - 1); day.ItemSelected += (sender, e) => { string dd = (string)day.GetItemAtPosition(e.Position); d = Convert.ToInt32(dd); }; year.ItemSelected += (sender, e) => { string yy = (string)year.GetItemAtPosition(e.Position); y = Convert.ToInt32(yy); }; Button register = FindViewById<Button>(Resource.Id.btnRegister); ImageView back = FindViewById<ImageView>(Resource.Id.imgBack); ImageView female = FindViewById<ImageView>(Resource.Id.imageGenderFemale); female.Click += delegate { gender = User.Gender.Female; }; ImageView male = FindViewById<ImageView>(Resource.Id.imageGenderMale); male.Click += delegate { gender = User.Gender.Male; }; ImageView alien = FindViewById<ImageView>(Resource.Id.imageGenderAlien); alien.Click += delegate { gender = User.Gender.Alien; }; ImageView monster = FindViewById<ImageView>(Resource.Id.imageGenderMonster); monster.Click += delegate { gender = User.Gender.Monster; }; ImageView other = FindViewById<ImageView>(Resource.Id.imageGenderOther); other.Click += delegate { gender = User.Gender.Unknown; }; q1 = q2 = q3 = false; CheckBox quest1 = FindViewById<CheckBox>(Resource.Id.checkQuest1); quest1.Click += delegate { q1 = !q1; }; CheckBox quest2 = FindViewById<CheckBox>(Resource.Id.checkQuest2); quest2.Click += delegate { q2 = !q2; }; CheckBox quest3 = FindViewById<CheckBox>(Resource.Id.checkQuest3); quest3.Click += delegate { q3 = !q3; }; EditText firstname = FindViewById<EditText>(Resource.Id.editFirstName); EditText lastname = FindViewById<EditText>(Resource.Id.editSurname); EditText description = FindViewById<EditText>(Resource.Id.editDescription); back.Click += delegate { Intent i = new Intent(); i.PutExtra("email", email); i.PutExtra("password", password); i.PutExtra("username", username); i.PutExtra("image", image); SetResult(Result.Ok, i); Finish(); }; register.Click += delegate { if (!string.IsNullOrEmpty(firstname.Text)) { describe = description.Text; first = firstname.Text; if (string.IsNullOrEmpty(lastname.Text)) last = "null"; else last = lastname.Text; dob = new DateTime(y, m, d); createUser(); } else RunOnUiThread(() => GeneralUtils.Alert(context, Application.Context.GetString(Resource.String.errorCreateTitle), Application.Context.GetString(Resource.String.errorCreateNoFirst))); }; location = new double[2]; if (q1 && q2) { var locationManager = (LocationManager)GetSystemService(LocationService); var criteria = new Criteria(); criteria.Accuracy = Accuracy.Coarse; criteria.PowerRequirement = Power.NoRequirement; string bestProvider = locationManager.GetBestProvider(criteria, true); Location lastKnownLocation = locationManager.GetLastKnownLocation(bestProvider); if (lastKnownLocation != null) { location [0] = lastKnownLocation.Latitude; location [1] = lastKnownLocation.Longitude; } AndroidData.GeoLocationEnabled = true; } else { location [0] = location [1] = -999; AndroidData.GeoLocationEnabled = false; } LinearLayout bottom = FindViewById<LinearLayout>(Resource.Id.bottomHolder); ImageHelper.setupButtonsPosition(back, register, bottom, context); }