private bool onClose(InventoryDataRecord updatedRecord) { finalRecord = updatedRecord; Logger.LogG("Item Info closed..."); return(true); }
public ItemDataWindow(Window callingWindow, IDataRecord record, Func <InventoryDataRecord, bool> closeCallback) { InitializeComponent(); Owner = callingWindow; onClose = closeCallback; //Check to make sure proper record is passed into the constructor if (!(record is InventoryDataRecord)) { throw new IllegalStateException( "Cannot pass this record type into this window, expected InventoryDataRecord!"); } finalRecord = (InventoryDataRecord)record; //Load all the fields ItemID.Text = record.Get("ItemId"); CatID.Text = record.Get("CatID"); Description.Text = record.Get("Description"); //Set save button ItemSaveButton.Click += (s, e) => { //Gather all the fields, and update them in our final record; finalRecord.SetField("ItemId", ItemID.Text); finalRecord.SetField("CatID", CatID.Text); finalRecord.SetField("Description", Description.Text); Close(); }; }
public InventoryDataWindow(IDataRecord record) { InitializeComponent(); //Check to make sure the correct version of the DataRecord is passed if (!(record is InventoryDataRecord)) { throw new IllegalStateException("Cannot pass this type of Data Record to this window, expected InventoryDataRecord."); } finalRecord = (InventoryDataRecord)record; //Load all the fields InvID.Text = finalRecord.Get("InvID"); ItemQuantity.Text = finalRecord.Get("Quantity"); ItemName.Text = finalRecord.Get("Name"); LastRestock.Text = finalRecord.Get("LastRestocked"); ItemPrice.Text = finalRecord.Get("Price"); //Set buttons ItemDetailsButton.Click += (s, a) => { new ItemDataWindow(this, finalRecord, onClose).Show(); }; UpdateButton.Click += (s, a) => { finalRecord.SetField("InvID", InvID.Text); finalRecord.SetField("Quantity", ItemQuantity.Text); finalRecord.SetField("Name", ItemName.Text); finalRecord.SetField("LastRestocked", LastRestock.Text); finalRecord.SetField("Price", ItemPrice.Text); //Call update routine on final record to finalize in database finalRecord.Update(); Close(); //Close window! }; }