/// <summary> /// Called by the instantiator of this Dialog to retrieve the result of the dialog /// /// </summary> /// <param name="AExtractId"></param> /// <param name="AExtractName"></param> /// <param name="AExtractDescription"></param> /// <param name="AKeyCount"></param> /// <param name="AExtractCreatedBy"></param> /// <param name="AExtractDateCreated"></param> /// <returns>true if a row was selected /// </returns> public bool GetResult(out int AExtractId, out String AExtractName, out String AExtractDescription, out int AKeyCount, out String AExtractCreatedBy, out DateTime AExtractDateCreated) { if ((FResultTable != null) && (FResultTable.Count > 0)) { // use first row (this method should normally only be called for single select dialog) MExtractMasterRow Row = (MExtractMasterRow)FResultTable.Rows[0]; AExtractId = Row.ExtractId; AExtractName = Row.ExtractName; AExtractDescription = Row.ExtractDesc; AKeyCount = Row.KeyCount; AExtractCreatedBy = Row.CreatedBy; AExtractDateCreated = (DateTime)Row.DateCreated; } else { // no selected rows -> initialize values AExtractId = -1; AExtractName = ""; AExtractDescription = ""; AKeyCount = 0; AExtractCreatedBy = ""; AExtractDateCreated = DateTime.Today; } return(AExtractId >= 0); }
/// <summary> /// Code to be run after the deletion process /// </summary> /// <param name="ARowToDelete">the row that was/was to be deleted</param> /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param> /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param> /// <param name="ACompletionMessage">if specified, is the deletion completion message</param> private void PostDeleteManual(MExtractMasterRow ARowToDelete, bool AAllowDeletion, bool ADeletionPerformed, string ACompletionMessage) { UpdateButtonStatus(); }
private bool PreDeleteManual(MExtractMasterRow ARowToDelete, ref string ADeletionQuestion) { ADeletionQuestion = Catalog.GetString("Are you sure you want to delete the current row?"); ADeletionQuestion += String.Format("{0}{0}({1} {2})", Environment.NewLine, lblExtractName.Text, txtExtractName.Text); return(true); }
/// <summary> /// Code to be run after the deletion process /// </summary> /// <param name="ARowToDelete">the row that was/was to be deleted</param> /// <param name="AAllowDeletion">whether or not the user was permitted to delete</param> /// <param name="ADeletionPerformed">whether or not the deletion was performed successfully</param> /// <param name="ACompletionMessage">if specified, is the deletion completion message</param> private void PostDeleteManual(MExtractMasterRow ARowToDelete, bool AAllowDeletion, bool ADeletionPerformed, string ACompletionMessage) { UpdateButtonStatus(); // automatically save changes after a delete SaveChanges(); }
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> /// Called by the instantiator of this Dialog to retrieve the result of the dialog /// /// </summary> /// <param name="AExtractId"></param> /// <param name="AExtractName"></param> /// <param name="AExtractDescription"></param> /// <returns>true if a row was selected /// </returns> public bool GetResult(out int AExtractId, out String AExtractName, out String AExtractDescription) { if ((FResultTable != null) && (FResultTable.Count > 0)) { // use first row (this method should normally only be called for single select dialog) MExtractMasterRow Row = (MExtractMasterRow)FResultTable.Rows[0]; AExtractId = Row.ExtractId; AExtractName = Row.ExtractName; AExtractDescription = Row.ExtractDesc; } else { // no selected rows -> initialize values AExtractId = -1; AExtractName = ""; AExtractDescription = ""; } return(AExtractId >= 0); }
/// <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> /// Guide user through process to create extract which contains all family records of /// Persons in a base extract. /// </summary> /// <param name="AParentForm"></param> /// <param name="AExtractMasterRow"></param> public static void CreateFamilyExtractForPersons(Form AParentForm, MExtractMasterRow AExtractMasterRow) { TFrmExtractFindDialog ExtractFindDialog = new TFrmExtractFindDialog(AParentForm); TFrmExtractNamingDialog ExtractNameDialog = new TFrmExtractNamingDialog(AParentForm); int BaseExtractId = 0; string BaseExtractName; string BaseExtractDescription; int ExtractId = 0; string ExtractName; string ExtractDescription; if (AExtractMasterRow != null) { BaseExtractId = AExtractMasterRow.ExtractId; // inform user what this extract is about and what will happen if (MessageBox.Show(Catalog.GetString("A new Extract will be created that will contain all Families of the Persons" + " that exist in the Extract '" + AExtractMasterRow.ExtractName + "'."), Catalog.GetString("Generate Family Extract for Persons"), MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel) { return; } } else { // inform user what this extract is about and what will happen MessageBox.Show(Catalog.GetString("Please select an existing Extract with the Find Screen that follows.\r\n\r\n" + "A new Extract will be created that will contain all Families of the Persons" + " that exist in the selected Extract."), Catalog.GetString("Generate Family Extract for Persons"), MessageBoxButtons.OK, MessageBoxIcon.Information); // let the user select base extract ExtractFindDialog.ShowDialog(true); // get data for selected base extract ExtractFindDialog.GetResult(out BaseExtractId, out BaseExtractName, out BaseExtractDescription); ExtractFindDialog.Dispose(); } // only continue if a base extract was selected if (BaseExtractId >= 0) { ExtractNameDialog.ShowDialog(); if (ExtractNameDialog.DialogResult != System.Windows.Forms.DialogResult.Cancel) { /* Get values from the Dialog */ ExtractNameDialog.GetReturnedParameters(out ExtractName, out ExtractDescription); ExtractNameDialog.Dispose(); } else { // dialog was cancelled, do not continue with extract generation ExtractNameDialog.Dispose(); return; } // create extract with given name and description and store it in db if (TRemote.MPartner.Partner.WebConnectors.CreateFamilyExtractForPersons(BaseExtractId, ref ExtractId, ExtractName, ExtractDescription)) { NewExtractCreated(ExtractName, ExtractId, AParentForm); } else { MessageBox.Show(Catalog.GetString("Creation of extract failed"), Catalog.GetString("Generate Family Extract for Persons"), MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } }
private bool PreDeleteManual(MExtractMasterRow ARowToDelete, ref string ADeletionQuestion) { ADeletionQuestion = Catalog.GetString("Are you sure you want to delete the current row?"); ADeletionQuestion += String.Format("{0}{0}({1} {2})", Environment.NewLine, lblExtractName.Text, txtExtractName.Text); return 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); }
/// <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); }