private void DeleteRecord() { bool NewTransaction; TDBTransaction ReadWriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction); try { ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( intLedgerNumber, strFlagName, ReadWriteTransaction); if (aLedgerInitFlagTable.Rows.Count == 1) { ((ALedgerInitFlagRow)aLedgerInitFlagTable.Rows[0]).Delete(); ALedgerInitFlagAccess.SubmitChanges(aLedgerInitFlagTable, ReadWriteTransaction); } if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } } catch (Exception Exc) { TLogging.Log("An Exception occured in DeleteRecord:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } }
private void CreateRecord() { TDBTransaction ReadWriteTransaction = null; Boolean SubmissionOK = false; try { DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref ReadWriteTransaction, ref SubmissionOK, delegate { ALedgerInitFlagTable ledgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( FLedgerNumber, FFlagName, ReadWriteTransaction); ALedgerInitFlagRow ledgerInitFlagRow = (ALedgerInitFlagRow)ledgerInitFlagTable.NewRow(); ledgerInitFlagRow.LedgerNumber = FLedgerNumber; ledgerInitFlagRow.InitOptionName = FFlagName; ledgerInitFlagTable.Rows.Add(ledgerInitFlagRow); ALedgerInitFlagAccess.SubmitChanges(ledgerInitFlagTable, ReadWriteTransaction); SubmissionOK = true; }); } catch (Exception ex) { TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}", Utilities.GetMethodSignature(), Environment.NewLine, ex.Message)); throw ex; } }
private bool FindRecord() { bool boolValue; bool NewTransaction; TDBTransaction ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( intLedgerNumber, strFlagName, ReadTransaction); boolValue = (aLedgerInitFlagTable.Rows.Count == 1); if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } } catch (Exception Exc) { TLogging.Log("An Exception occured in FindRecord:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } return(boolValue); }
/// <summary> /// /// </summary> public string LockInfo() { if (!blnResult) { try { bool NewTransaction; TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( intLegerNumber, TLedgerInitFlagEnum.LedgerLock.ToString(), Transaction); ALedgerInitFlagRow aLedgerInitFlagRow = (ALedgerInitFlagRow)aLedgerInitFlagTable.Rows[0]; string strAnswer = aLedgerInitFlagRow.CreatedBy + " - " + DateTime.Parse(aLedgerInitFlagRow.DateCreated.ToString()).ToLongDateString(); if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } return(strAnswer); } catch (Exception) { return(Catalog.GetString("Free Again")); } } else { return(String.Empty); } }
private void DeleteFlag(String AFlag) { TDBTransaction Transaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("DeleteFlag", FDataBase); Boolean SubmissionOK = true; db.WriteTransaction( ref Transaction, ref SubmissionOK, delegate { ALedgerInitFlagTable LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( FLedgerNumber, AFlag, Transaction); if (LedgerInitFlagTable.Rows.Count == 1) { LedgerInitFlagTable[0].Delete(); ALedgerInitFlagAccess.SubmitChanges(LedgerInitFlagTable, Transaction); } }); if (FDataBase == null) { db.CloseDBConnection(); } }
private ALedgerInitFlagRow FindRecord(String AFlag) { TDBTransaction ReadTransaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("FindRecord", FDataBase); ALedgerInitFlagTable LedgerInitFlagTable = null; ALedgerInitFlagRow Ret = null; db.ReadTransaction( ref ReadTransaction, delegate { LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(FLedgerNumber, AFlag, ReadTransaction); if ((LedgerInitFlagTable != null) && (LedgerInitFlagTable.Rows.Count == 1)) { Ret = LedgerInitFlagTable[0]; } }); if (FDataBase == null) { db.CloseDBConnection(); } return(Ret); }
private bool FindRecord() { bool RecordFound = false; TDBTransaction ReadTransaction = null; ALedgerInitFlagTable LedgerInitFlagTable = null; try { DBAccess.GDBAccessObj.GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref ReadTransaction, delegate { LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(FLedgerNumber, FFlagName, ReadTransaction); RecordFound = (LedgerInitFlagTable != null && LedgerInitFlagTable.Rows.Count == 1); }); } catch (Exception ex) { TLogging.Log(String.Format("Method:{0} - Unexpected error!{1}{1}{2}", Utilities.GetMethodSignature(), Environment.NewLine, ex.Message)); throw ex; } return(RecordFound); }
/// <summary> /// /// </summary> /// <param name="ALedgerNumber"></param> /// <param name="AFlag"></param> /// <param name="AValue"></param> /// <param name="ADataBase"></param> public static void SetFlagValue(int ALedgerNumber, String AFlag, String AValue, TDataBase ADataBase = null) { TDBTransaction ReadWriteTransaction = null; Boolean SubmissionOK = false; DBAccess.GetDBAccessObj(ADataBase).GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref ReadWriteTransaction, ref SubmissionOK, delegate { ALedgerInitFlagTable ledgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( ALedgerNumber, AFlag, ReadWriteTransaction); ALedgerInitFlagRow ledgerInitFlagRow = ledgerInitFlagTable.Rows.Count == 0 ? ledgerInitFlagTable.NewRowTyped() : ledgerInitFlagTable[0]; ledgerInitFlagRow.LedgerNumber = ALedgerNumber; ledgerInitFlagRow.InitOptionName = AFlag; ledgerInitFlagRow.Value = AValue; if (ledgerInitFlagTable.Rows.Count == 0) { ledgerInitFlagTable.Rows.Add(ledgerInitFlagRow); } ALedgerInitFlagAccess.SubmitChanges(ledgerInitFlagTable, ReadWriteTransaction); SubmissionOK = true; }); }
/// <summary> /// /// </summary> public TLedgerLock(int ALedgerNum) { bool NewTransaction; intLegerNumber = ALedgerNum; TDBTransaction Transaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction); ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( intLegerNumber, TLedgerInitFlagEnum.LedgerLock.ToString(), Transaction); ALedgerInitFlagRow aLedgerInitFlagRow = (ALedgerInitFlagRow)aLedgerInitFlagTable.NewRow(); aLedgerInitFlagRow.LedgerNumber = intLegerNumber; aLedgerInitFlagRow.InitOptionName = TLedgerInitFlagEnum.LedgerLock.ToString(); lock (synchRoot) { try { aLedgerInitFlagTable.Rows.Add(aLedgerInitFlagRow); ALedgerInitFlagAccess.SubmitChanges(aLedgerInitFlagTable, Transaction); blnResult = true; if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } } catch (System.Data.ConstraintException Exc) { TLogging.Log("A ConstraintException occured during a call to the TLedgerLock constructor:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } blnResult = false; throw; } catch (Exception Exc) { TLogging.Log("An Exception occured during during a call to the TLedgerLock constructor:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } blnResult = false; throw; } } }
private void DeleteRecord() { TDBTransaction Transaction = null; Boolean SubmissionOK = true; DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, ref SubmissionOK, delegate { ALedgerInitFlagTable LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( FLedgerNumber, FFlagName, Transaction); if (LedgerInitFlagTable.Rows.Count == 1) { ((ALedgerInitFlagRow)LedgerInitFlagTable.Rows[0]).Delete(); ALedgerInitFlagAccess.SubmitChanges(LedgerInitFlagTable, Transaction); } }); }
private static ALedgerInitFlagRow FindRecord(int ALedgerNumber, String AFlag, TDataBase ADataBase = null) { TDBTransaction ReadTransaction = null; ALedgerInitFlagTable LedgerInitFlagTable = null; ALedgerInitFlagRow Ret = null; DBAccess.GetDBAccessObj(ADataBase).GetNewOrExistingAutoReadTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, ref ReadTransaction, delegate { LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(ALedgerNumber, AFlag, ReadTransaction); if ((LedgerInitFlagTable != null) && (LedgerInitFlagTable.Rows.Count == 1)) { Ret = LedgerInitFlagTable[0]; } }); return(Ret); }
private static void DeleteFlag(int ALedgerNumber, String AFlag, TDataBase ADataBase = null) { TDBTransaction Transaction = null; Boolean SubmissionOK = true; DBAccess.GetDBAccessObj(ADataBase).GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, ref Transaction, ref SubmissionOK, delegate { ALedgerInitFlagTable LedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( ALedgerNumber, AFlag, Transaction); if (LedgerInitFlagTable.Rows.Count == 1) { LedgerInitFlagTable[0].Delete(); ALedgerInitFlagAccess.SubmitChanges(LedgerInitFlagTable, Transaction); } }); }
/// <summary> /// /// </summary> public void SetFlagAndName(string AName) { bool NewTransaction; TDBTransaction WriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, out NewTransaction); ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( intLedgerNumber, strFlagName, WriteTransaction); ALedgerInitFlagRow aLedgerInitFlagRow = (ALedgerInitFlagRow)aLedgerInitFlagTable.NewRow(); aLedgerInitFlagRow.LedgerNumber = intLedgerNumber; aLedgerInitFlagRow.InitOptionName = strFlagName; aLedgerInitFlagTable.Rows.Add(aLedgerInitFlagRow); try { ALedgerInitFlagAccess.SubmitChanges(aLedgerInitFlagTable, WriteTransaction); if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } } catch (Exception Exc) { TLogging.Log("An Exception occured in SetFlagAndName:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } }
/// <summary> /// /// </summary> /// <param name="AFlag"></param> /// <param name="AValue"></param> public void SetFlagValue(String AFlag, String AValue) { TDBTransaction ReadWriteTransaction = new TDBTransaction(); TDataBase db = DBAccess.Connect("SetFlagValue", FDataBase); Boolean SubmissionOK = false; db.WriteTransaction( ref ReadWriteTransaction, ref SubmissionOK, delegate { ALedgerInitFlagTable ledgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey( FLedgerNumber, AFlag, ReadWriteTransaction); ALedgerInitFlagRow ledgerInitFlagRow = ledgerInitFlagTable.Rows.Count == 0 ? ledgerInitFlagTable.NewRowTyped() : ledgerInitFlagTable[0]; ledgerInitFlagRow.LedgerNumber = FLedgerNumber; ledgerInitFlagRow.InitOptionName = AFlag; ledgerInitFlagRow.Value = AValue; if (ledgerInitFlagTable.Rows.Count == 0) { ledgerInitFlagTable.Rows.Add(ledgerInitFlagRow); } ALedgerInitFlagAccess.SubmitChanges(ledgerInitFlagTable, ReadWriteTransaction); SubmissionOK = true; }); if (FDataBase == null) { db.CloseDBConnection(); } }