int getNextRow() { int i = 0; DataTable Dt = null; SearchCriteria objSearch = new SearchCriteria(); objSearch.Query = _Query; objSearch.WhereString = _Where; objSearch.SearchOn = _FilterCol; objSearch.SearchValue = this.Text; objSearch.MaximumRows = 2; objSearch.IsMoveUp = false; CommonClient oDMCommon = new CommonClient(); Dt = oDMCommon.GetDataSet_Search(objSearch, CompanyDBIndex.ToString()).Tables[0]; oDMCommon.Close(); if (Dt.Rows.Count > 1) { if (!((DataView)this.ItemsSource).Table.Rows.Contains(Dt.Rows[1][0])) { ((DataView)this.ItemsSource).Table.Rows.RemoveAt(0); DataRow dr = ((DataView)this.ItemsSource).Table.NewRow(); for (int j = 0; j < ((DataView)this.ItemsSource).Table.Columns.Count; j++) { dr[j] = Dt.Rows[1][j]; } ((DataView)this.ItemsSource).Table.Rows.Add(dr); } } return(i); }
protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); CommonClient oDMCommon = new CommonClient(); DataTable dt = oDMCommon.GetDataTable("SELECT * FROM AdmnLayoutLists WHERE ID=" + FeatureID, CompanyDBIndex.ToString()); oDMCommon.Close(); strTable = dt.Rows[0]["TableName"].ToString(); strPrimaryKey = dt.Rows[0]["PrimaryKey"].ToString(); _Where = dt.Rows[0]["WhereClause"].ToString(); XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(dt.Rows[0]["LayoutXML"].ToString()); XmlNodeList xList = xDoc.SelectNodes("XML/Columns/TreeColumn"); TreeColumn oCol; oColumns = new List <TreeColumn>(); _Query = "SELECT " + strPrimaryKey; this.IsEditable = true; DataGridTextColumn dgCol; dgCol = new DataGridTextColumn(); dgCol.Header = strPrimaryKey; dgCol.Binding = new Binding(strPrimaryKey); dgCol.Visibility = System.Windows.Visibility.Hidden; this.Columns.Add(dgCol); for (int i = 0; i < xList.Count; i++) { oCol = (TreeColumn)PACTSerializer.FromXml(xList[i].OuterXml, typeof(TreeColumn)); _Query += "," + oCol.Name; dgCol = new DataGridTextColumn(); dgCol.Header = oCol.Label; dgCol.Width = oCol.Width; dgCol.Binding = new Binding(oCol.Name); iWidth += oCol.Width; this.Columns.Add(dgCol); oColumns.Add(oCol); } _Query += " FROM " + strTable; if (this.SelectedValue != null) { valueSelected = true; } //this.SelectedValue = new Binding(strPrimaryKey); this.SelectedValuePath = strPrimaryKey; }
void FillListBox() { IstextChanged = true; DataTable Dt = null; SearchCriteria objSearch = new SearchCriteria(); objSearch.Query = _Query; objSearch.WhereString = _Where; objSearch.SearchOn = _FilterCol; objSearch.SearchValue = this.Text; objSearch.MaximumRows = PageSize; objSearch.IsMoveUp = false; if (valueSelected) { objSearch.SelectedValueQuery = "select @SearchValue=" + _FilterCol + " from " + strTable + " where " + strPrimaryKey + " = " + this.SelectedValue.ToString(); valueSelected = false; } CommonClient oDMCommon = new CommonClient(); Dt = oDMCommon.GetDataTable_Search(objSearch, CompanyDBIndex.ToString()); oDMCommon.Close(); if (Dt != null && Dt.Rows.Count > 0) { if (this.ItemsSource == null) { this.ItemsSource = Dt.AsDataView(); ((DataView)this.ItemsSource).Table.PrimaryKey = new DataColumn[] { ((DataView)this.ItemsSource).Table.Columns[0] }; } else { Dt.PrimaryKey = new DataColumn[] { Dt.Columns[0] }; for (int i = 0; i < ((DataView)this.ItemsSource).Table.Rows.Count; i++) { if (!Dt.Rows.Contains(((DataView)this.ItemsSource).Table.Rows[i][0])) { ((DataView)this.ItemsSource).Table.Rows.RemoveAt(i); i--; } } for (int i = 0; i < Dt.Rows.Count; i++) { if (((DataView)this.ItemsSource).Table.Rows.Contains(Dt.Rows[i][0])) { continue; } DataRow dr = ((DataView)this.ItemsSource).Table.NewRow(); for (int j = 0; j < ((DataView)this.ItemsSource).Table.Columns.Count; j++) { dr[j] = Dt.Rows[i][j]; } if (((DataView)this.ItemsSource).Table.Rows.Count == i) { ((DataView)this.ItemsSource).Table.Rows.Add(dr); } else { ((DataView)this.ItemsSource).Table.Rows.InsertAt(dr, i); } } //if (popupDataGrid.Items.Count > 0) // popupDataGrid.SelectedItem = popupDataGrid.Items[0]; } } IstextChanged = false; }