public void SaveBOM() { DateTime dateNow = DateTime.Today; if (_observableBOMPartsCollection != null && _observableBOMPartsCollection.Count > 0) { foreach (var part in _observableBOMPartsCollection) { BOMPart newBOMPart = new BOMPart() { JobNumber = _jobNumber, PartId = part.PartId, Quantity = part.Quantity, DateCreated = dateNow }; context.BOMParts.Add(newBOMPart); } context.SaveChanges(); } else if (_observableBOMPartsCollection.Count < 1) { MessageBox.Show("There are no parts added to the BOM.\nPlease add parts and try again."); } }
/// <summary> /// To check whether a bompart need partcheck according to its checksetting data /// </summary> /// <param name="bomPart">Bom part</param> /// <returns>Whether a check is required</returns> public bool IfNeedCheck(BOMPart bomPart) { PartCheck checkSetting = this.GetPartCheckSettingData(bomPart.ValueType); if (checkSetting == null) { string msg = string.Format("PartCheck data of {0} type does not exist.", bomPart.Type); Exception ex = new Exception(msg); throw ex; } return checkSetting.NeedCheck > 0; }