protected void Page_Prerender(object sender, EventArgs e) { if (!IsPostBack) { for (int i = 1; i < RowCount; i++) { HideRow(i); } if (mWhereCriteriaUpdated && mWhereCriteria.Count > 0) { for (int i = 0; i < mWhereCriteria.Count; i++) { var c = mWhereCriteria[i]; ShowRow(i); if (i > 0) { HideListManager(i - 1); } RepeaterItem it = rpWhere.Items[i]; ColumnSelect csWhere = (ColumnSelect)it.FindControl("csWhere"); ConditionSelect Condition = (ConditionSelect)it.FindControl("Condition"); PlaceHolder phValue = (PlaceHolder)it.FindControl("phValue"); System.Web.UI.WebControls.TextBox tbValue = (System.Web.UI.WebControls.TextBox)it.FindControl("tbValue"); Telerik.Web.UI.RadComboBox rcbValue = (Telerik.Web.UI.RadComboBox)it.FindControl("rcbValue"); Telerik.Web.UI.RadNumericTextBox rnValue = (Telerik.Web.UI.RadNumericTextBox)it.FindControl("rnValue"); tbValue.Visible = false; rcbValue.Visible = false; rnValue.Visible = false; csWhere.Select(c.TableName, c.ColumnName); string OutTable; string OutColumn; string TextColumn; string SelectControl; if (!csWhere.SelectedField(DataViewTypeID, out OutTable, out OutColumn, out TextColumn, out SelectControl)) { continue; } Type t = typeof(MetricTrac.Bll.LinqMicajahEntitybase).Assembly.GetType("MetricTrac.Bll." + c.TableName); if (t == null) { continue; } System.Reflection.PropertyInfo pi = t.GetProperty(c.ColumnName); if (pi == null) { continue; } if (SelectControl != null) { Condition.Mode = ConditionSelect.ConditionViewMode.Equal; foreach (Panel p in phValue.Controls) { if (p.ID != System.IO.Path.GetFileNameWithoutExtension(SelectControl)) { continue; } if (!(p.Controls[0] is MetricTrac.Utils.IValueSelectControl)) { continue; } MetricTrac.Utils.IValueSelectControl iv = (MetricTrac.Utils.IValueSelectControl)p.Controls[0]; iv.SelectedValue = c.CompareValue; p.Style[HtmlTextWriterStyle.Display] = "block"; break; } continue; } if (pi.PropertyType == typeof(string)) { Condition.Mode = ConditionSelect.ConditionViewMode.Like; tbValue.Visible = true; tbValue.Text = c.CompareValue; continue; } if (pi.PropertyType == typeof(Guid) || pi.PropertyType == typeof(Guid?)) { Condition.Mode = ConditionSelect.ConditionViewMode.Equal; rcbValue.Visible = true; rcbValue.DataValueField = c.ColumnName; rcbValue.DataTextField = TextColumn; rcbValue.DataSource = MetricTrac.Bll.LinqMicajahDataContext.SelectGuid(c.TableName, c.ColumnName, TextColumn); rcbValue.DataBind(); rcbValue.SelectedValue = c.CompareValue; continue; } foreach (Type nt in NumericType) { if (pi.PropertyType == nt) { Condition.Mode = ConditionSelect.ConditionViewMode.Compare; rnValue.Visible = true; double v; if (!double.TryParse(c.CompareValue, out v)) { continue; } rnValue.Value = v; continue; } } Condition.Mode = ConditionSelect.ConditionViewMode.All; tbValue.Visible = true; } ShowListManager(mWhereCriteria.Count - 1); } else { ShowRow(0); ShowRow(1); ShowRow(2); HideListManager(0); HideListManager(1); ShowListManager(2); } } }
private string GetValue(RepeaterItem it, string Table, string Column, string SelectControl) { ConditionSelect Condition = (ConditionSelect)it.FindControl("Condition"); PlaceHolder phValue = (PlaceHolder)it.FindControl("phValue"); System.Web.UI.WebControls.TextBox tbValue = (System.Web.UI.WebControls.TextBox)it.FindControl("tbValue"); Telerik.Web.UI.RadComboBox rcbValue = (Telerik.Web.UI.RadComboBox)it.FindControl("rcbValue"); Telerik.Web.UI.RadNumericTextBox rnValue = (Telerik.Web.UI.RadNumericTextBox)it.FindControl("rnValue"); Type t = typeof(MetricTrac.Bll.LinqMicajahEntitybase).Assembly.GetType("MetricTrac.Bll." + Table); if (t == null) { return(null); } System.Reflection.PropertyInfo pi = t.GetProperty(Column); if (pi == null) { return(null); } if (SelectControl != null) { foreach (Panel p in phValue.Controls) { if (p.ID != System.IO.Path.GetFileNameWithoutExtension(SelectControl)) { continue; } if (p.Controls.Count < 1) { return(null); } if (!(p.Controls[0] is MetricTrac.Utils.IValueSelectControl)) { return(null); } MetricTrac.Utils.IValueSelectControl iv = (MetricTrac.Utils.IValueSelectControl)p.Controls[0]; if (!iv.IsValueSelected) { return(null); } return(iv.SelectedValue.ToString()); } return(null); } if (pi.PropertyType == typeof(string)) { if (tbValue.Text == string.Empty) { return(null); } return(tbValue.Text); } if (pi.PropertyType == typeof(Guid) || pi.PropertyType == typeof(Guid?)) { if (string.IsNullOrEmpty(rcbValue.SelectedValue)) { return(null); } return(rcbValue.SelectedValue); } foreach (Type nt in NumericType) { if (pi.PropertyType == nt) { if (rnValue.Value == null) { return(null); } return(((double)rnValue.Value).ToString()); } } return(null); }