Exemplo n.º 1
0
        /// <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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
        /// <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;
            });
        }
Exemplo n.º 5
0
        private void CreateRecord()
        {
            bool           NewTransaction;
            TDBTransaction ReadWriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable,
                                                                                                    out NewTransaction);

            try
            {
                ALedgerInitFlagTable aLedgerInitFlagTable = ALedgerInitFlagAccess.LoadByPrimaryKey(
                    intLedgerNumber, strFlagName, ReadWriteTransaction);

                ALedgerInitFlagRow aLedgerInitFlagRow = (ALedgerInitFlagRow)aLedgerInitFlagTable.NewRow();
                aLedgerInitFlagRow.LedgerNumber   = intLedgerNumber;
                aLedgerInitFlagRow.InitOptionName = strFlagName;
                aLedgerInitFlagTable.Rows.Add(aLedgerInitFlagRow);

                ALedgerInitFlagAccess.SubmitChanges(aLedgerInitFlagTable, ReadWriteTransaction);

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }
            }
            catch (Exception Exc)
            {
                TLogging.Log("An Exception occured in CreateRecord:" + Environment.NewLine + Exc.ToString());

                if (NewTransaction)
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }

                throw;
            }
        }
Exemplo n.º 6
0
        /// <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;
                }
            }
        }
 // Normally this would be in the generated code, but this screen does not have any controls that are bound to this table (yet?)
 // If something changes and ShowData moves to generated code, this will become ShowDataManual
 private void ShowData(ALedgerRow ARow)
 {
     if ((FMainDS != null) && (FMainDS.ALedgerInitFlag != null))
     {
         FRequireApprovalDataRow = (ALedgerInitFlagRow)FMainDS.ALedgerInitFlag.Rows.Find(new object[] { FLedgerNumber, "AP_APPROVE_BLOCK" });
         chkRequireApproval.Checked = (FRequireApprovalDataRow != null);
     }
     else
     {
         throw new NullReferenceException("The GLSetupTDS dataset has not been initialised correctly");
     }
 }
Exemplo n.º 8
0
 // Normally this would be in the generated code, but this screen does not have any controls that are bound to this table (yet?)
 // If something changes and ShowData moves to generated code, this will become ShowDataManual
 private void ShowData(ALedgerRow ARow)
 {
     if ((FMainDS != null) && (FMainDS.ALedgerInitFlag != null))
     {
         FRequireApprovalDataRow    = (ALedgerInitFlagRow)FMainDS.ALedgerInitFlag.Rows.Find(new object[] { FLedgerNumber, "AP_APPROVE_BLOCK" });
         chkRequireApproval.Checked = (FRequireApprovalDataRow != null);
     }
     else
     {
         throw new NullReferenceException("The GLSetupTDS dataset has not been initialised correctly");
     }
 }
