public string GetShortName() { return(String.Concat(LastName, " ", FirstName.Substring(0, 1), ".", MiddleName.Substring(0, 1), ".")); }
public Customer(FirstName firstName, LastName lastName) { this.FirstName = firstName; this.LastName = lastName; }
public bool Equals(Person other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(LastName.Equals(other.LastName, StringComparison.CurrentCultureIgnoreCase) && FirstName.Equals(other.FirstName, StringComparison.CurrentCultureIgnoreCase) && MiddleName.Equals(other.MiddleName, StringComparison.CurrentCultureIgnoreCase) && (BirthDate == other.BirthDate)); }
public override int GetHashCode() { return(FirstName.GetHashCode() + LastName.GetHashCode()); }
public override int GetHashCode() { return(FirstName.GetHashCode() & LastName.GetHashCode() & Age); }
/// <summary> /// On window loaded event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Window_Loaded(object sender, RoutedEventArgs e) { FirstName.Focus(); }
/// <summary> /// Compares a person with another one. /// </summary> /// <param name="other">Other person to compare to.</param> /// <returns>-1 if the first name of the current person comes before the other person's, 0 if it's equal and 1 if it comes after</returns> public int CompareTo(Person other) { return(FirstName.CompareTo(other.FirstName)); }
public void PrintShortName() { Console.WriteLine($"{FirstName.Substring(0, 1)}. {LastName}"); }
public bool Matches(string name) { name = name.ToLower(); return(FirstName.ToLower().Contains(name) || LastName.ToLower().Contains(name)); }
public void PrintFullNameAllCaps() { Console.WriteLine($"{LastName.ToUpper()}, {FirstName.ToUpper()}"); }
public void PrintFullNameLowerCase() { Console.WriteLine($"{LastName.ToLower()}, {FirstName.ToLower()}"); }
private string GenerateUsername() { Random random = new Random(); return($"{FirstName.Substring(3)}{random.Next(0,9)}{LastName.Substring(4)}"); }
public int CompareTo(Object obj) { Employee emp = (Employee)obj; return(FirstName.CompareTo(emp.FirstName)); }
private void save_Click(object sender, RoutedEventArgs e) { Purchaser purU = new Purchaser(); if (purData.Purchaser.ContactPerson != null) { purU.ContactPerson = new Person(); purU.ContactPerson = purData.Purchaser.ContactPerson; } PurchaserData purDataU = new PurchaserData(); purU.HomeAdress = new Adress(); InputEvaluator ie = new InputEvaluator(); if (ie.Evaluate(this)) { purU.Id = AGidx; purU.FirstName = FirstName.getContent(); purU.LastName = LastName.getmustContent(); purU.EMail = Email.getContent(); if (PhoneNr.getContent() != null) { purU.PhoneNumber = PhoneNr.getContent(); } if (MobileNr.getContent() != null) { purU.MobilePhone = MobileNr.getContent(); } purU.HomeAdress.AdressId = purData.Purchaser.HomeAdress.AdressId; purU.HomeAdress.Street = Street.getContent(); purU.HomeAdress.StairNumber = parseInt(StairNr.getContent()); purU.HomeAdress.HouseNumber = parseInt(HNr.getContent()); purU.HomeAdress.Etage = parseInt(Etage.getContent()); purU.HomeAdress.DoorNumber = parseInt(DoorNr.getContent()); purU.HomeAdress.City = City.getContent(); purU.HomeAdress.Country = Country.getContent(); purU.HomeAdress.ZipCode = parseInt(ZIP.getContent()); purU.EntryDate = EntryDate.DisplayDate; purU.ApprovalBegin = ApprovelFrom.DisplayDate; purU.ApprovalEnd = ApprovelTo.DisplayDate; purU.DistrictCommision = districtcommission.getContent(); purU.nationality = nationality.getContent(); purU.SVN = parseLong(SVN.getContent()); purDataU.HourlyRate = parseDecimal(PayperHour.getContent()); purDataU.TravellingAllowanceKM = parseDecimal(KmPay.getContent()); purDataU.HourlyRatePayoff = parseDecimal(billablePayperHour.getContent()); purDataU.Income = parseDecimal(Income.getContent()); purDataU.AssistenceDemand = parseInt(Needof.getContent()); purDataU.InputIncome = parseDecimal(IncomeBetrag.getContent()); purDataU.CareAllowance = parseInt((string)CareAllowence.SelectedValue); purDataU.Purchaser.InfoField = purData.Purchaser.InfoField; purDataU.Year = purData.Year; purDataU.Month = purData.Month; purU.IBAN = IBAN.getContent(); purU.BIC = BIC.getContent(); purU.AccountHolder = kontoinhaber.getContent(); if ((bool)activeRadioBtn.IsChecked) { purU.Active = true; } else if ((bool)inactiveRadioBtn.IsChecked) { purU.Active = false; } if ((bool)einfuehrungskurs.IsChecked) { purU.hasContract = true; } if ((bool)contract.IsChecked) { purU.hasIntroCourse = true; } if (purDataU.Purchaser.Employees != null) { foreach (EmploymentStatus emp in purData.Purchaser.Employees) { bool found = false; foreach (PersonalAssistant pa in employedPA) { if (pa.Id.Equals(emp.Assistant.Id)) { found = true; } } if (found) { purU.Employees.Add(emp); } } } //add PA connection PAtoPurchaserBL PBL = new PAtoPurchaserBL(); foreach (PersonalAssistant pa in addedPAs) { foreach (PersonalAssistant pad in deletedPAs) { if (pa.Id == pad.Id) { addedPAs.Remove(pa); deletedPAs.Remove(pad); } } } foreach (PersonalAssistant pa in addedPAs) { PBL.add(pa, purU); } //delete PA connection foreach (PersonalAssistant pa in deletedPAs) { PBL.delete(pa, purU); } //delete PA connection //AKTIV RADIO BOXEN NAMEN //switch to Übersicht foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(Main)) { (window as Main).FrameÜbersicht.Source = new Uri("../Personenverwaltung/AG/AGÜbersicht.xaml", UriKind.Relative); } } } purU.InfoField = purData.Purchaser.InfoField; purDataU.Purchaser = purU; if (purU.FirstName != null && purU.LastName != null) { bl.UpdatePurchaser(purDataU); } }
/// <inheritdoc /> /// <summary> /// Returns true if SpeakerDraft instances are equal /// </summary> /// <param name="other">Instance of SpeakerDraft to be compared</param> /// <returns>Boolean</returns> public bool Equals(SpeakerDraft other) { #pragma warning disable IDE0041 // Use 'is null' check if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } #pragma warning disable CA1309 // Use ordinal stringcomparison #pragma warning disable CA1307 // Specify StringComparison #pragma warning disable SA1515 // Single-line comment must be preceded by blank line #pragma warning disable SA1009 // Closing parenthesis must be spaced correctly return (#pragma warning disable SA1119 // Statement must not use unnecessary parenthesis ( // ReSharper disable once RedundantNameQualifier string.Equals(Id, other.Id) || (Id != null && Id.Equals(other.Id)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(FirstName, other.FirstName) || (FirstName != null && FirstName.Equals(other.FirstName)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(LastName, other.LastName) || (LastName != null && LastName.Equals(other.LastName)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(CompanyName, other.CompanyName) || (CompanyName != null && CompanyName.Equals(other.CompanyName)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(CompanyUrl, other.CompanyUrl) || (CompanyUrl != null && CompanyUrl.Equals(other.CompanyUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(Description, other.Description) || (Description != null && Description.Equals(other.Description)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(BlogsUrl, other.BlogsUrl) || (BlogsUrl != null && BlogsUrl.Equals(other.BlogsUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(ContactsUrl, other.ContactsUrl) || (ContactsUrl != null && ContactsUrl.Equals(other.ContactsUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(TwitterUrl, other.TwitterUrl) || (TwitterUrl != null && TwitterUrl.Equals(other.TwitterUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(HabrUrl, other.HabrUrl) || (HabrUrl != null && HabrUrl.Equals(other.HabrUrl)) ) && ( // ReSharper disable once RedundantNameQualifier string.Equals(GitHubUrl, other.GitHubUrl) || (GitHubUrl != null && GitHubUrl.Equals(other.GitHubUrl)) ) && ( Meetups == other.Meetups || (Meetups != null && Meetups.SequenceEqual(other.Meetups)) ) && ( Venues == other.Venues || (Venues != null && Venues.SequenceEqual(other.Venues)) ) && ( Talks == other.Talks || (Talks != null && Talks.SequenceEqual(other.Talks)) ) && ( Friends == other.Friends || (Friends != null && Friends.SequenceEqual(other.Friends)) )); #pragma warning restore SA1119 // Statement must not use unnecessary parenthesis #pragma warning restore SA1009 // Closing parenthesis must be spaced correctly #pragma warning restore SA1515 // Single-line comment must be preceded by blank line #pragma warning restore CA1307 // Specify StringComparison #pragma warning restore CA1309 // Use ordinal stringcomparison }
private void Button_Click(object sender, RoutedEventArgs e) { if (purData == null) { purData = new PurchaserData(); } if (purData.Purchaser == null) { purData.Purchaser = new Purchaser(); } Purchaser pur = purData.Purchaser; //purData = new PurchaserData(); pur.HomeAdress = new Adress(); InputEvaluator ie = new InputEvaluator(); bool save = true; if (doubles()) { SystemSounds.Asterisk.Play(); switch (MessageBox.Show("Es existiert bereits ein Auftraggeber mit diesem Namen. Soll er wirklich hinzugefügt werden?", "Achtung!", MessageBoxButton.YesNo, MessageBoxImage.Question)) { case MessageBoxResult.No: save = false; break; case MessageBoxResult.Yes: break; } } if (save) { if (ie.Evaluate(this)) { pur.FirstName = FirstName.getContent(); pur.LastName = LastName.getmustContent(); pur.EMail = Email.getContent(); if (PhoneNr.getContent() != null) { pur.PhoneNumber = PhoneNr.getContent(); } if (MobileNr.getContent() != null) { pur.MobilePhone = MobileNr.getContent(); } pur.HomeAdress.Street = Street.getContent(); pur.HomeAdress.StairNumber = parseInt(StairNr.getContent()); pur.HomeAdress.HouseNumber = parseInt(HNr.getContent()); pur.HomeAdress.Etage = parseInt(Etage.getContent()); pur.HomeAdress.DoorNumber = parseInt(DoorNr.getContent()); pur.HomeAdress.City = City.getContent(); pur.HomeAdress.Country = Country.getContent(); pur.HomeAdress.ZipCode = parseInt(ZIP.getContent()); pur.BIC = BIC.getContent(); pur.IBAN = IBAN.getContent(); pur.SVN = parseLong(SVN.getContent()); pur.AccountHolder = kontoinhaber.getContent(); pur.EntryDate = EntryDate.SelectedDate; pur.ApprovalBegin = ApprovelFrom.SelectedDate; pur.ApprovalEnd = ApprovelTo.SelectedDate; pur.nationality = nationality.getContent(); purData.HourlyRate = parseDecimal(PayperHour.getContent()); purData.TravellingAllowanceKM = parseDecimal(KmPay.getContent()); purData.HourlyRatePayoff = parseDecimal(billablePayperHour.getContent()); purData.Income = parseDecimal(Income.getContent()); purData.AssistenceDemand = parseInt(Needof.getContent()); purData.InputIncome = parseDecimal(IncomeBetrag.getContent()); purData.CareAllowance = parseInt((string)CareAllowence.SelectedValue); pur.DistrictCommision = districtcommission.getContent(); if ((bool)activeRadioBtn.IsChecked) { pur.Active = true; } if ((bool)einfuehrungskurs.IsChecked) { pur.hasContract = true; } if ((bool)contract.IsChecked) { pur.hasIntroCourse = true; } //switch to Übersicht foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(Main)) { (window as Main).FrameÜbersicht.Source = new Uri("../Personenverwaltung/AG/AGÜbersicht.xaml", UriKind.Relative); } } purData.Purchaser = pur; if (pur.FirstName != null && pur.LastName != null) { _bl.CreatePurchaser(purData); } //add PA connection PAtoPurchaserBL PBL = new PAtoPurchaserBL(); foreach (PersonalAssistant pa in addedPAs) { foreach (PersonalAssistant pad in deletedPAs) { if (pa.Id == pad.Id) { addedPAs.Remove(pa); deletedPAs.Remove(pad); } } } foreach (PersonalAssistant pa in addedPAs) { PBL.add(pa, pur); } //delete PA connection foreach (PersonalAssistant pa in deletedPAs) { PBL.delete(pa, pur); } } } }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // Overflow is fine, just wrap unchecked { var hashCode = 41; // Suitable nullity checks etc, of course :) #pragma warning disable CA1307 // Specify StringComparison // ReSharper disable once NonReadonlyMemberInGetHashCode if (Id != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Id.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (FirstName != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + FirstName.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (LastName != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + LastName.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (CompanyName != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + CompanyName.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (CompanyUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + CompanyUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Description != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Description.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (BlogsUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + BlogsUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (ContactsUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + ContactsUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (TwitterUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + TwitterUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (HabrUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + HabrUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (GitHubUrl != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + GitHubUrl.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Meetups != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Meetups.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Venues != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Venues.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Talks != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Talks.GetHashCode(); } // ReSharper disable once NonReadonlyMemberInGetHashCode if (Friends != null) { // ReSharper disable once NonReadonlyMemberInGetHashCode hashCode = (hashCode * 59) + Friends.GetHashCode(); } #pragma warning restore CA1307 // Specify StringComparison return(hashCode); } }
private bool doubles() { List <PurchaserData> purchaser = bl.SelectAllPurchaser(); foreach (PurchaserData pur in purchaser) { if (pur.Purchaser.SVN != 0 && pur.Purchaser.SVN.Equals(SVN.getContent()) || pur.Purchaser.FirstName.Equals(FirstName.getContent()) && pur.Purchaser.LastName.Equals(LastName.getContent())) { return(true); } } return(false); }
public void EnterFirstName(string firstName) { FirstName.Clear(); FirstName.SendKeys(firstName); }
public string FullName() { return(LastName.Trim().ToUpper() + ", " + FirstName.Trim() + " " + MiddleName.Substring(0, 1) + "."); }
public void ValidateModel(ModelStateDictionary modelState) { var dorouting = false; var doaccount = Account.HasValue() && !Account.StartsWith("X"); if (Routing.HasValue() && !Routing.StartsWith("X")) { dorouting = true; } if (doaccount || dorouting) { if (doaccount) { Account = Account.GetDigits(); } if (dorouting) { Routing = Routing.GetDigits(); } } if (Type == PaymentType.CreditCard) { PaymentValidator.ValidateCreditCardInfo(modelState, new PaymentForm { CreditCard = CreditCard, Expires = Expires, CVV = CVV, SavePayInfo = true }); } else if (Type == PaymentType.Ach) { PaymentValidator.ValidateBankAccountInfo(modelState, Routing, Account); } else { modelState.AddModelError("Type", "Must select Bank Account or Credit Card"); } if (SemiEvery == "S") { if (!Day1.HasValue || !Day2.HasValue) { modelState.AddModelError("Day2", "Both Days must have values"); } else if (Day2 > 31) { modelState.AddModelError("Day2", "Day2 must be 31 or less"); } else if (Day1 >= Day2) { modelState.AddModelError("Day1", "Day1 must be less than Day2"); } } else if (SemiEvery == "E") { if (!EveryN.HasValue || EveryN < 1) { modelState.AddModelError("EveryN", "Days must be > 0"); } } else { modelState.AddModelError("SemiEvery", "Must Choose Payment Frequency"); } if (!StartWhen.HasValue) { modelState.AddModelError("StartWhen", "StartDate must have a value"); } else if (StartWhen <= DateTime.Today) { modelState.AddModelError("StartWhen", "StartDate must occur after today"); } // else if (StopWhen.HasValue && StopWhen <= StartWhen) // modelState.AddModelError("StopWhen", "StopDate must occur after StartDate"); if (!FirstName.HasValue()) { modelState.AddModelError("FirstName", "Needs first name"); } if (!LastName.HasValue()) { modelState.AddModelError("LastName", "Needs last name"); } if (!Address.HasValue()) { modelState.AddModelError("Address", "Needs address"); } if (!City.HasValue()) { modelState.AddModelError("City", "Needs city"); } if (!State.HasValue()) { modelState.AddModelError("State", "Needs state"); } if (!Country.HasValue()) { modelState.AddModelError("Country", "Needs country"); } if (!Zip.HasValue()) { modelState.AddModelError("Zip", "Needs zip"); } if (!Phone.HasValue()) { modelState.AddModelError("Phone", "Needs phone"); } }
public bool HasAllNonEmpty() { return(!FirstName.IsNullOrEmpty() && !LastName.IsNullOrEmpty() && !EmailAddress.IsNullOrEmpty()); }
public void ProcessRequest(HttpContext context) { ManagementService managementservice = new ManagementService(); ScopeServices scopeservices = new ScopeServices(); managementservice.SQLConnection = ConnectDb.SQLConnection; UserProfile contactProfile = new UserProfile(); Project project = new Project(); User contactUser = new User(); long userId; string FirstName; string LastName; string Email; string Contact1; string Contact2; string Contact3; string Address; string Suburb; int SuburbId; string City; int CityId; string PostCode; string Region; int RegionId; string Country; int CountryId; string ProjectName; string ClaimNumber; string EstimatedTime; string StartDate = ""; string ScopeDate = ""; string AssessmentDate = ""; string QuotationDate = ""; string FinishDate = ""; string ProjectGroupName; int ProjectGroupId; int Priority; string Hazard; int status; try { userId = Convert.ToInt32(context.Request.QueryString["userId"]); } catch { userId = 0; } try { FirstName = context.Request.QueryString["FirstName"]; } catch { FirstName = ""; } try { LastName = context.Request.QueryString["LastName"]; } catch { LastName = ""; } try { Email = context.Request.QueryString["Email"]; } catch { Email = ""; } try { Contact1 = context.Request.QueryString["Contact1"]; } catch { Contact1 = ""; } try { Contact2 = context.Request.QueryString["Contact2"]; } catch { Contact2 = ""; } try { Contact3 = context.Request.QueryString["Contact3"]; } catch { Contact3 = ""; } try { Address = context.Request.QueryString["Address"]; } catch { Address = ""; } try { Suburb = context.Request.QueryString["Suburb"]; } catch { Suburb = ""; } try { SuburbId = Convert.ToInt32(context.Request.QueryString["SuburbId"]); } catch { SuburbId = 0; } try { City = context.Request.QueryString["City"]; } catch { City = ""; } try { CityId = Convert.ToInt32(context.Request.QueryString["CityId"]); } catch { CityId = 0; } try { PostCode = context.Request.QueryString["PostCode"]; } catch { PostCode = ""; } try { Region = context.Request.QueryString["Region"]; } catch { Region = ""; } try { RegionId = Convert.ToInt32(context.Request.QueryString["RegionId"]); } catch { RegionId = 0; } try { Country = context.Request.QueryString["Country"]; } catch { Country = ""; } try { CountryId = Convert.ToInt32(context.Request.QueryString["CountryId"]); } catch { CountryId = 0; } try { ProjectName = context.Request.QueryString["ProjectName"]; } catch { ProjectName = ""; } try { ClaimNumber = context.Request.QueryString["ClaimNumber"]; } catch { ClaimNumber = ""; } try { EstimatedTime = context.Request.QueryString["EstimatedTime"]; } catch { EstimatedTime = ""; } try { StartDate = context.Request.QueryString["StartDate"]; } catch { } try { ScopeDate = context.Request.QueryString["ScopeDate"]; } catch { } try { AssessmentDate = context.Request.QueryString["AssessmentDate"]; } catch { } try { QuotationDate = context.Request.QueryString["QuotationDate"]; } catch { } try { FinishDate = context.Request.QueryString["FinishDate"]; } catch { } try { ProjectGroupName = context.Request.QueryString["ProjectGroupName"]; } catch { ProjectGroupName = ""; } try { ProjectGroupId = Convert.ToInt32(context.Request.QueryString["ProjectGroupId"]); } catch { ProjectGroupId = 0; } try { Priority = Convert.ToInt32(context.Request.QueryString["Priority"]); } catch { Priority = 0; } try { Hazard = context.Request.QueryString["Hazard"]; } catch { Hazard = ""; } try { status = Convert.ToInt32(context.Request.QueryString["status"]); } catch { status = 0; } contactUser.Email = Email.Trim(); contactUser.Type = 0; userId = managementservice.CreateUser(contactUser, userId); long userProfileId; contactProfile.UserId = userId; contactProfile.FirstName = FirstName.Trim(); contactProfile.LastName = LastName.Trim(); contactProfile.Contact1 = Contact1.Trim(); contactProfile.Contact2 = Contact2.Trim(); contactProfile.Contact3 = Contact3.Trim(); contactProfile.Email = Email.Trim(); userProfileId = managementservice.CreateUserProfile(contactProfile); contactProfile.UserProfileId = userProfileId; VoucherCodeFunctions cVoucherCode = new VoucherCodeFunctions(); String strIdentifier = String.Format("{0}{1}", userProfileId, cVoucherCode.GenerateVoucherCodeGuid(16)); contactProfile.Identifier = strIdentifier; managementservice.UpdateUserProfileIdentifier(contactProfile); string filename = DateTime.UtcNow.ToString("yyyyMMddHHmmss"); string fname = "", virtualpath = ""; System.Text.StringBuilder str = new System.Text.StringBuilder(); try { if (context.Request.Files.Count > 0) { HttpFileCollection files = context.Request.Files; string myactualfilename = ""; for (int i = 0; i < files.Count; i++) { HttpPostedFile file = files[i]; myactualfilename = file.FileName; var p = file.FileName.Split('.'); var extention = myactualfilename.Split('.'); string ext = extention[extention.Length - 1]; filename = filename + '.' + ext; string projectpath = "http://koreprojects.com"; string folderPath = context.Server.MapPath(projectpath + "/Images/" + contactProfile.Identifier); if (!System.IO.Directory.Exists(folderPath)) { System.IO.Directory.CreateDirectory(folderPath); } fname = context.Server.MapPath(projectpath + "/Images/" + contactProfile.Identifier + "/" + filename); file.SaveAs(fname); //context.Response.Write(filename); } } } catch { //context.Response.Write("un"); } if (filename != String.Empty) { contactProfile.PersonalPhoto = filename; } managementservice.UpdateUserProfile(contactProfile); project.ContactId = userId; project.ProjectOwnerId = managementservice.GetProjectOwnerByContactId(userId).ProjectOwnerId; project.Address = Address.Trim(); project.Suburb = Suburb; if (Suburb != string.Empty) { project.SuburbID = SuburbId; } project.City = City; if (City != string.Empty) { project.CityID = CityId; } project.Region = Region; if (RegionId > 0) { project.RegionID = RegionId; } project.Country = Country; if (CountryId > 0) { project.CountryID = CountryId; } project.Name = ProjectName.Trim(); project.EQCClaimNumber = ClaimNumber.Trim(); project.EstimatedTime = EstimatedTime.Trim(); project.StartDate = Convert.ToDateTime(StartDate); project.ScopeDate = Convert.ToDateTime(ScopeDate); project.ProjectStatusId = 0; if (ProjectGroupId > 0) { project.GroupID = ProjectGroupId; project.GroupName = ProjectGroupName; } else { project.GroupID = 0; project.GroupName = String.Empty; } project.AssessmentDate = Convert.ToDateTime(AssessmentDate); project.QuotationDate = Convert.ToDateTime(QuotationDate); project.FinishDate = Convert.ToDateTime(FinishDate); project.Priority = Priority; project.Hazard = Hazard.Trim(); long newProjectId; newProjectId = managementservice.CreateProject(project); project.ProjectId = newProjectId; UserProjectStatusValue userProjectStatusValue = new UserProjectStatusValue(); userProjectStatusValue.ProjectId = project.ProjectId; userProjectStatusValue.UserId = userId; userProjectStatusValue.UserProjectStatusValue = status; managementservice.CreateUserProjectStatusValue(userProjectStatusValue); int projectCredit = 0; try { DataSet dsUserAccount = new DataSet(); dsUserAccount = managementservice.GetUserAccountByUserID(userId); if (dsUserAccount.Tables[0].Rows.Count > 0) { projectCredit = int.Parse(dsUserAccount.Tables[0].Rows[0]["ProjectCredit"].ToString()); } if (projectCredit > 0) { managementservice.UpdateUserAccount(userId, projectCredit - 1); managementservice.CreateUserTransaction(userId, String.Format("Create Project", project.Name), 0, 0, -1, projectCredit - 1); } } catch (Exception w) { } context.Response.ContentType = "image/jpg"; context.Response.AddHeader("Content-Disposition", "attachment; filename=\"" + filename + "\""); }
/// <summary> /// Displays a formatted string for list box /// </summary> /// <returns>Listbox string</returns> protected virtual string ToListBoxString(String personType) { return(String.Format("{0} {1} {2} {3}", FirstName.PadRight(16), LastName.PadRight(16), personType.PadRight(13), AcademicDepartment.PadRight(10))); }
public override int GetHashCode() { return(FirstName.GetHashCode() ^ MiddleName.GetHashCode() ^ LastName.GetHashCode() ^ SSN.GetHashCode()); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { //throw new NotImplementedException(); if (FirstName == null || FirstName.Trim() == "") { yield return(new ValidationResult("First name cannot be empty or just blanks", new[] { nameof(FirstName) })); } if (!(FirstName == null || FirstName.Trim() == "")) { FirstName = FirstName.Trim(); } if (LastName == null || LastName.Trim() == "") { yield return(new ValidationResult("Last name cannot be empty or just blanks", new[] { nameof(LastName) })); } if (!(LastName == null || LastName.Trim() == "")) { LastName = LastName.Trim(); } FirstName = KAValidations.KACapitalize(FirstName); LastName = KAValidations.KACapitalize(LastName); Address = KAValidations.KACapitalize(Address); City = KAValidations.KACapitalize(City); Gender = KAValidations.KACapitalize(Gender); if (!String.IsNullOrEmpty(ProvinceCode)) { ProvinceCode = ProvinceCode.ToUpper(); } if (!String.IsNullOrEmpty(Ohip)) { Ohip = KAValidations.KACapitalize(Ohip); if (!KAValidations.KAOhipValidation(Ohip)) { yield return(new ValidationResult("Ohip format not accepted. Accepted format is 1234-123-123-XX", new[] { nameof(Ohip) })); } } if (!String.IsNullOrEmpty(HomePhone)) { string phoneDigits = KAValidations.KAExtractDigits(HomePhone); if (Regex.IsMatch(phoneDigits, @"^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$")) { phoneDigits = phoneDigits.Insert(3, "-"); phoneDigits = phoneDigits.Insert(7, "-"); HomePhone = phoneDigits; } else { yield return(new ValidationResult("Home Phone number format is wrong. Home phone number must contain exactly 10 digits", new[] { nameof(HomePhone) })); } } if (!String.IsNullOrEmpty(DateOfBirth.ToString())) { if (DateOfBirth > DateTime.Now) { yield return(new ValidationResult("Date of birth cannot be in future", new[] { nameof(DateOfBirth) })); } } if (Deceased) { if (String.IsNullOrWhiteSpace(DateOfDeath.ToString())) { yield return(new ValidationResult("Date of Death is compulsary for deceased patients", new[] { nameof(DateOfDeath) })); } } if (!Deceased) { if (!String.IsNullOrWhiteSpace(DateOfDeath.ToString())) { yield return(new ValidationResult("Cannot add date of death for patient who is not dead (deceased must be checked)", new[] { nameof(DateOfDeath) })); } } if (!String.IsNullOrWhiteSpace(DateOfDeath.ToString())) { if (DateOfDeath < DateOfBirth) { yield return(new ValidationResult("Date of death cannot be before date of birth.", new[] { nameof(DateOfDeath) })); } if (DateOfDeath > DateTime.Now) { yield return(new ValidationResult("Date of death cannot be in future", new[] { nameof(DateOfDeath) })); } } if (String.IsNullOrWhiteSpace(Gender)) { yield return(new ValidationResult("Gender is required", new[] { nameof(Gender) })); } if (!(Gender == "M" || Gender == "F" || Gender == "X")) { yield return(new ValidationResult("Gender must be M or F or X", new[] { nameof(Gender) })); } localPatientContext = (PatientsContext)validationContext.GetService(typeof(PatientsContext)); if (!String.IsNullOrEmpty(ProvinceCode)) { ProvinceCode = KAValidations.KACapitalize(ProvinceCode); //try //{ if (!(localPatientContext.Province.Any(x => x.ProvinceCode == ProvinceCode))) { yield return(new ValidationResult("This province name do not exists", new[] { nameof(ProvinceCode) })); } //} //catch (Exception ex) { //} } if (!String.IsNullOrEmpty(PostalCode)) { if (String.IsNullOrEmpty(ProvinceCode)) { yield return(new ValidationResult("In order to add/edit postal code, You need to add valid Province code ", new[] { nameof(PostalCode), nameof(ProvinceCode) })); } PostalCode = PostalCode.ToUpper(); firstLetterPostalCode = PostalCode[0].ToString(); } if (localPatientContext.Province.Where(x => x.ProvinceCode == ProvinceCode) .Select(x => x.CountryCode).FirstOrDefault() == "CA") { if (ProvinceCode.ToUpper() == "ON") { if (!(firstLetterPostalCode == "K" || firstLetterPostalCode == "L" || firstLetterPostalCode == "M" || firstLetterPostalCode == "N" || firstLetterPostalCode == "P")) { yield return(new ValidationResult("Postal Code and Province Name are not matching ", new[] { nameof(PostalCode), nameof(ProvinceCode) })); } } else if (ProvinceCode.ToUpper() == "QC") { if (!(firstLetterPostalCode == "G" || firstLetterPostalCode == "H" || firstLetterPostalCode == "J")) { yield return(new ValidationResult("Postal Code and Province Name are not matching ", new[] { nameof(PostalCode), nameof(ProvinceCode) })); } } else { if (!(localPatientContext.Province.Where(x => x.ProvinceCode == ProvinceCode) .Select(x => x.FirstPostalLetter).FirstOrDefault() == firstLetterPostalCode)) { yield return(new ValidationResult("Postal Code and Province Name are not matching ", new[] { nameof(PostalCode), nameof(ProvinceCode) })); } } if (!KAValidations.KAPostalCodeValidation(PostalCode)) { yield return(new ValidationResult("The postal code is not as per the format", new[] { nameof(PostalCode) })); } if (KAValidations.KAPostalCodeValidation(PostalCode)) { PostalCode = KAValidations.KAPostalCodeFormat(PostalCode); } } if (localPatientContext.Province.Where(x => x.ProvinceCode == ProvinceCode) .Select(x => x.CountryCode).FirstOrDefault() == "US") { if (!KAValidations.KAZipCodeValidation(PostalCode)) { yield return(new ValidationResult("The ZIP code is not as per the format", new[] { nameof(PostalCode) })); } } yield return(ValidationResult.Success); }
protected override void OnBeforeEntitySave() { var now = DateTime.UtcNow; if (IsNew && !Fields[UserFields.CreatedOn.FieldIndex].IsChanged) { CreatedOn = now; } if (IsDirty && !Fields[UserFields.ModifiedOn.FieldIndex].IsChanged) { ModifiedOn = now; } if (IsNew && !Fields[UserFields.Guid.FieldIndex].IsChanged) { Guid = System.Guid.NewGuid().ToString("N"); // should be set by UserStore of Identity } if (Gender.Length == 0 || !new[] { 'm', 'f', 'u' }.Contains(Gender[0])) { Gender = "u"; } if (!string.IsNullOrEmpty(FirstName)) { FirstName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(FirstName?.ToLower(CultureInfo.CurrentCulture)); } if (!string.IsNullOrEmpty(MiddleName)) { MiddleName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(MiddleName.ToLower(CultureInfo.CurrentCulture)); } if (!string.IsNullOrEmpty(LastName)) { LastName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(LastName.ToLower(CultureInfo.CurrentCulture)); } if (!string.IsNullOrEmpty(Nickname)) { Nickname = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Nickname.ToLower(CultureInfo.CurrentCulture)); } if (string.IsNullOrEmpty(PhoneNumber) && !string.IsNullOrEmpty(PhoneNumber2)) { PhoneNumber = PhoneNumber2; PhoneNumber2 = string.Empty; } if (string.IsNullOrEmpty(Email) && !string.IsNullOrEmpty(Email2)) { Email = Email2; Email2 = string.Empty; } if (!string.IsNullOrEmpty(Email)) { Email = Email.ToLowerInvariant(); } if (!string.IsNullOrEmpty(Email2)) { Email2 = Email2.ToLowerInvariant(); } base.OnBeforeEntitySave(); }
//self_validation for memebr class public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { SailContext _context = new SailContext(); //trim all strings FirstName = FirstName.Trim(); LastName = LastName.Trim(); if (SpouseFirstName != null) { SpouseFirstName = SpouseFirstName.Trim(); } if (SpouseLastName != null) { SpouseLastName = SpouseLastName.Trim(); } if (Street != null) { Street = Street.Trim(); } if (City != null) { City = City.Trim(); } if (ProvinceCode != null) { ProvinceCode = ProvinceCode.Trim(); } if (PostalCode != null) { PostalCode = PostalCode.Trim(); } HomePhone = HomePhone.Trim(); if (Email != null) { Email = Email.Trim(); } //capitalize designated fields FirstName = HXClassLibrary.HXValidations.HXCapitalize(FirstName); LastName = HXClassLibrary.HXValidations.HXCapitalize(LastName); SpouseFirstName = HXClassLibrary.HXValidations.HXCapitalize(SpouseFirstName); SpouseLastName = HXClassLibrary.HXValidations.HXCapitalize(SpouseLastName); Street = HXClassLibrary.HXValidations.HXCapitalize(Street); City = HXClassLibrary.HXValidations.HXCapitalize(City); // format full name if (SpouseFirstName == "") { FullName = LastName + ", " + FirstName; } else if (SpouseFirstName != "" && SpouseLastName != "") { if (SpouseLastName == LastName) { FullName = LastName + ", " + FirstName + " & " + SpouseFirstName; } else { FullName = LastName + ", " + FirstName + " & " + SpouseLastName + ", " + SpouseFirstName; } } else if (SpouseFirstName != "" && SpouseLastName == "") { FullName = LastName + ", " + FirstName + " & " + SpouseFirstName; } //validate province code Province province = null; string errorMessage = ""; try { ProvinceCode = (ProvinceCode + "").ToUpper(); province = _context.Province.Find(ProvinceCode); if (province == null) { errorMessage = "the province code is not on file"; } } catch (Exception ex) { errorMessage = $"fetching provinceCode error: {ex.GetBaseException().Message}"; } if (errorMessage != "") { yield return(new ValidationResult( errorMessage, new[] { "ProvinceCode" })); } //validate postal code if (!string.IsNullOrEmpty(PostalCode)) { if (string.IsNullOrEmpty(ProvinceCode)) { yield return(new ValidationResult( "province code is required when having the postal code", new[] { "ProvinceCode" })); } else { if (province == null) { yield return(new ValidationResult( "The province code is not on file", new[] { "ProvinceCode" })); } else { if (province.CountryCode == "CA") { if (HXClassLibrary.HXValidations.HXPostalCodeValidation(PostalCode)) { HXClassLibrary.HXValidations.HXPostalCodeFormat(PostalCode); } else { yield return(new ValidationResult( "the postal code is invalid in Canada (it should follow the format: A1B 1E1)", new[] { "PostalCode" })); } } else if (province.CountryCode == "US") { string postalCode = PostalCode; if (HXClassLibrary.HXValidations.HXZipCodeValidation(ref postalCode)) { PostalCode = postalCode; } else { yield return(new ValidationResult( "the zip code is invalid in the US (it should have 5 or 9 digits)", new[] { "PostalCode" })); } } } } } //validate home phone if (HXClassLibrary.HXValidations.HXExtractDigits(HomePhone).Length == 10) { HomePhone = HXClassLibrary.HXValidations.HXExtractDigits(HomePhone).Insert(3, "-").Insert(6, "-"); } else { HomePhone = HXClassLibrary.HXValidations.HXExtractDigits(HomePhone); yield return(new ValidationResult( "a valid phone number should have 10 digits", new[] { "HomePhone" })); } //validate year joined if (YearJoined > Convert.ToInt32(DateTime.Now.Year)) { yield return(new ValidationResult( "year joined can not be in the future", new[] { "YearJoined" })); } var memberId = _context.Member.Find(MemberId); if (memberId == null) { if (YearJoined == null) { yield return(new ValidationResult( "year joined can only be null for existing records.", new[] { "YearJoined" })); } } //validate using canada post if (UseCanadaPost == false) { if (string.IsNullOrEmpty(Email)) { yield return(new ValidationResult( "Must have a valid email if not using Canada Post", new[] { "Email" })); } } else { if (string.IsNullOrEmpty(Street) || string.IsNullOrEmpty(City) || string.IsNullOrEmpty(ProvinceCode) || string.IsNullOrEmpty(PostalCode)) { yield return(new ValidationResult( "street, city, province code, postal code can not be null when using Canada Post.", new[] { "UseCanadaPost" })); } } yield return(ValidationResult.Success); }
//case/switch thats gives user student's last name when first name is entered. public void LastName(FirstName firstname) { switch (firstname) { case FirstName.Marjorie: Console.WriteLine("Boucher"); break; case FirstName.Howard: Console.WriteLine("Newell"); break; case FirstName.Norma: Console.WriteLine("Childs"); break; case FirstName.Ruby: Console.WriteLine("Ibarra"); break; case FirstName.Joyce: Console.WriteLine("Winter"); break; case FirstName.Francis: Console.WriteLine("Davies"); break; case FirstName.Melvin: Console.WriteLine("Schultz"); break; case FirstName.Edith: Console.WriteLine("Gibbons"); break; case FirstName.Clyde: Console.WriteLine("Westridge"); break; case FirstName.Agnes: Console.WriteLine("Delarosa"); break; case FirstName.Gilbert: Console.WriteLine("Kessler"); break; case FirstName.Clara: Console.WriteLine("Downey"); break; case FirstName.Russell: Console.WriteLine("Espinosa"); break; case FirstName.Florence: Console.WriteLine("Vogel"); break; default: throw new Exception("\nWe're sorry, but that name is not in the class list."); break; } }
public override int GetHashCode() { return(Id.GetHashCode() ^ FirstName.GetHashCode() ^ LastName.GetHashCode() ^ Address.GetHashCode()); }