public static void update(Guid id, string name, GordenItemCategories category, Guid vendorID, Guid retailLengthUnitID, Guid bulkLengthUnitID, Guid?productWidthID, decimal?buyRetailPricePerUnit, decimal?buyBulkPricePerUnit, decimal?sellRetailPricePerUnit, decimal?sellBulkPricePerUnit, string notes) { try { GordenItem objOld = new GordenItem(id); //generate log description string log = ""; log = ActivityLog.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.CategoryName, category, "Category: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.VendorID, new Vendor(vendorID).Name, "Vendor: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.ProductWidthID, new ProductWidth(productWidthID).Name, "Width: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.RetailLengthUnitID, new LengthUnit(retailLengthUnitID).Name, "Retail Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.BulkLengthUnitID, new LengthUnit(bulkLengthUnitID).Name, "Bulk Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.BuyRetailPricePerUnit, buyRetailPricePerUnit, "Buy Retail Price/Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.BuyBulkPricePerUnit, buyBulkPricePerUnit, "Buy Bulk Price/Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.SellRetailPricePerUnit, sellRetailPricePerUnit, "Sell Retail Price/Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.SellBulkPricePerUnit, sellBulkPricePerUnit, "Sell Bulk Price/Unit: '{0}' to '{1}'"); log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'"); if (string.IsNullOrEmpty(log)) { Tools.showError("No changes to record"); } else { using (SqlCommand cmd = new SqlCommand("gordenitem_update", DBConnection.ActiveSqlConnection)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value = id; cmd.Parameters.Add("@" + COL_DB_NAME, SqlDbType.VarChar).Value = name; cmd.Parameters.Add("@" + COL_DB_CATEGORYENUMID, SqlDbType.TinyInt).Value = category; cmd.Parameters.Add("@" + COL_DB_VENDORID, SqlDbType.UniqueIdentifier).Value = vendorID; cmd.Parameters.Add("@" + COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier).Value = Util.wrapNullable(productWidthID); cmd.Parameters.Add("@" + COL_DB_RETAILLENGTHUNITID, SqlDbType.UniqueIdentifier).Value = retailLengthUnitID; cmd.Parameters.Add("@" + COL_DB_BULKLENGTHUNITID, SqlDbType.UniqueIdentifier).Value = bulkLengthUnitID; cmd.Parameters.Add("@" + COL_DB_BUYRETAILPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(buyRetailPricePerUnit); cmd.Parameters.Add("@" + COL_DB_BUYBULKPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(buyBulkPricePerUnit); cmd.Parameters.Add("@" + COL_DB_SELLRETAILPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(sellRetailPricePerUnit); cmd.Parameters.Add("@" + COL_DB_SELLBULKPRICEPERUNIT, SqlDbType.Decimal).Value = Util.wrapNullable(sellBulkPricePerUnit); cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value = Util.wrapNullable(notes); cmd.ExecuteNonQuery(); ActivityLog.submit(id, "UPDATE: " + log); } Tools.hasMessage("Item updated"); } } catch (Exception ex) { Tools.showError(ex.Message); } }
public GordenOrderItemMaterial(Guid?gordenOrderItemID, Guid gordenItemID, decimal qty, string notes) { ID = Guid.NewGuid(); if (gordenOrderItemID != null) { GordenOrderItemID = (Guid)gordenOrderItemID; } Qty = qty; Notes = notes; GordenItem item = new GordenItem(GordenItemID); GordenItemID = item.ID; Description = item.Name; BuyAmountPerUnit = item.SellRetailPricePerUnit; }