/// <summary> /// close the screen and return the selected extract as accepted record /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AcceptExtract(System.Object sender, EventArgs e) { MExtractMasterRow ExtractMasterRow; FResultTable = new MExtractMasterTable(); //MExtractMasterRow SelectedRow = null; DataRow SelectedRow = null; if (AllowMultipleSelect) { // multiple rows may have been selected: find all the ones where first column is ticked foreach (DataRow Row in FDataTable.Rows) { if (Convert.ToBoolean(Row[FCheckedColumnName]) == true) { ExtractMasterRow = FResultTable.NewRowTyped(); ExtractMasterRow.ExtractId = (int)Row[MExtractMasterTable.GetExtractIdDBName()]; ExtractMasterRow.ExtractName = Row[MExtractMasterTable.GetExtractNameDBName()].ToString(); ExtractMasterRow.ExtractDesc = Row[MExtractMasterTable.GetExtractDescDBName()].ToString(); ExtractMasterRow.KeyCount = (int)Row[MExtractMasterTable.GetKeyCountDBName()]; ExtractMasterRow.CreatedBy = Row[MExtractMasterTable.GetCreatedByDBName()].ToString(); ExtractMasterRow.DateCreated = (DateTime)Row[MExtractMasterTable.GetDateCreatedDBName()]; FResultTable.Rows.Add(ExtractMasterRow); } } } else { // just one row can be selected DataRowView[] SelectedGridRow = clbDetails.SelectedDataRowsAsDataRowView; if (SelectedGridRow.Length >= 1) { SelectedRow = SelectedGridRow[0].Row; ExtractMasterRow = FResultTable.NewRowTyped(); ExtractMasterRow.ExtractId = (int)SelectedRow[MExtractMasterTable.GetExtractIdDBName()]; ExtractMasterRow.ExtractName = SelectedRow[MExtractMasterTable.GetExtractNameDBName()].ToString(); ExtractMasterRow.ExtractDesc = SelectedRow[MExtractMasterTable.GetExtractDescDBName()].ToString(); ExtractMasterRow.KeyCount = (int)SelectedRow[MExtractMasterTable.GetKeyCountDBName()]; ExtractMasterRow.CreatedBy = SelectedRow[MExtractMasterTable.GetCreatedByDBName()].ToString(); ExtractMasterRow.DateCreated = (DateTime)SelectedRow[MExtractMasterTable.GetDateCreatedDBName()]; FResultTable.Rows.Add(ExtractMasterRow); } } Close(); }
/// <summary> /// Open Dialog to find extracts to be added list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddExtractToList(System.Object sender, EventArgs e) { TFrmExtractFindDialog ExtractFindDialog = new TFrmExtractFindDialog(this.ParentForm); MExtractMasterTable ExtractMasterTable = new MExtractMasterTable(); MExtractMasterRow NewRow; // let the user select base extract ExtractFindDialog.AllowMultipleSelect = true; ExtractFindDialog.ShowDialog(true); // get data for selected base extract ExtractFindDialog.GetResult(ref ExtractMasterTable); ExtractFindDialog.Dispose(); // only continue if an extract was selected foreach (MExtractMasterRow Row in ExtractMasterTable.Rows) { if (!FExtractMasterTable.Rows.Contains(new object[] { Row.ExtractId })) { NewRow = FExtractMasterTable.NewRowTyped(); NewRow.ExtractId = Row.ExtractId; NewRow.ExtractName = Row.ExtractName; NewRow.ExtractDesc = Row.ExtractDesc; NewRow.KeyCount = Row.KeyCount; NewRow.CreatedBy = Row.CreatedBy; NewRow.DateCreated = Row.DateCreated; FExtractMasterTable.Rows.Add(NewRow); btnRemove.Enabled = true; } } }
/// <summary> /// Called by the instantiator of this Dialog to retrieve the result of the dialog /// /// </summary> /// <param name="AExtractMasterTable"></param> /// <returns>true if at least one row was selected /// </returns> public bool GetResult(ref MExtractMasterTable AExtractMasterTable) { MExtractMasterRow NewRow; AExtractMasterTable.Clear(); if (FResultTable == null) { return(false); } foreach (MExtractMasterRow Row in FResultTable.Rows) { NewRow = AExtractMasterTable.NewRowTyped(); NewRow.ExtractId = Row.ExtractId; NewRow.ExtractName = Row.ExtractName; NewRow.ExtractDesc = Row.ExtractDesc; NewRow.KeyCount = Row.KeyCount; NewRow.CreatedBy = Row.CreatedBy; NewRow.DateCreated = Row.DateCreated; AExtractMasterTable.Rows.Add(NewRow); } return(AExtractMasterTable.Count >= 0); }
public static Boolean GetExtractDescription(String AExtractName, out String AExtractDescription) { TDBTransaction ReadTransaction; Boolean NewTransaction; Boolean ReturnValue = false; AExtractDescription = "Can not retrieve description"; TLogging.LogAtLevel(9, "TPartnerServerLookups.GetExtractDescription called!"); MExtractMasterTable ExtractMasterDT = new MExtractMasterTable(); ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); // Load data MExtractMasterTable TemplateExtractDT = new MExtractMasterTable(); MExtractMasterRow TemplateRow = TemplateExtractDT.NewRowTyped(false); TemplateRow.ExtractName = AExtractName; try { ExtractMasterDT = MExtractMasterAccess.LoadUsingTemplate(TemplateRow, ReadTransaction); } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TPartnerServerLookups.GetExtractDescription: committed own transaction."); } } if (ExtractMasterDT.Rows.Count < 1) { ReturnValue = false; TLogging.LogAtLevel(7, "TPartnerServerLookups.TPartnerServerLookups.GetExtractDescription: m_extract_master DB Table is empty"); } else { MExtractMasterRow ExtractRow = ExtractMasterDT.Rows[0] as MExtractMasterRow; if (ExtractRow != null) { AExtractDescription = ExtractRow.ExtractDesc; ReturnValue = true; } } return(ReturnValue); }
/// <summary> /// Pre-select an extract to be displayed in the grid. /// </summary> /// <param name="ARow"></param> public void PreSelectExtract(MExtractMasterRow ARow) { if (FMode == TMode.ecisSubtractMode) { txtBaseExtract.Text = ARow.ExtractName; } else { MExtractMasterRow NewRow = FExtractMasterTable.NewRowTyped(); NewRow.ExtractId = ARow.ExtractId; NewRow.ExtractName = ARow.ExtractName; NewRow.ExtractDesc = ARow.ExtractDesc; NewRow.KeyCount = ARow.KeyCount; NewRow.CreatedBy = ARow.CreatedBy; NewRow.DateCreated = ARow.DateCreated; FExtractMasterTable.Rows.Add(NewRow); grdExtracts.SelectRowInGrid(1); btnRemove.Enabled = true; } }
/// <summary> /// Creates a new extract with the given extract name and extract description in the /// m_extract_master data table. The Extract Id and the Extract Name must both be /// unique in the Petra Database. /// </summary> /// <param name="AExtractName">Name of the Extract to be created.</param> /// <param name="AExtractDescription">Description of the Extract to be created.</param> /// <param name="ANewExtractId">Extract Id of the created Extract, or -1 if the /// creation of the Extract was not successful.</param> /// <param name="AExtractAlreadyExists">True if there is already an extract with /// the given name, otherwise false.</param> /// <returns>True if the new Extract was created, otherwise false.</returns> public static bool CreateNewExtract(String AExtractName, String AExtractDescription, out Int32 ANewExtractId, out Boolean AExtractAlreadyExists) { TDBTransaction Transaction = null; Boolean ReturnValue = false; bool SubmissionOK = false; MExtractMasterTable NewExtractMasterDT = null; MExtractMasterRow TemplateRow = null; Boolean ExtractAlreadyExists = false; Int32 NewExtractId = -1; TLogging.LogAtLevel(9, "CreateNewExtract called!"); DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK, delegate { // Check if there is already an extract with the extract name if (!CheckExtractExists(AExtractName)) { // The extract name is unique. So create the new extract... NewExtractMasterDT = new MExtractMasterTable(); TemplateRow = (MExtractMasterRow)NewExtractMasterDT.NewRowTyped(true); TemplateRow.ExtractName = AExtractName; TemplateRow.ExtractDesc = AExtractDescription; TemplateRow.ExtractId = -1; // initialize id negative so sequence can be used NewExtractMasterDT.Rows.Add(TemplateRow); MExtractMasterAccess.SubmitChanges(NewExtractMasterDT, Transaction); // Get the Extract Id TemplateRow = (MExtractMasterRow)NewExtractMasterDT.Rows[0]; NewExtractId = TemplateRow.ExtractId; SubmissionOK = true; ReturnValue = true; } else { ExtractAlreadyExists = true; ReturnValue = false; } if (ReturnValue) { SubmissionOK = true; } else { SubmissionOK = false; } }); // Get the Extract Id // if (NewExtractMasterDT != null) // { // TemplateRow = (MExtractMasterRow)NewExtractMasterDT.Rows[0]; // ANewExtractId = TemplateRow.ExtractId; // } ANewExtractId = NewExtractId; AExtractAlreadyExists = ExtractAlreadyExists; return ReturnValue; }
public static Boolean GetExtractDescription(String AExtractName, out String AExtractDescription) { TDBTransaction ReadTransaction; Boolean NewTransaction; Boolean ReturnValue = false; AExtractDescription = "Can not retrieve description"; TLogging.LogAtLevel(9, "TPartnerServerLookups.GetExtractDescription called!"); MExtractMasterTable ExtractMasterDT = new MExtractMasterTable(); ReadTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.ReadCommitted, TEnforceIsolationLevel.eilMinimum, out NewTransaction); // Load data MExtractMasterTable TemplateExtractDT = new MExtractMasterTable(); MExtractMasterRow TemplateRow = TemplateExtractDT.NewRowTyped(false); TemplateRow.ExtractName = AExtractName; try { ExtractMasterDT = MExtractMasterAccess.LoadUsingTemplate(TemplateRow, ReadTransaction); } finally { if (NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); TLogging.LogAtLevel(7, "TPartnerServerLookups.GetExtractDescription: committed own transaction."); } } if (ExtractMasterDT.Rows.Count < 1) { ReturnValue = false; TLogging.LogAtLevel(7, "TPartnerServerLookups.TPartnerServerLookups.GetExtractDescription: m_extract_master DB Table is empty"); } else { MExtractMasterRow ExtractRow = ExtractMasterDT.Rows[0] as MExtractMasterRow; if (ExtractRow != null) { AExtractDescription = ExtractRow.ExtractDesc; ReturnValue = true; } } return ReturnValue; }
/// <summary> /// Creates a new extract with the given extract name and extract description in the /// m_extract_master data table. The Extract Id and the Extract Name must both be /// unique in the Petra Database. /// </summary> /// <param name="AExtractName">Name of the Extract to be created.</param> /// <param name="AExtractDescription">Description of the Extract to be created.</param> /// <param name="ANewExtractId">Extract Id of the created Extract, or -1 if the /// creation of the Extract was not successful.</param> /// <param name="AExtractAlreadyExists">True if there is already an extract with /// the given name, otherwise false.</param> /// <returns>True if the new Extract was created, otherwise false.</returns> public static bool CreateNewExtract(String AExtractName, String AExtractDescription, out Int32 ANewExtractId, out Boolean AExtractAlreadyExists) { TDBTransaction Transaction = null; Boolean ReturnValue = false; bool SubmissionOK = false; MExtractMasterTable NewExtractMasterDT = null; MExtractMasterRow TemplateRow = null; Boolean ExtractAlreadyExists = false; Int32 NewExtractId = -1; TLogging.LogAtLevel(9, "CreateNewExtract called!"); DBAccess.GDBAccessObj.GetNewOrExistingAutoTransaction(IsolationLevel.Serializable, ref Transaction, ref SubmissionOK, delegate { // Check if there is already an extract with the extract name if (!CheckExtractExists(AExtractName)) { // The extract name is unique. So create the new extract... NewExtractMasterDT = new MExtractMasterTable(); TemplateRow = (MExtractMasterRow)NewExtractMasterDT.NewRowTyped(true); TemplateRow.ExtractName = AExtractName; TemplateRow.ExtractDesc = AExtractDescription; TemplateRow.ExtractId = -1; // initialize id negative so sequence can be used NewExtractMasterDT.Rows.Add(TemplateRow); MExtractMasterAccess.SubmitChanges(NewExtractMasterDT, Transaction); // Get the Extract Id TemplateRow = (MExtractMasterRow)NewExtractMasterDT.Rows[0]; NewExtractId = TemplateRow.ExtractId; SubmissionOK = true; ReturnValue = true; } else { ExtractAlreadyExists = true; ReturnValue = false; } if (ReturnValue) { SubmissionOK = true; } else { SubmissionOK = false; } }); // Get the Extract Id // if (NewExtractMasterDT != null) // { // TemplateRow = (MExtractMasterRow)NewExtractMasterDT.Rows[0]; // ANewExtractId = TemplateRow.ExtractId; // } ANewExtractId = NewExtractId; AExtractAlreadyExists = ExtractAlreadyExists; return(ReturnValue); }
/// <summary> /// Creates a new extract with the given extract name and extract description in the /// m_extract_master data table. The Extract Id and the Extract Name must both be /// unique in the Petra Database. /// </summary> /// <param name="AExtractName">Name of the Extract to be created.</param> /// <param name="AExtractDescription">Description of the Extract to be created.</param> /// <param name="ANewExtractId">Extract Id of the created Extract, or -1 if the /// creation of the Extract was not successful.</param> /// <param name="AExtractAlreadyExists">True if there is already an extract with /// the given name, otherwise false.</param> /// <returns>True if the new Extract was created, otherwise false.</returns> public static bool CreateNewExtract(String AExtractName, String AExtractDescription, out Int32 ANewExtractId, out Boolean AExtractAlreadyExists) { TDBTransaction WriteTransaction; Boolean NewTransaction; Boolean ReturnValue = false; ANewExtractId = -1; AExtractAlreadyExists = false; TLogging.LogAtLevel(9, "CreateNewExtract called!"); WriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { // Check if there is already an extract with the extract name if (!CheckExtractExists(AExtractName)) { // The extract name is unique. So create the new extract... MExtractMasterTable NewExtractMasterDT = new MExtractMasterTable(); MExtractMasterRow TemplateRow = (MExtractMasterRow)NewExtractMasterDT.NewRowTyped(true); TemplateRow.ExtractName = AExtractName; TemplateRow.ExtractDesc = AExtractDescription; TemplateRow.ExtractId = -1; // initialize id negative so sequence can be used NewExtractMasterDT.Rows.Add(TemplateRow); MExtractMasterAccess.SubmitChanges(NewExtractMasterDT, WriteTransaction); // Get the Extract Id TemplateRow = (MExtractMasterRow)NewExtractMasterDT.Rows[0]; ANewExtractId = TemplateRow.ExtractId; ReturnValue = true; } else { AExtractAlreadyExists = true; ReturnValue = false; } if (ReturnValue && NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } else if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } } catch (Exception Exc) { TLogging.Log("An Exception occured during the creation of a new Extract:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } return(ReturnValue); }
public static Int32 GetExtractId(String AExtractName) { MExtractMasterTable TemplateTable; MExtractMasterRow TemplateRow; MExtractMasterTable ResultTable; MExtractMasterRow ResultRow; Int32 ReturnValue = -1; TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable); TemplateTable = new MExtractMasterTable(); TemplateRow = TemplateTable.NewRowTyped(false); TemplateRow.ExtractName = AExtractName; ResultTable = MExtractMasterAccess.LoadUsingTemplate(TemplateRow, null, Transaction); if (ResultTable.Count > 0) { ResultRow = (MExtractMasterRow)ResultTable.Rows[0]; ReturnValue = ResultRow.ExtractId; } DBAccess.GDBAccessObj.RollbackTransaction(); return ReturnValue; }
public static Boolean ExtractExists(String AExtractName) { MExtractMasterTable TemplateTable; MExtractMasterRow TemplateRow; Boolean ReturnValue = true; TDBTransaction Transaction = null; DBAccess.GDBAccessObj.BeginAutoReadTransaction(IsolationLevel.ReadCommitted, ref Transaction, delegate { TemplateTable = new MExtractMasterTable(); TemplateRow = TemplateTable.NewRowTyped(false); TemplateRow.ExtractName = AExtractName; if (MExtractMasterAccess.CountUsingTemplate(TemplateRow, null, Transaction) == 0) { ReturnValue = false; } }); return ReturnValue; }
/// <summary> /// Creates a new extract with the given extract name and extract description in the /// m_extract_master data table. The Extract Id and the Extract Name must both be /// unique in the Petra Database. /// </summary> /// <param name="AExtractName">Name of the Extract to be created.</param> /// <param name="AExtractDescription">Description of the Extract to be created.</param> /// <param name="ANewExtractId">Extract Id of the created Extract, or -1 if the /// creation of the Extract was not successful.</param> /// <param name="AExtractAlreadyExists">True if there is already an extract with /// the given name, otherwise false.</param> /// <returns>True if the new Extract was created, otherwise false.</returns> public static bool CreateNewExtract(String AExtractName, String AExtractDescription, out Int32 ANewExtractId, out Boolean AExtractAlreadyExists) { TDBTransaction WriteTransaction; Boolean NewTransaction; Boolean ReturnValue = false; ANewExtractId = -1; AExtractAlreadyExists = false; TLogging.LogAtLevel(9, "CreateNewExtract called!"); WriteTransaction = DBAccess.GDBAccessObj.GetNewOrExistingTransaction(IsolationLevel.Serializable, TEnforceIsolationLevel.eilMinimum, out NewTransaction); try { // Check if there is already an extract with the extract name if (!CheckExtractExists(AExtractName)) { // The extract name is unique. So create the new extract... MExtractMasterTable NewExtractMasterDT = new MExtractMasterTable(); MExtractMasterRow TemplateRow = (MExtractMasterRow)NewExtractMasterDT.NewRowTyped(true); TemplateRow.ExtractName = AExtractName; TemplateRow.ExtractDesc = AExtractDescription; TemplateRow.ExtractId = -1; // initialize id negative so sequence can be used NewExtractMasterDT.Rows.Add(TemplateRow); MExtractMasterAccess.SubmitChanges(NewExtractMasterDT, WriteTransaction); // Get the Extract Id TemplateRow = (MExtractMasterRow)NewExtractMasterDT.Rows[0]; ANewExtractId = TemplateRow.ExtractId; ReturnValue = true; } else { AExtractAlreadyExists = true; ReturnValue = false; } if (ReturnValue && NewTransaction) { DBAccess.GDBAccessObj.CommitTransaction(); } else if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } } catch (Exception Exc) { TLogging.Log("An Exception occured during the creation of a new Extract:" + Environment.NewLine + Exc.ToString()); if (NewTransaction) { DBAccess.GDBAccessObj.RollbackTransaction(); } throw; } return ReturnValue; }
public static Boolean ExtractExists(String AExtractName) { MExtractMasterTable TemplateTable; MExtractMasterRow TemplateRow; Boolean ReturnValue = true; TDBTransaction Transaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.Serializable); TemplateTable = new MExtractMasterTable(); TemplateRow = TemplateTable.NewRowTyped(false); TemplateRow.ExtractName = AExtractName; if (MExtractMasterAccess.CountUsingTemplate(TemplateRow, null, Transaction) == 0) { ReturnValue = false; } DBAccess.GDBAccessObj.CommitTransaction(); return ReturnValue; }
/// <summary> /// Called by the instantiator of this Dialog to retrieve the result of the dialog /// /// </summary> /// <param name="AExtractMasterTable"></param> /// <returns>true if at least one row was selected /// </returns> public bool GetResult(ref MExtractMasterTable AExtractMasterTable) { MExtractMasterRow NewRow; AExtractMasterTable.Clear(); if (FResultTable == null) { return false; } foreach (MExtractMasterRow Row in FResultTable.Rows) { NewRow = AExtractMasterTable.NewRowTyped(); NewRow.ExtractId = Row.ExtractId; NewRow.ExtractName = Row.ExtractName; NewRow.ExtractDesc = Row.ExtractDesc; NewRow.KeyCount = Row.KeyCount; NewRow.CreatedBy = Row.CreatedBy; NewRow.DateCreated = Row.DateCreated; AExtractMasterTable.Rows.Add(NewRow); } return AExtractMasterTable.Count >= 0; }