private void AttributeFocusedRowChanged(System.Object sender, SourceGrid.RowEventArgs e) { String AttributeCode = ""; if (grdAttribute.SelectedDataRows.Length > 0) { AttributeCode = (String)((DataRowView)grdAttribute.SelectedDataRows[0]).Row[0]; } PContactAttributeDetailTable tmpTable = (PContactAttributeDetailTable)FContactAttributesTable.Copy(); for (int Counter = tmpTable.Rows.Count - 1; Counter >= 0; --Counter) { if ((String)tmpTable.Rows[Counter][PContactAttributeDetailTable.ColumnContactAttributeCodeId] != AttributeCode) { tmpTable.Rows.RemoveAt(Counter); } } TDataCache.TMPartner.GetCacheableMailingTable(TCacheableMailingTablesEnum.ContactAttributeDetailList); tmpTable.DefaultView.AllowNew = false; grdDetail.DataSource = new DevAge.ComponentModel.BoundDataView(tmpTable.DefaultView); grdDetail.AutoSizeCells(); grdDetail.Selection.ResetSelection(true); }
/// <summary> /// Specifies a new Filter and applies it, then selects the Row passed in with <paramref name="ACurrentRowIndex"/>. /// </summary> /// <param name="ANewCode">New Code to filter on.</param> /// <param name="ACurrentRowIndex">The index of the Row that should get displayed (the 'current' Row).</param> private void FilterOnCode(string ANewCode, int ACurrentRowIndex) { string FilterStr = String.Format("{0}='{1}'", PContactAttributeDetailTable.GetContactAttributeCodeDBName(), ANewCode); FFilterAndFindObject.FilterPanelControls.SetBaseFilter(FilterStr, true); FFilterAndFindObject.ApplyFilter(); grdDetails.SelectRowWithoutFocus(ACurrentRowIndex); }
private void FillTempTable() { DataView UnselectedContactAttributeTableDV; DataRow TheNewRow; Int16 RowCounter; FGridTable.Rows.Clear(); FGridTable.AcceptChanges(); UnselectedContactAttributeTableDV = FContactAttributeDetailTableDV; // first add Contact Attributes which are already selected for partner for (RowCounter = 0; RowCounter < FSelectedContactAttributeTableDV.Count; RowCounter++) { TheNewRow = FGridTable.NewRow(); TheNewRow["Checked"] = (System.Object)true; TheNewRow["AttributeCode"] = FSelectedContactAttributeTableDV[RowCounter][PPartnerContactAttributeTable.GetContactAttributeCodeDBName()]; TheNewRow["AttributeDescription"] = ContactAttributesLogic.GetContactAttributeDesciption( FSelectedContactAttributeTableDV[RowCounter][PPartnerContactAttributeTable.GetContactAttributeCodeDBName()].ToString(), FContactAttributeTableDV); TheNewRow["AttributeDetailCode"] = FSelectedContactAttributeTableDV[RowCounter][PPartnerContactAttributeTable.GetContactAttrDetailCodeDBName()]; TheNewRow["AttributeDetailDescription"] = ContactAttributesLogic.GetContactAttributeDetailDesciption( FSelectedContactAttributeTableDV[RowCounter][PPartnerContactAttributeTable.GetContactAttributeCodeDBName()].ToString(), FSelectedContactAttributeTableDV[RowCounter][PPartnerContactAttributeTable.GetContactAttrDetailCodeDBName()].ToString(), FContactAttributeDetailTableDV); FGridTable.Rows.Add(TheNewRow); } // second add the rest of the Special Types in db for (RowCounter = 0; RowCounter < UnselectedContactAttributeTableDV.Count; RowCounter++) { // only add row if it has not already been added as a checked row if (FSelectedContactAttributeTableDV.Find(new object[] { UnselectedContactAttributeTableDV[RowCounter][PContactAttributeDetailTable.GetContactAttributeCodeDBName()], UnselectedContactAttributeTableDV[RowCounter][PContactAttributeDetailTable.GetContactAttrDetailCodeDBName()] }) == -1) { TheNewRow = FGridTable.NewRow(); TheNewRow["Checked"] = (System.Object)false; TheNewRow["AttributeCode"] = UnselectedContactAttributeTableDV[RowCounter][PContactAttributeDetailTable.GetContactAttributeCodeDBName()]; TheNewRow["AttributeDescription"] = ContactAttributesLogic.GetContactAttributeDesciption( UnselectedContactAttributeTableDV[RowCounter][PContactAttributeDetailTable.GetContactAttributeCodeDBName()].ToString(), FContactAttributeTableDV); TheNewRow["AttributeDetailCode"] = UnselectedContactAttributeTableDV[RowCounter][PContactAttributeDetailTable.GetContactAttrDetailCodeDBName()]; TheNewRow["AttributeDetailDescription"] = ContactAttributesLogic.GetContactAttributeDetailDesciption( UnselectedContactAttributeTableDV[RowCounter][PContactAttributeDetailTable.GetContactAttributeCodeDBName()].ToString(), UnselectedContactAttributeTableDV[RowCounter][PContactAttributeDetailTable.GetContactAttrDetailCodeDBName()].ToString(), FContactAttributeDetailTableDV); FGridTable.Rows.Add(TheNewRow); } } }
private void grdDetail_InitialiseData(TFrmPetraReportingUtils APetraUtilsObject) { FContactAttributesTable = (PContactAttributeDetailTable) TDataCache.TMPartner.GetCacheableMailingTable(TCacheableMailingTablesEnum.ContactAttributeDetailList); grdDetail.Columns.Clear(); grdDetail.AddTextColumn("Attribute", FContactAttributesTable.ColumnContactAttributeCode); grdDetail.AddTextColumn("Detail", FContactAttributesTable.ColumnContactAttrDetailCode); grdDetail.AddTextColumn("Description", FContactAttributesTable.ColumnContactAttrDetailDescr); grdDetail.Columns[0].Visible = false; grdDetail.AutoSizeCells(); grdDetail.Selection.EnableMultiSelection = true; }
private void grdSelection_InitialiseData(TFrmPetraReportingUtils APetraUtilsObject) { FSelectionTable = new PContactAttributeDetailTable(); FSelectionTable.DefaultView.AllowNew = false; FSelectionTable.DefaultView.AllowDelete = true; FSelectionTable.DefaultView.AllowEdit = false; grdSelection.Columns.Clear(); grdSelection.AddTextColumn("Attribute", FSelectionTable.ColumnContactAttributeCode); grdSelection.AddTextColumn("Detail", FSelectionTable.ColumnContactAttrDetailCode); grdSelection.AddTextColumn("Description", FSelectionTable.ColumnContactAttrDetailDescr); grdSelection.DataSource = new DevAge.ComponentModel.BoundDataView(FSelectionTable.DefaultView); grdSelection.AutoSizeCells(); grdSelection.Selection.EnableMultiSelection = true; }
private void InitializeManualCode() { this.AcceptButton = btnOK; FContactAttributeTableDV = TDataCache.TMPartner.GetCacheableMailingTable(TCacheableMailingTablesEnum.ContactAttributeList).DefaultView; FContactAttributeTableDV.Sort = PContactAttributeTable.GetContactAttributeCodeDBName() + " ASC"; FContactAttributeDetailTableDV = TDataCache.TMPartner.GetCacheableMailingTable(TCacheableMailingTablesEnum.ContactAttributeDetailList).DefaultView; FContactAttributeDetailTableDV.Sort = PContactAttributeDetailTable.GetContactAttributeCodeDBName() + " ASC, " + PContactAttributeDetailTable.GetContactAttrDetailCodeDBName() + " ASC"; CreateTempTable(); grdContactAttributes.MouseClick += new MouseEventHandler(this.GrdContactAttributes_Click); grdContactAttributes.SpaceKeyPressed += new TKeyPressedEventHandler(this.GrdContactAttributes_SpaceKeyPressed); grdContactAttributes.EnterKeyPressed += new TKeyPressedEventHandler(this.GrdContactAttributes_EnterKeyPressed); }
/// <summary> /// Gets a contact attribute detail's desciption. /// </summary> /// <param name="AContactAttributeCode">The contact attribute's Code</param> /// <param name="AContactAttributeDetailCode">The contact attribute detail's Code</param> /// <param name="AContactAttributeDetailTableDV">Table containing all ContactAttributeDetails</param> /// <returns></returns> public static string GetContactAttributeDetailDesciption(string AContactAttributeCode, string AContactAttributeDetailCode, DataView AContactAttributeDetailTableDV) { string ReturnValue = ""; int TypeDescriptionInCachePosition = AContactAttributeDetailTableDV.Find(new object[] { AContactAttributeCode, AContactAttributeDetailCode }); if (TypeDescriptionInCachePosition != -1) { ReturnValue = AContactAttributeDetailTableDV [TypeDescriptionInCachePosition][PContactAttributeDetailTable.GetContactAttrDetailDescrDBName()].ToString(); // If this Type is inactive, show it. if (!Convert.ToBoolean(AContactAttributeDetailTableDV[TypeDescriptionInCachePosition][PContactAttributeDetailTable.GetActiveDBName()])) { ReturnValue = ReturnValue + MCommonResourcestrings.StrGenericInactiveCode; } } return(ReturnValue); }
/// <summary> /// Setups the contact attributes grid (used on the following screens: Contact Log tab, Contacts with Partners and Extract by Contact Log. /// </summary> /// <param name="AGrid">Grid to be set up</param> /// <param name="AAttributes">Attributes to be included in the grid</param> /// <param name="AIncludeDescription">Include columns that display the attribute descriptions</param> /// <param name="AContactLogIDFilter">Filter grid to only show rows for given contact log if</param> public static DataView SetupContactAttributesGrid(ref TSgrdDataGridPaged AGrid, DataTable AAttributes, bool AIncludeDescription, Int64 AContactLogIDFilter = -1) { DataView ContactAttributeTableDV = TDataCache.TMPartner.GetCacheableMailingTable(TCacheableMailingTablesEnum.ContactAttributeList).DefaultView; ContactAttributeTableDV.Sort = PContactAttributeTable.GetContactAttributeCodeDBName() + " ASC"; DataView ContactAttributeDetailTableDV = TDataCache.TMPartner.GetCacheableMailingTable(TCacheableMailingTablesEnum.ContactAttributeDetailList).DefaultView; ContactAttributeDetailTableDV.Sort = PContactAttributeDetailTable.GetContactAttributeCodeDBName() + " ASC, " + PContactAttributeDetailTable.GetContactAttrDetailCodeDBName() + " ASC"; DataTable DT = new PPartnerContactAttributeTable(); if ((AAttributes != null) && (AAttributes.Rows.Count > 0)) { DT = AAttributes.Copy(); } if (AIncludeDescription) { DT.Columns.Add("AttributeDescription", System.Type.GetType("System.String")); DT.Columns.Add("AttributeDetailDescription", System.Type.GetType("System.String")); // add descriptions to new table foreach (DataRow Row in DT.Rows) { if (Row.RowState != DataRowState.Deleted) { Row["AttributeDescription"] = GetContactAttributeDesciption( Row[PPartnerContactAttributeTable.GetContactAttributeCodeDBName()].ToString(), ContactAttributeTableDV); Row["AttributeDetailDescription"] = GetContactAttributeDetailDesciption( Row[PPartnerContactAttributeTable.GetContactAttributeCodeDBName()].ToString(), Row[PPartnerContactAttributeTable.GetContactAttrDetailCodeDBName()].ToString(), ContactAttributeDetailTableDV); } } } AGrid.Columns.Clear(); AGrid.AddTextColumn("Attribute Code", DT.Columns[PPartnerContactAttributeTable.GetContactAttributeCodeDBName()]); if (AIncludeDescription) { AGrid.AddTextColumn("Description", DT.Columns["AttributeDescription"]); } AGrid.AddTextColumn("Detail Code", DT.Columns[PPartnerContactAttributeTable.GetContactAttrDetailCodeDBName()]); if (AIncludeDescription) { AGrid.AddTextColumn("Description", DT.Columns["AttributeDetailDescription"]); } DataView GridTableDV = DT.DefaultView; GridTableDV.AllowNew = false; GridTableDV.AllowEdit = false; GridTableDV.AllowDelete = false; if (AContactLogIDFilter != -1) { GridTableDV.RowFilter = PPartnerContactAttributeTable.GetContactIdDBName() + " = " + AContactLogIDFilter; } // DataBind the DataGrid AGrid.DataSource = new DevAge.ComponentModel.BoundDataView(GridTableDV); AGrid.AutoResizeGrid(); return(GridTableDV); }
/// <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())); }