public void AddAssetHistory(AssetHistoryData item) { hasError = false; try { TraditionAssetEntities db = new TraditionAssetEntities(); var data = new asset_history() { asset_history_id = item.Asset_history_id, user_id = item.User_id, asset_id = item.Asset_id, asset_history_type = item.Asset_history_type, remark = item.Remark, history_timestamp = item.History_timestamp }; db.asset_history.Add(data); db.SaveChanges(); MessageBox.Show("Insert complete"); } catch (Exception ex) { errorMessage = "Add error, " + ex.Message; hasError = true; } }
public ObservableCollection <AssetHistoryTypeData> GetAssetHistoryTypeNameFromAssetHistoryType(AssetHistoryData item) { hasError = false; ObservableCollection <AssetHistoryTypeData> _result = new ObservableCollection <AssetHistoryTypeData>(); try { TraditionAssetEntities db = new TraditionAssetEntities(); var query = db.asset_history_type.FirstOrDefault(x => x.asset_history_type_id == item.Asset_history_type); if (query != null) { AssetHistoryTypeData pTemp = new AssetHistoryTypeData(/*item*/); pTemp.Type_code = query.type_code; _result.Add(pTemp); } else { MessageBox.Show("NOT FOUND"); } } catch (Exception ex) { errorMessage = "GetAssetHistoryTypeNameFromAssetHistoryType() error, " + ex.Message; hasError = true; } return(_result); }