コード例 #1
0
ファイル: InventoryBOMsBLL.cs プロジェクト: shulemg/SPG
        public bool UpdateInventoryBOM(int?InventoryBOMsID, int?InventoryBOMsRawMatID, int?InventoryBOMsInventoryID, float?InventoryBOMsQuantity, double?scrapFactor)
        {
            SPG.InventoryBOMsDataTable inventoryBOMs = Adapter.GetInventoryBOMByID(InventoryBOMsID.Value);

            if (!InventoryBOMsRawMatID.HasValue)
            {
                throw new ApplicationException("You must provide a RM ID.");
            }

            if (!InventoryBOMsQuantity.HasValue || InventoryBOMsQuantity.Value == 0)
            {
                throw new ApplicationException("You must provide the Quantity Used.");
            }

            if (inventoryBOMs.Count() == 0)
            {
                //It is a new Product
                return(InsertInventoryBOM(InventoryBOMsRawMatID, InventoryBOMsInventoryID, InventoryBOMsQuantity, scrapFactor));
            }

            SPG.InventoryBOMsRow inventoryBOM = inventoryBOMs[0];

            object[] originalRecord = inventoryBOM.ItemArray;

            SetInventoryBOMFields(InventoryBOMsRawMatID, InventoryBOMsInventoryID, InventoryBOMsQuantity, scrapFactor, inventoryBOM);

            if (!(originalRecord == null))
            {
                UpdateAuditTrail(inventoryBOM, originalRecord);
            }

            int rowsAffected = Adapter.Update(inventoryBOM);

            return(rowsAffected == 1);
        }
コード例 #2
0
ファイル: InventoryBOMsBLL.cs プロジェクト: shulemg/SPG
        public bool InsertInventoryBOM(int?InventoryBOMsRawMatID, int?InventoryBOMsInventoryID, float?InventoryBOMsQuantity, double?scrapFactor)
        {
            SPG.InventoryBOMsDataTable inventoryBOMs = new SPG.InventoryBOMsDataTable();
            SPG.InventoryBOMsRow       inventoryBOM  = inventoryBOMs.NewInventoryBOMsRow();

            SetInventoryBOMFields(InventoryBOMsRawMatID, InventoryBOMsInventoryID, InventoryBOMsQuantity, scrapFactor, inventoryBOM);

            inventoryBOMs.AddInventoryBOMsRow(inventoryBOM);
            int rowsAffected = Adapter.Update(inventoryBOMs);

            return(rowsAffected == 1);
        }
コード例 #3
0
ファイル: InventoryBOMsBLL.cs プロジェクト: shulemg/SPG
        private void UpdateAuditTrail(SPG.InventoryBOMsRow ModifiedRecord, object[] originalRecord)
        {
            StringBuilder builder      = new StringBuilder(string.Empty);
            int           recordFields = (ModifiedRecord.ItemArray.Length - 1);
            int           i            = 0;

            while (i <= recordFields)
            {
                try
                {
                    if (Convert.IsDBNull(originalRecord[i]))
                    {
                        if (!Convert.IsDBNull(ModifiedRecord[i]))
                        {
                            builder.Append(string.Format("{0}:{1}({2}); ", ModifiedRecord.Table.Columns[i].ColumnName, "NULL", ModifiedRecord[i]));
                        }
                    }
                    else if (Convert.IsDBNull(ModifiedRecord[i]))
                    {
                        if (!Convert.IsDBNull(originalRecord[i]))
                        {
                            builder.Append(string.Format("{0}:{1}({2}); ", ModifiedRecord.Table.Columns[i].ColumnName, originalRecord[i], "NULL"));
                        }
                    }
                    else if (ModifiedRecord[i] != originalRecord[i])
                    {
                        builder.Append(string.Format("{0}:{1}({2}); ", ModifiedRecord.Table.Columns[i].ColumnName, originalRecord[i], ModifiedRecord[i]));
                    }
                }
                catch
                {
                }
                i += 1;
            }
            if (builder.Length > 2)
            {
                builder.Length = (builder.Length - 2);
                AuditTrailBLL.AddTrailEntry(Properties.Settings.Default.UserName, Convert.ToInt32(ModifiedRecord[0]), "InventoryBOM", builder.ToString());
            }
        }
コード例 #4
0
ファイル: InventoryBOMsBLL.cs プロジェクト: shulemg/SPG
 private static void SetInventoryBOMFields(int?InventoryBOMsRawMatID, int?InventoryBOMsInventoryID, float?InventoryBOMsQuantity, double?scrapFactor, SPG.InventoryBOMsRow inventoryBOM)
 {
     inventoryBOM.InventoryBOMRawMatID    = InventoryBOMsRawMatID.Value;
     inventoryBOM.InventoryBOMInventoryID = InventoryBOMsInventoryID.Value;
     inventoryBOM.InventoryBOMQuantity    = InventoryBOMsQuantity.Value;
     if (scrapFactor.HasValue)
     {
         inventoryBOM.ScrapFactor = scrapFactor.Value;
     }
     else
     {
         inventoryBOM.SetScrapFactorNull();
     }
 }