62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace TracingDB.Entities
|
|
{
|
|
public class Record
|
|
{
|
|
public virtual int Id { get; protected set; }
|
|
public virtual string Code { get; set; }
|
|
public virtual DateTime TimeStamp { get; set; }
|
|
|
|
public virtual Part Part { get; set; }
|
|
public virtual ReferenceRecord ReferenceRecord { get; set; }
|
|
|
|
|
|
protected Record()
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor used when a part barcode is scanned
|
|
/// </summary>
|
|
/// <param name="partId">Part</param>
|
|
/// <param name="referenceRecordId">Reference record</param>
|
|
/// <param name="code">Scanned barcode</param>
|
|
public Record(Part part, ReferenceRecord referenceRecord, string code)
|
|
{
|
|
Part = part;
|
|
ReferenceRecord = referenceRecord;
|
|
Code = code;
|
|
TimeStamp = DateTime.Now;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a copy of a process with a new name
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
public virtual Record Clone(Process newProcess, ReferenceRecord newRR)
|
|
{
|
|
Part newPart = null;
|
|
foreach (var pt in newProcess.Parts)
|
|
{
|
|
if (Part.Name == pt.Name)
|
|
{
|
|
newPart = pt;
|
|
break;
|
|
}
|
|
}
|
|
Record rslt = new Record(newPart, newRR, Code);
|
|
rslt.TimeStamp = TimeStamp;
|
|
|
|
return rslt;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return string.Format("code={0} part={1} description='{2}'", Code, Part.Name, Part.Description);
|
|
}
|
|
}
|
|
}
|