public bool UpdateBOM(int?bomID, int?bomRawMatID, int?bomFiniGoodID, float?bomQuantity, double?scrapFactor) { SPG.BOMDataTable boms = Adapter.GetBomByBomID(bomID.Value); StringBuilder str = new StringBuilder(string.Empty); if (bomRawMatID.HasValue == false) { str.Append("a RM ID, "); } if (bomQuantity.HasValue == false || bomQuantity.Value == 0) { str.Append("the Quantity Needed, "); } if (str.Length > 0) { throw new ApplicationException(string.Format("You must provide {0}.", str.ToString().Substring(0, str.Length - 2))); } if (boms.Count() == 0) { //It is a new Product return(InsertBOM(bomRawMatID, bomFiniGoodID, bomQuantity, scrapFactor)); } SPG.BOMRow bom = boms[0]; object[] originalRecord = bom.ItemArray; bom.BOMRawMatID = bomRawMatID.Value; bom.BOMFiniGoodID = bomFiniGoodID.Value; bom.BOMQuantity = bomQuantity.Value; if (scrapFactor.HasValue) { bom.ScrapFactor = scrapFactor.Value; } else { bom.SetScrapFactorNull(); } if (!(originalRecord == null)) { UpdateAuditTrail(bom, originalRecord); } int rowsAffected = Adapter.Update(bom); return(rowsAffected == 1); }
public bool DeleteBOMByFGItemID(int FGItemID) { SPG.BOMDataTable boms = Adapter.GetBOMByFGItemID(FGItemID); int rowsAffected = 0; if (boms.Count() > 0) { rowsAffected = Adapter.DeleteBOMByFGItemID(FGItemID); } else { rowsAffected = 0; } return(Convert.ToBoolean(rowsAffected)); }