Main Screen fixes
Added confimation dialogues for deleting parts/products; Finished implementing Product class methods; Propogating part modifications to associated products; Stopped deleting of items if there is an association;
This commit is contained in:
@@ -4,7 +4,7 @@ namespace C968Project;
|
||||
|
||||
public class Product
|
||||
{
|
||||
public BindingList<Part> AssociatedParts { get; set; }
|
||||
public BindingList<Part> AssociatedParts { get; set; } = new();
|
||||
public int ProductId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public float Price { get; set; }
|
||||
@@ -12,15 +12,39 @@ public class Product
|
||||
public int Min { get; set; }
|
||||
public int Max { get; set; }
|
||||
|
||||
public void AddAssociatedPart(Part part){}
|
||||
public void AddAssociatedPart(Part part)
|
||||
{
|
||||
if (AssociatedParts.Contains(part))
|
||||
{
|
||||
MessageBox.Show($"Product {Name} already has an association with part {part.Name}", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
AssociatedParts.Add(part);
|
||||
}
|
||||
|
||||
public bool RemoveAssociatedPart(int partIndex)
|
||||
{
|
||||
return false;
|
||||
var part = LookupAssociatedPart(partIndex);
|
||||
|
||||
if (part is null)
|
||||
{
|
||||
MessageBox.Show($"An error occured while trying to locate the part at index {partIndex}.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
AssociatedParts.Remove(part);
|
||||
return true;
|
||||
}
|
||||
|
||||
public Part LookupAssociatedPart(int partIndex)
|
||||
public Part? LookupAssociatedPart(int partIndex)
|
||||
{
|
||||
return null;
|
||||
if (partIndex > AssociatedParts.Count)
|
||||
{
|
||||
MessageBox.Show($"Error trying to locate part at index {partIndex}. Out of bounds.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return null;
|
||||
}
|
||||
|
||||
return AssociatedParts[partIndex];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user