/// <summary> /// Create grid and populate /// </summary> private void CreateGrid() { string CheckedMember = FCheckedColumnName; string IdMember = MExtractMasterTable.GetExtractIdDBName(); string NameMember = MExtractMasterTable.GetExtractNameDBName(); string DescriptionMember = MExtractMasterTable.GetExtractDescDBName(); string DeletableMember = MExtractMasterTable.GetDeletableDBName(); string KeyCountMember = MExtractMasterTable.GetKeyCountDBName(); string CreatedByMember = MExtractMasterTable.GetCreatedByDBName(); string DateCreatedMember = MExtractMasterTable.GetDateCreatedDBName(); string ModifiedByMember = MExtractMasterTable.GetModifiedByDBName(); string DateModifiedMember = MExtractMasterTable.GetDateModifiedDBName(); FExtractMasterTable = TRemote.MPartner.Partner.WebConnectors.GetAllExtractHeaders(); if (FExtractMasterTable != null) { DataView view = new DataView(FExtractMasterTable); FDataTable = view.ToTable(true, new string[] { IdMember, NameMember, DescriptionMember, DeletableMember, KeyCountMember, CreatedByMember, DateCreatedMember, ModifiedByMember, DateModifiedMember }); FDataTable.Columns.Add(new DataColumn(CheckedMember, typeof(bool))); clbDetails.Columns.Clear(); if (FAllowMultipleSelect) { clbDetails.AddCheckBoxColumn("Select", FDataTable.Columns[FCheckedColumnName], 17, false); } else { clbDetails.AutoFindColumn = 0; } clbDetails.AddTextColumn("Extract Name", FDataTable.Columns[NameMember] /*, 200*/); clbDetails.AddCheckBoxColumn("Deletable", FDataTable.Columns[DeletableMember] /*, 120*/); clbDetails.AddTextColumn("Key Count", FDataTable.Columns[KeyCountMember] /*, 80*/); clbDetails.AddTextColumn("Description", FDataTable.Columns[DescriptionMember] /*, 300*/); clbDetails.DataBindGrid(FDataTable, NameMember, CheckedMember, NameMember, false, true, false); clbDetails.SetCheckedStringList(""); } this.clbDetails.ValueChanged += new System.EventHandler(this.UpdateRecordCount); PrepareButtons(); UpdateRecordCount(); }
private void RefreshFilter(System.Object sender, EventArgs e) { if (FDataTable == null) { return; } DataView dv = FDataTable.DefaultView; string FilterString = string.Empty; if (!string.IsNullOrEmpty(txtExtractName.Text)) { FilterString = MExtractMasterTable.GetExtractNameDBName() + " LIKE '%" + txtExtractName.Text + "%' AND "; } if (!string.IsNullOrEmpty(txtExtractDesc.Text)) { FilterString += MExtractMasterTable.GetExtractDescDBName() + " LIKE '%" + txtExtractDesc.Text + "%' AND "; } if (!string.IsNullOrEmpty(cmbUserCreated.GetSelectedString())) { FilterString += MExtractMasterTable.GetCreatedByDBName() + " = '" + cmbUserCreated.GetSelectedString() + "' AND "; } if ((dtpCreatedFrom.Date != null) && dtpCreatedFrom.ValidDate()) { FilterString += MExtractMasterTable.GetDateCreatedDBName() + " >= '" + ((DateTime)dtpCreatedFrom.Date).ToShortDateString() + "' AND "; } if ((dtpCreatedTo.Date != null) && dtpCreatedTo.ValidDate()) { FilterString += MExtractMasterTable.GetDateCreatedDBName() + " <= '" + ((DateTime)dtpCreatedTo.Date).ToShortDateString() + "' AND "; } if (!string.IsNullOrEmpty(cmbUserModified.GetSelectedString())) { FilterString += MExtractMasterTable.GetModifiedByDBName() + " = '" + cmbUserModified.GetSelectedString() + "' AND "; } if ((dtpModifiedFrom.Date != null) && dtpModifiedFrom.ValidDate()) { FilterString += MExtractMasterTable.GetDateModifiedDBName() + " >= '" + ((DateTime)dtpModifiedFrom.Date).ToShortDateString() + "' AND "; } if ((dtpModifiedTo.Date != null) && dtpModifiedTo.ValidDate()) { FilterString += MExtractMasterTable.GetDateModifiedDBName() + " <= '" + ((DateTime)dtpModifiedTo.Date).ToShortDateString() + "'"; } if (FilterString.EndsWith(" AND ")) { FilterString = FilterString.Remove(FilterString.Length - 5); } dv.RowFilter = FilterString; // temp remove event so UpdateRecordCount doesn't get called for every row this.clbDetails.ValueChanged -= new System.EventHandler(this.UpdateRecordCount); clbDetails.SetCheckedStringList(""); clbDetails.DataSource = new DevAge.ComponentModel.BoundDataView(dv); clbDetails.AutoResizeGrid(); this.clbDetails.ValueChanged += new System.EventHandler(this.UpdateRecordCount); UpdateRecordCount(); }