private void AddDetail(System.Object sender, EventArgs e) { String Attribute = ""; String Detail = ""; String Description = ""; for (int Counter = 0; Counter < grdDetail.SelectedDataRows.Length; ++Counter) { Attribute = (String)((DataRowView)grdDetail.SelectedDataRows[Counter]).Row[0]; Detail = (String)((DataRowView)grdDetail.SelectedDataRows[Counter]).Row[1]; Description = (String)((DataRowView)grdDetail.SelectedDataRows[Counter]).Row[2]; PContactAttributeDetailRow newRow = (PContactAttributeDetailRow)FSelectionTable.NewRow(); newRow.Active = true; newRow.ContactAttributeCode = Attribute; newRow.ContactAttrDetailCode = Detail; newRow.ContactAttrDetailDescr = Description; if (FSelectionTable.Rows.Find(new String[] { Attribute, Detail }) == null) { FSelectionTable.Rows.Add(newRow); } } }
/// <summary> /// Performs checks to determine whether a deletion of the current row is permissable /// </summary> /// <param name="ARowToDelete">the currently selected row to be deleted</param> /// <param name="ADeletionQuestion">can be changed to a context-sensitive deletion confirmation question</param> /// <returns>true if user is permitted and able to delete the current row</returns> private bool PreDeleteManual(PContactAttributeDetailRow ARowToDelete, ref string ADeletionQuestion) { // If the last Row in the Grid is to be deleted: check if there are added 'Detail' Rows in *other* 'Master' Rows, // and if any of those 'Master' Rows was added too, tell the user that data needs to be saved first before deletion // of the present 'Detail' Row can go ahead. // The reason for that is that the deletion of that last 'Detail' Row will cause the OnNoMoreDetailRecords Event to // be raised by the UserControl, which in turn will cause the Form to call the 'SaveChanges' Method of the // UserControl before the Form saves its own data. While this in itself is OK, saving in the 'SaveChanges' Method // of the UserControl would fail as a 'Master' Row itself was newly added AND it wouldn't be in the DB yet! return(TDeleteGridRows.MasterDetailFormsSpecialPreDeleteCheck(this.Count, FContactAttributeDT, FMainDS.PContactAttributeDetail, PContactAttributeTable.GetContactAttributeCodeDBName(), PContactAttributeDetailTable.GetContactAttrDetailCodeDBName())); }
/// <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(PContactAttributeDetailRow ARowToDelete, bool AAllowDeletion, bool ADeletionPerformed, string ACompletionMessage) { if (ADeletionPerformed) { // If we have no Attribute Details anymore: Inform the Form if (this.Count == 0) { OnNoMoreDetailRecords(null); } } }
private void grdSelection_SetControls(TParameterList AParameters) { FSelectionTable.Rows.Clear(); int NumAttributes = AParameters.Get("param_number_of_contact_attributes").ToInt32(); for (int Counter = 0; Counter < NumAttributes; ++Counter) { PContactAttributeDetailRow Row = FSelectionTable.NewRowTyped(true); Row.ContactAttributeCode = AParameters.Get("param_contact_attribute_attribute_" + Counter.ToString()).ToString(); Row.ContactAttrDetailCode = AParameters.Get("param_contact_attribute_detail_" + Counter.ToString()).ToString(); Row.ContactAttrDetailDescr = AParameters.Get("param_contact_attribute_description_" + Counter.ToString()).ToString(); FSelectionTable.Rows.Add(Row); } }
private void NewRowManual(ref PContactAttributeDetailRow ARow) { string NewName = Catalog.GetString("NEWDETAIL"); Int32 CountNewDetail = 0; if (FMainDS.PContactAttributeDetail.Rows.Find(new object[] { FContactAttribute, NewName }) != null) { while (FMainDS.PContactAttributeDetail.Rows.Find(new object[] { FContactAttribute, NewName + CountNewDetail.ToString() }) != null) { CountNewDetail++; } NewName += CountNewDetail.ToString(); } ARow.ContactAttrDetailCode = NewName; ARow.ContactAttributeCode = FContactAttribute; }
private void RemoveDetail(System.Object sender, EventArgs e) { for (int Counter = grdSelection.SelectedDataRows.Length - 1; Counter >= 0; --Counter) { String Attribute = (String)((DataRowView)grdSelection.SelectedDataRows[Counter]).Row[0]; String Detail = (String)((DataRowView)grdSelection.SelectedDataRows[Counter]).Row[1]; for (int Counter2 = FSelectionTable.Rows.Count - 1; Counter2 >= 0; --Counter2) { PContactAttributeDetailRow currentRow = (PContactAttributeDetailRow)FSelectionTable.Rows[Counter2]; if ((currentRow.ContactAttributeCode == Attribute) && (currentRow.ContactAttrDetailCode == Detail)) { FSelectionTable.Rows.RemoveAt(Counter); break; } } } grdSelection.Selection.ResetSelection(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(PContactAttributeDetailRow ARowToDelete, bool AAllowDeletion, bool ADeletionPerformed, string ACompletionMessage) { if (ADeletionPerformed) { // If we have no Attribute Details anymore: Inform the Form if (this.Count == 0) { OnNoMoreDetailRecords(null); } } }
/// <summary> /// Performs checks to determine whether a deletion of the current row is permissable /// </summary> /// <param name="ARowToDelete">the currently selected row to be deleted</param> /// <param name="ADeletionQuestion">can be changed to a context-sensitive deletion confirmation question</param> /// <returns>true if user is permitted and able to delete the current row</returns> private bool PreDeleteManual(PContactAttributeDetailRow ARowToDelete, ref string ADeletionQuestion) { // If the last Row in the Grid is to be deleted: check if there are added 'Detail' Rows in *other* 'Master' Rows, // and if any of those 'Master' Rows was added too, tell the user that data needs to be saved first before deletion // of the present 'Detail' Row can go ahead. // The reason for that is that the deletion of that last 'Detail' Row will cause the OnNoMoreDetailRecords Event to // be raised by the UserControl, which in turn will cause the Form to call the 'SaveChanges' Method of the // UserControl before the Form saves its own data. While this in itself is OK, saving in the 'SaveChanges' Method // of the UserControl would fail as a 'Master' Row itself was newly added AND it wouldn't be in the DB yet! return TDeleteGridRows.MasterDetailFormsSpecialPreDeleteCheck(this.Count, FContactAttributeDT, FMainDS.PContactAttributeDetail, PContactAttributeTable.GetContactAttributeCodeDBName(), PContactAttributeDetailTable.GetContactAttrDetailCodeDBName()); }
private void NewRowManual(ref PContactAttributeDetailRow ARow) { string NewName = Catalog.GetString("NEWDETAIL"); Int32 CountNewDetail = 0; if (FMainDS.PContactAttributeDetail.Rows.Find(new object[] { FContactAttribute, NewName }) != null) { while (FMainDS.PContactAttributeDetail.Rows.Find(new object[] { FContactAttribute, NewName + CountNewDetail.ToString() }) != null) { CountNewDetail++; } NewName += CountNewDetail.ToString(); } ARow.ContactAttrDetailCode = NewName; ARow.ContactAttributeCode = FContactAttribute; }
private Boolean PerformContactAttributeAddOrRemoval(DataRow AChangingRow, out Boolean AIsRemoval) { Boolean ReturnValue = false; AIsRemoval = false; try { String AttributeCode = AChangingRow["AttributeCode"].ToString(); String AttributeDetailCode = AChangingRow["AttributeDetailCode"].ToString(); DataRow ExistingDataRow = FSelectedContactAttributeTable.Rows.Find(new object[] { FContactID, AttributeCode, AttributeDetailCode }); if (ExistingDataRow == null) { /* * Add Contact Attribute */ DataRow DeletedRow = null; // check that this contact attribute hasn't previously been deleted foreach (DataRow Row in FSelectedContactAttributeTable.Rows) { if ((Row.RowState == DataRowState.Deleted) && (Convert.ToInt64(Row[PPartnerContactAttributeTable.GetContactIdDBName(), DataRowVersion.Original]) == FContactID) && (Row[PPartnerContactAttributeTable.GetContactAttributeCodeDBName(), DataRowVersion.Original].ToString() == AttributeCode) && (Row[PPartnerContactAttributeTable.GetContactAttrDetailCodeDBName(), DataRowVersion.Original].ToString() == AttributeDetailCode)) { DeletedRow = Row; } } if (DeletedRow != null) { // undelete the previously deleted row DeletedRow.RejectChanges(); } else { // Check: is this Contact Attribute assignable PContactAttributeRow ContactAttribute = (PContactAttributeRow)FContactAttributeTableDV.Table.Rows.Find(new Object[] { AttributeCode }); PContactAttributeDetailRow ContactAttributeDetail = (PContactAttributeDetailRow)FContactAttributeDetailTableDV.Table.Rows.Find(new Object[] { AttributeCode, AttributeDetailCode }); // -1 means this is being used in a find screen and we can select inactive attributes if ((FContactID != -1) && (!ContactAttribute.Active || !ContactAttributeDetail.Active)) { MessageBox.Show( string.Format(Catalog.GetString("This Contact Attribute is inactive and cannot be added to this Contact Log."), AttributeCode), Catalog.GetString("Inactive Contact Attribute"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return(false); } // add new row to PartnerType table PPartnerContactAttributeRow TheNewRow = FSelectedContactAttributeTable.NewRowTyped(); TheNewRow.ContactId = FContactID; TheNewRow.ContactAttributeCode = AttributeCode; TheNewRow.ContactAttrDetailCode = AttributeDetailCode; FSelectedContactAttributeTable.Rows.Add(TheNewRow); } ReturnValue = true; AIsRemoval = false; } else { /* * Remove Special Type */ // Delete row if (ExistingDataRow.RowState == DataRowState.Added) { FAddedAttributeDeleted = true; } ExistingDataRow.Delete(); ReturnValue = true; AIsRemoval = true; } } catch (Exception E) { MessageBox.Show(E.ToString()); ReturnValue = false; } return(ReturnValue); }