Exemplo n.º 9
0
        /// <summary>
        /// The named AFlag is a composite value (internally stored as CSV)
        /// This method adds the component, if it's not already present.
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="AFlag"></param>
        /// <param name="AComponent"></param>
        /// <param name="ADataBase"></param>
        public static void SetFlagComponent(int ALedgerNumber, String AFlag, String AComponent, TDataBase ADataBase = null)
        {
            ALedgerInitFlagRow Row = FindRecord(ALedgerNumber, AFlag, ADataBase);
            String             Val = (Row == null ? "" : Row.Value);

            if ((Val + ",").IndexOf(AComponent + ",") < 0) // I need to add this?
            {
                if (Val != "")
                {
                    Val += ",";
                }

                Val += AComponent;
                SetFlagValue(ALedgerNumber, AFlag, Val, ADataBase);
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// The named AFlag is a composite value (internally stored as CSV)
        /// This method removes the component, if it's present in AFlag.
        /// (If AFlag was not found, it's not created.)
        /// </summary>
        /// <param name="AFlag"></param>
        /// <param name="AComponent"></param>
        public void RemoveFlagComponent(String AFlag, String AComponent)
        {
            ALedgerInitFlagRow Row    = FindRecord(AFlag);
            String             Val    = (Row == null ? "" : Row.Value);
            String             NewVal = (Val + ",").Replace(AComponent + ",", "");

            if (NewVal != Val) // I need to remove this?
            {
                if (NewVal.Length > 0)
                {
                    NewVal = NewVal.Substring(0, NewVal.Length - 1); // the test above appended a comma to the string
                }

                SetFlagValue(AFlag, NewVal);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// The named AFlag is a composite value (internally stored as CSV)
        /// This method adds the component, if it's not already present.
        /// </summary>
        /// <param name="AFlag"></param>
        /// <param name="AComponent"></param>
        public void SetFlagComponent(String AFlag, String AComponent)
        {
            ALedgerInitFlagRow Row = FindRecord(AFlag);
            String             Val = (Row == null ? "" : Row.Value);

            if ((Val + ",").IndexOf(AComponent + ",") < 0) // I need to add this?
            {
                if (Val != "")
                {
                    Val += ",";
                }

                Val += AComponent;
                SetFlagValue(AFlag, Val);
            }
        }
Exemplo n.º 12
0
        private void GetDataFromControlsManual(ALedgerRow ARow)
        {
            if ((FRequireApprovalDataRow != null) && !chkRequireApproval.Checked)
            {
                // Turn off the requirement for AP approval
                FRequireApprovalDataRow.Delete();
            }

            if (chkRequireApproval.Checked && (FRequireApprovalDataRow == null))
            {
                // Turn on requirement for AP approval
                FRequireApprovalDataRow = FMainDS.ALedgerInitFlag.NewRowTyped();
                FRequireApprovalDataRow.LedgerNumber   = FLedgerNumber;
                FRequireApprovalDataRow.InitOptionName = "AP_APPROVE_BLOCK";
                FMainDS.ALedgerInitFlag.Rows.Add(FRequireApprovalDataRow);
            }
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        /// <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();
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// This more conventional string-based ValueStore is intended to replace the limited and over-complicated binary flag approach
        /// (which is preserved above, but no longer used for Reval, or anything else.)
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="AFlag"></param>
        /// <param name="ADataBase"></param>
        /// <returns></returns>
        public static String GetFlagValue(int ALedgerNumber, String AFlag, TDataBase ADataBase = null)
        {
            ALedgerInitFlagRow Row = FindRecord(ALedgerNumber, AFlag, ADataBase);

            return(Row == null ? "" : Row.Value);
        }
Exemplo n.º 16
0
        /// <summary>
        /// This more conventional string-based ValueStore is intended to replace the limited and over-complicated binary flag approach
        /// (which is preserved above, but no longer used for Reval, or anything else.)
        /// </summary>
        /// <param name="AFlag"></param>
        /// <returns></returns>
        public String GetFlagValue(String AFlag)
        {
            ALedgerInitFlagRow Row = FindRecord(AFlag);

            return(Row == null ? "" : Row.Value);
        }
        private void GetDataFromControlsManual(ALedgerRow ARow)
        {
            if ((FRequireApprovalDataRow != null) && !chkRequireApproval.Checked)
            {
                // Turn off the requirement for AP approval
                FRequireApprovalDataRow.Delete();
            }

            if (chkRequireApproval.Checked && (FRequireApprovalDataRow == null))
            {
                // Turn on requirement for AP approval
                FRequireApprovalDataRow = FMainDS.ALedgerInitFlag.NewRowTyped();
                FRequireApprovalDataRow.LedgerNumber = FLedgerNumber;
                FRequireApprovalDataRow.InitOptionName = "AP_APPROVE_BLOCK";
                FMainDS.ALedgerInitFlag.Rows.Add(FRequireApprovalDataRow);
            }
        }
 /// <summary>
 /// The data has been saved on the main form, either using the OK or the Apply button
 /// </summary>
 public void OnDataSaved()
 {
     // The data has been saved.  Not sure if we need to get a new reference to our data row of interest??
     FRequireApprovalDataRow = (ALedgerInitFlagRow)FMainDS.ALedgerInitFlag.Rows.Find(new object[] { FLedgerNumber, "AP_APPROVE_BLOCK" });
 }
Exemplo n.º 19
0
 /// <summary>
 /// The data has been saved on the main form, either using the OK or the Apply button
 /// </summary>
 public void OnDataSaved()
 {
     // The data has been saved.  Not sure if we need to get a new reference to our data row of interest??
     FRequireApprovalDataRow = (ALedgerInitFlagRow)FMainDS.ALedgerInitFlag.Rows.Find(new object[] { FLedgerNumber, "AP_APPROVE_BLOCK" });
 }