or
| private void BindDataMainGrid() |
| { |
| try |
| { |
| thisthis.gvAccount.ItemsSource = this.GetData(); |
| } |
| catch{} |
| } |
| private DataSet GetData() |
| { |
| try |
| { |
| dsb = ServiceData.GetBudgetsByOBS(iOBSID); |
| if (dsb != null) |
| { |
| dsb.Tables["Budget"].Columns.Add("SumBudgetAllocation", typeof(float)); |
| dsb.Tables["Budget"].Columns.Add("SumBudgetRequest", typeof(float)); |
| dsb.Tables["Budget"].Columns.Add("SumOrderAllocation", typeof(float)); |
| dsb.Tables["Budget"].Columns.Add("SumOrderPaid", typeof(float)); |
| foreach (DataRow dr in dsb.Tables["Budget"].Rows) |
| { |
| dr["RowStatus"] = 0; |
| if (dsb.Tables["BudgetAllocation"].Select("id=" + Convert.ToInt32(dr["ID"])).GetLength(0) > 0) |
| { |
| dr["SumBudgetAllocation"] = Convert.ToDecimal(((LM_Model.dsBudget.BudgetAllocationRow)dsb.Tables["BudgetAllocation"].Select("id=" + Convert.ToInt32(dr["ID"]))[0]).ItemArray[1]); |
| } |
| if (dsb.Tables["BudgetRequest"].Select("BudgetId=" + Convert.ToInt32(dr["ID"])).GetLength(0) > 0) |
| { |
| dr["SumBudgetRequest"] = Convert.ToDecimal(((LM_Model.dsBudget.BudgetRequestRow)dsb.Tables["BudgetRequest"].Select("BudgetId=" + Convert.ToInt32(dr["ID"]))[0]).ItemArray[1]); |
| } |
| if (dsb.Tables["BudgetOrder"].Select("BudgetId=" + Convert.ToInt32(dr["ID"])).GetLength(0) > 0) |
| { |
| dr["SumOrderAllocation"] = Convert.ToDecimal(((LM_Model.dsBudget.BudgetOrderRow)dsb.Tables["BudgetOrder"].Select("BudgetId=" + Convert.ToInt32(dr["ID"]))[0]).ItemArray[1]); |
| } |
| if (dsb.Tables["BudgetOrderPaid"].Select("Id=" + Convert.ToInt32(dr["ID"])).GetLength(0) > 0) |
| { |
| dr["SumOrderPaid"] = Convert.ToDecimal(((LM_Model.dsBudget.BudgetOrderPaidRow)dsb.Tables["BudgetOrderPaid"].Select("Id=" + Convert.ToInt32(dr["ID"]))[0]).ItemArray[1]); |
| } |
| } |
| dsb.Tables["Budget"].Columns.Add("BalanceBudgetAllocation", typeof(float), "TotalBudget-SumBudgetAllocation"); |
| dsb.Tables["Budget"].Columns.Add("BalanceToPay", typeof(float), "SumBudgetRequest-SumOrderPaid"); |
| //Build dsAcoount |
| dsAcoount = new DataSet(); |
| DataView dv = new DataView(dsb.Tables["Budget"], "Type=1", "", DataViewRowState.CurrentRows); |
| dsAcoount.Tables.Add((DataTable)dv.ToTable("Account")); |
| dv = new DataView(dsb.Tables["Budget"], "Type=2", "", DataViewRowState.CurrentRows); |
| dsAcoount.Tables.Add((DataTable)dv.ToTable("Budget")); |
| dv = new DataView(dsb.Tables["Budget"], "Type=3", "", DataViewRowState.CurrentRows); |
| dsAcoount.Tables.Add((DataTable)dv.ToTable("SubBudget")); |
| LM_Model.clsEnums.BudgetType eVal = clsEnums.BudgetType.Investment; |
| decimal dCurrentInvestment = Convert.ToDecimal(dsAcoount.Tables["Account"].Compute("SUM(TotalBudget)", "BudgetType=" + Convert.ToInt32(eVal))); |
| txtbInvestmentSum.Text = dCurrentInvestment.ToString("#,##0.00"); |
| eVal = clsEnums.BudgetType.Continuous; |
| decimal dCurrentContinues = Convert.ToDecimal(dsAcoount.Tables["Account"].Compute("SUM(TotalBudget)", "BudgetType=" + Convert.ToInt32(eVal))); |
| txtbContinuesSum.Text = dCurrentContinues.ToString("#,##0.00"); |
| decimal dInvestmentBaseline = Convert.ToDecimal(dsb.Tables["BaselineBudget"].Rows[0]["InvestmentBaseline"]); |
| decimal dContinuesBaseline = Convert.ToDecimal(dsb.Tables["BaselineBudget"].Rows[0]["ContinuesBaseline"]); |
| decimal dI = (dCurrentInvestment / dInvestmentBaseline - 1) * 100; |
| decimal dC = (dCurrentContinues / dContinuesBaseline - 1) * 100; |
| txtInv.Text = dI.ToString("#.00"); |
| txtCon.Text = dC.ToString("#.00"); |
| DateTime dDate = (DateTime)dsb.Tables["BaselineBudget"].Rows[0]["Date"]; |
| txtBLDate.Text = dDate.ToString("dd/MM/yyyy"); |
| //Add Relations |
| dsAcoount.Relations.Add("BudgetRelation", |
| dsAcoount.Tables["Account"].Columns["Number"], |
| dsAcoount.Tables["Budget"].Columns["ParentID"]); |
| dsAcoount.Relations.Add("SubBudgetRelation", |
| dsAcoount.Tables["Budget"].Columns["Number"], |
| dsAcoount.Tables["SubBudget"].Columns["ParentID"]); |
| return dsAcoount; |
| } |
| } |
| catch { } |
| return null; |
| } |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID < 2000")); |

