private void OnArchivedPropChange( CswNbtNodeProp NodeProp, bool Creating ) { ArchiveDate.setHidden( value: Archived.Checked != CswEnumTristate.True, SaveToDb: true ); string ArchivedTitleSuffix = " (Archived)"; if( Archived.Checked == CswEnumTristate.True ) { ArchiveDate.DateTimeValue = DateTime.Now; Title.Text += ArchivedTitleSuffix; } else { ArchiveDate.DateTimeValue = DateTime.MinValue; if( Title.Text.EndsWith( ArchivedTitleSuffix ) ) { Title.Text = Title.Text.Substring( 0, Title.Text.Length - ArchivedTitleSuffix.Length ); } } } // OnArchivedPropChange()
/// <summary> /// タイプ数をアーカイブします。 /// 初期タイプ数リストを返却します。 /// </summary> public List <Current> Archive() { using var context = new ApplicationDbContext(); var nowDate = DateTime.Now.Date; return(context.Tx(() => { var keys = context.Current.ToList(); var mod = context.ArchiveDate.Include(nameof(ArchiveDate.Archives)).SingleOrDefault(ad => ad.DateTime.Date == nowDate.Date); // insert if (mod == null) { var archives = keys.Select(k => new Archive() { Code = k.Code, Count = k.Count }).ToList(); var reg = new ArchiveDate() { DateTime = nowDate, Archives = archives }; context.ArchiveDate.Add(reg); } // update else { foreach (var modKey in mod.Archives) { modKey.Count += keys.SingleOrDefault(k => k.Code == modKey.Code)?.Count ?? 0; } } context.RemoveRange(context.Current); var regKey = Current.CreateInitialKeyList(); context.Current.AddRange(regKey); context.SaveChanges(); return regKey; })); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { int hash = 41; // Suitable nullity checks hash = hash * 59 + Id.GetHashCode(); if (OwnerEquipmentCodePrefix != null) { hash = hash * 59 + OwnerEquipmentCodePrefix.GetHashCode(); } if (OrganizationName != null) { hash = hash * 59 + OrganizationName.GetHashCode(); } hash = hash * 59 + MeetsResidency.GetHashCode(); if (LocalArea != null) { hash = hash * 59 + LocalArea.GetHashCode(); } if (Status != null) { hash = hash * 59 + Status.GetHashCode(); } if (DoingBusinessAs != null) { hash = hash * 59 + DoingBusinessAs.GetHashCode(); } if (RegisteredCompanyNumber != null) { hash = hash * 59 + RegisteredCompanyNumber.GetHashCode(); } if (PrimaryContact != null) { hash = hash * 59 + PrimaryContact.GetHashCode(); } if (IsMaintenanceContractor != null) { hash = hash * 59 + IsMaintenanceContractor.GetHashCode(); } if (WorkSafeBCPolicyNumber != null) { hash = hash * 59 + WorkSafeBCPolicyNumber.GetHashCode(); } if (WorkSafeBCExpiryDate != null) { hash = hash * 59 + WorkSafeBCExpiryDate.GetHashCode(); } if (CGLEndDate != null) { hash = hash * 59 + CGLEndDate.GetHashCode(); } if (ArchiveCode != null) { hash = hash * 59 + ArchiveCode.GetHashCode(); } if (ArchiveReason != null) { hash = hash * 59 + ArchiveReason.GetHashCode(); } if (ArchiveDate != null) { hash = hash * 59 + ArchiveDate.GetHashCode(); } if (Contacts != null) { hash = hash * 59 + Contacts.GetHashCode(); } if (Notes != null) { hash = hash * 59 + Notes.GetHashCode(); } if (Attachments != null) { hash = hash * 59 + Attachments.GetHashCode(); } if (History != null) { hash = hash * 59 + History.GetHashCode(); } if (EquipmentList != null) { hash = hash * 59 + EquipmentList.GetHashCode(); } return(hash); } }
/// <summary> /// Returns true if Owner instances are equal /// </summary> /// <param name="other">Instance of Owner to be compared</param> /// <returns>Boolean</returns> public bool Equals(Owner other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Id == other.Id || Id.Equals(other.Id) ) && ( OwnerEquipmentCodePrefix == other.OwnerEquipmentCodePrefix || OwnerEquipmentCodePrefix != null && OwnerEquipmentCodePrefix.Equals(other.OwnerEquipmentCodePrefix) ) && ( OrganizationName == other.OrganizationName || OrganizationName != null && OrganizationName.Equals(other.OrganizationName) ) && ( MeetsResidency == other.MeetsResidency || MeetsResidency.Equals(other.MeetsResidency) ) && ( LocalArea == other.LocalArea || LocalArea != null && LocalArea.Equals(other.LocalArea) ) && ( Status == other.Status || Status != null && Status.Equals(other.Status) ) && ( DoingBusinessAs == other.DoingBusinessAs || DoingBusinessAs != null && DoingBusinessAs.Equals(other.DoingBusinessAs) ) && ( RegisteredCompanyNumber == other.RegisteredCompanyNumber || RegisteredCompanyNumber != null && RegisteredCompanyNumber.Equals(other.RegisteredCompanyNumber) ) && ( PrimaryContact == other.PrimaryContact || PrimaryContact != null && PrimaryContact.Equals(other.PrimaryContact) ) && ( IsMaintenanceContractor == other.IsMaintenanceContractor || IsMaintenanceContractor != null && IsMaintenanceContractor.Equals(other.IsMaintenanceContractor) ) && ( WorkSafeBCPolicyNumber == other.WorkSafeBCPolicyNumber || WorkSafeBCPolicyNumber != null && WorkSafeBCPolicyNumber.Equals(other.WorkSafeBCPolicyNumber) ) && ( WorkSafeBCExpiryDate == other.WorkSafeBCExpiryDate || WorkSafeBCExpiryDate != null && WorkSafeBCExpiryDate.Equals(other.WorkSafeBCExpiryDate) ) && ( CGLEndDate == other.CGLEndDate || CGLEndDate != null && CGLEndDate.Equals(other.CGLEndDate) ) && ( ArchiveCode == other.ArchiveCode || ArchiveCode != null && ArchiveCode.Equals(other.ArchiveCode) ) && ( ArchiveReason == other.ArchiveReason || ArchiveReason != null && ArchiveReason.Equals(other.ArchiveReason) ) && ( ArchiveDate == other.ArchiveDate || ArchiveDate != null && ArchiveDate.Equals(other.ArchiveDate) ) && ( Contacts == other.Contacts || Contacts != null && Contacts.SequenceEqual(other.Contacts) ) && ( Notes == other.Notes || Notes != null && Notes.SequenceEqual(other.Notes) ) && ( Attachments == other.Attachments || Attachments != null && Attachments.SequenceEqual(other.Attachments) ) && ( History == other.History || History != null && History.SequenceEqual(other.History) ) && ( EquipmentList == other.EquipmentList || EquipmentList != null && EquipmentList.SequenceEqual(other.EquipmentList) )); }
private void OnAcquiredDatePropChange( CswNbtNodeProp NodeProp, bool Creating ) { ArchiveDate.setHidden( value: true, SaveToDb: true ); }