85 lines
2.4 KiB
C#
85 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace SharedDatabase.Entities
|
|
{
|
|
public class Workstep
|
|
{
|
|
public virtual int Id { get; protected set; }
|
|
public virtual int WorkstepNr { get; set; }
|
|
public virtual string Name { get; set; }
|
|
public virtual string Description { get; set; }
|
|
public virtual int CheckPartNr { get; set; } /// 0 == No previous part checked
|
|
public virtual bool AllowRepairs { get; set; }
|
|
|
|
public virtual Process Process { get; set; }
|
|
public virtual Part ReferencePart { get; set; }
|
|
public virtual IList<Part> Parts { get; set; }
|
|
|
|
public virtual Workstep Clone(Process owningProcess)
|
|
{
|
|
Workstep rslt = new Workstep(WorkstepNr, Name, owningProcess);
|
|
rslt.Description = Description;
|
|
rslt.CheckPartNr = CheckPartNr;
|
|
rslt.AllowRepairs = AllowRepairs;
|
|
|
|
if (ReferencePart != null)
|
|
{
|
|
foreach (var p in owningProcess.Parts)
|
|
{
|
|
if (p.Name == ReferencePart.Name)
|
|
{
|
|
rslt.ReferencePart = p;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach (var srcP in Parts)
|
|
{
|
|
foreach (var p in owningProcess.Parts)
|
|
{
|
|
if ((p.Name == srcP.Name) && (p.StepNumber == srcP.StepNumber))
|
|
{
|
|
rslt.Parts.Add(p);
|
|
p.Workstep = rslt;
|
|
}
|
|
}
|
|
}
|
|
|
|
return rslt;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Default (private) constructor inicializing a list
|
|
/// </summary>
|
|
protected Workstep()
|
|
{
|
|
Parts = new List<Part>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Constructor used when this workstep is added to a process
|
|
/// </summary>
|
|
/// <param name="name">Workstep name</param>
|
|
/// <param name="process">Process to be referenced</param>
|
|
public Workstep(int workstepNr, string name, Process process)
|
|
: this()
|
|
{
|
|
WorkstepNr = workstepNr;
|
|
Name = name;
|
|
Description = string.Empty;
|
|
CheckPartNr = 0;
|
|
AllowRepairs = false;
|
|
Process = process;
|
|
ReferencePart = null;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return Name; /// Displayed in Pracovisko.WorkstepDlg.workstepComboBox, Items are Workstep objects
|
|
}
|
|
}
|
|
}
|