We are using the Radtreeview control in our Query Builder application to show the Tables and Fields from the Dtabase . The user can drag and drop the fields in to Selection list (select clause - listbox) and Condition list (where clause - listbox). When i drag and drop the field in to Selection list or Condition list, the selected treeview item(field) removed from the RadTreeView. I want to use the same field in both the lists.
Thanks,
| private void BindDataMainGrid() |
| { |
| try |
| { |
| GridViewTableDefinition BudgetTableDefinition = new GridViewTableDefinition(); |
| BudgetTableDefinition.Relation = new PropertyRelation("Budget"); |
| GridViewTableDefinition SubBudgetTableDefinition = new GridViewTableDefinition(); |
| SubBudgetTableDefinition.Relation = new PropertyRelation("SubBudget"); |
| this.gvAccount.ItemsSource = this.GetData(); |
| } |
| catch{} |
| } |
| private void OnChildGridLoaded(object sender, RoutedEventArgs e) |
| { |
| try |
| { |
| var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext; |
| var ds = dataRowView.DataView.Table.DataSet; |
| var childData = dataRowView.CreateChildView(ds.Relations["BudgetRelation"]); |
| //סינון הערכים בגריד לפי סוג פעילות |
| if (((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id != 0) |
| { |
| childData.RowFilter = "ActivityTypeID=" + ((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id; |
| ((RadGridView)sender).ItemsSource = childData; |
| } |
| else |
| { |
| ((RadGridView)sender).ItemsSource = null; |
| ((RadGridView)sender).ItemsSource = childData; |
| } |
| //סינון הערכים בתיבת הבחירה בעמודה של סוג פעילות |
| if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 1) |
| { |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID < 2000")); |
| } |
| if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 2) |
| { |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID > 2000")); |
| } |
| } |
| catch { } |
| } |
| private void OnSubChildGridLoaded(object sender, RoutedEventArgs e) |
| { |
| try |
| { |
| var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext; |
| var ds = dataRowView.DataView.Table.DataSet; |
| var childData = dataRowView.CreateChildView(ds.Relations["SubBudgetRelation"]); |
| ((RadGridView)sender).ItemsSource = childData; |
| //סינון הערכים בגריד לפי סוג פעילות |
| if (((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id != 0) |
| { |
| childData.RowFilter="ActivityTypeID=" + ((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id; |
| ((RadGridView)sender).ItemsSource = childData; |
| } |
| else |
| { |
| ((RadGridView)sender).ItemsSource = null; |
| ((RadGridView)sender).ItemsSource = childData; |
| } |
| //סינון הערכים בתיבת הבחירה של סוג פעילות |
| if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 1) |
| { |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID < 2000")); |
| } |
| if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 2) |
| { |
| ((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID > 2000")); |
| } |
| } |
| catch { } |
| } |