public CurrencyData UpdateCurrency(string account, byte currencyType, int currency) { CurrencyData currencyData = new CurrencyData(); currencyData.ReturnCode = "(Logic)S700"; currencyData.ReturnMessage = ""; try { // to do check int rice = 0; Int16 gold = 0; CurrencyIO currencyIO = new CurrencyIO(); currencyData = currencyIO.LoadCurrency(account); switch (currencyType) { case 0: { if (currencyData.Rice > currency) { rice = currencyData.Rice - currency; currencyData = currencyIO.UpdateCurrency(account, rice); } else { currencyData.ReturnMessage = "遊戲幣不足!"; currencyData.ReturnCode = "S711"; } break; } case 1: { if (currencyData.Gold > currency) { gold = (Int16)(currencyData.Gold - (Int16)currency); currencyData = currencyIO.UpdateCurrency(account, gold); } else { currencyData.ReturnMessage = "金幣不足!"; currencyData.ReturnCode = "S712"; } break; } default: currencyData.ReturnMessage = "金流資料未知例外情況!"; currencyData.ReturnCode = "S799"; break; } } catch (Exception e) { throw e; } return(currencyData); }