Work on Attestation, Concurrency. Db0017.
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Swarmops.Database
|
||||
/// </summary>
|
||||
public static int DbVersionExpected
|
||||
{
|
||||
get { return 16; }
|
||||
get { return 17; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using Swarmops.Basic.Types.Financial;
|
||||
using Swarmops.Common.Exceptions;
|
||||
|
||||
namespace Swarmops.Database
|
||||
{
|
||||
@@ -141,6 +142,29 @@ namespace Swarmops.Database
|
||||
}
|
||||
|
||||
|
||||
public void SetCashAdvanceAmountCents(int cashAdvanceId, Int64 amountCents)
|
||||
{
|
||||
using (DbConnection connection = GetMySqlDbConnection())
|
||||
{
|
||||
connection.Open();
|
||||
|
||||
DbCommand command = GetDbCommand("SetCashAdvanceAmountCents", connection);
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
|
||||
AddParameterWithName(command, "cashAdvanceId", cashAdvanceId);
|
||||
AddParameterWithName(command, "amountCents", amountCents);
|
||||
|
||||
if (Convert.ToInt32(command.ExecuteScalar()) != 1) // returns count of rows updated
|
||||
{
|
||||
// This assumes that the cash advance ID existed, but that another sesssion modified it first,
|
||||
// so the selector failed on the Open=1 and PaidOut=0 criteria rather than the Id=X criterion.
|
||||
|
||||
throw new DatabaseConcurrencyException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetCashAdvanceOpen(int cashAdvanceId, bool open)
|
||||
{
|
||||
using (DbConnection connection = GetMySqlDbConnection())
|
||||
|
||||
@@ -13,4 +13,5 @@
|
||||
0013 - Added PositionTitles for organizational culture flexibility [RF]
|
||||
0014 - Forgot one storedproc in Db0012; renamed CreateAssignedRole [RF]
|
||||
0015 - Merged PositionsStandard and PositionsAdditional into one table [RF]
|
||||
0016 - Added SetCashAdvanceBudget procedure [RF]
|
||||
0016 - Added SetCashAdvanceBudget procedure [RF]
|
||||
0017 - Added SetCashAdvanceAmountCents procedure [RF]
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
CREATE PROCEDURE `SetCashAdvanceAmountCents`(
|
||||
IN cashAdvanceId INTEGER,
|
||||
IN amountCents INTEGER
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE CashAdvances SET CashAdvances.AmountCents=amountCents
|
||||
WHERE CashAdvances.CashAdvanceId=cashAdvanceId
|
||||
AND CashAdvances.PaidOut=0
|
||||
AND CashAdvances.Open=1;
|
||||
|
||||
SELECT ROW_COUNT() AS RecordsUpdated;
|
||||
|
||||
END
|
||||
Reference in New Issue
Block a user