public virtual void Load_Params() { try { var container = this.Container_Params; container.Controls.Clear(); jwcControlBase ctrl = null; // ReCreate... if (this.Ctrl_ParamsID.Count > 0) { foreach (var paramID in this.Ctrl_ParamsID) { if (string.IsNullOrEmpty(paramID)) { continue; } ctrl = this.Get_SwitchControl(paramID); container.Controls.Add(ctrl); } } else // Add new... { var filters = this.IntrFilters; if (filters == null) { return; } foreach (var filter in filters) { var paramID = string.Format("{0}_{1}-{2}", this.DashboardCode, this.WidgetCode, filter.Name); ctrl = this.Get_SwitchControl(paramID); container.Controls.Add(ctrl); this.Ctrl_ParamsID.Add(ctrl.ID); } } // Add Command Apply. if (container.Controls.Count > 0) { var cmdCtrl = this.Get_CmdApplyParam(); container.Controls.Add(cmdCtrl); } } catch { } }
protected jwcControlBase Get_SwitchControl(string ctrlID) { jwcControlBase ctrl = null; try { var name = ctrlID.Split('-').Last(); var filters = this.IntrFilters; if (filters == null) { return(null); } var obj = filters.FirstOrDefault(p => p.Name == name); if (obj == null) { return(null); } var timeFieldName = ""; var ctrlName = obj.Control; if (ctrlName == "ComboBox") { ctrl = this.LoadControl("~/App/jwc/jwcComboBox.ascx") as jwcComboBox; } else if (ctrlName == "CheckedComboBox") { ctrl = this.LoadControl("~/App/jwc/jwcComboBoxChecked.ascx") as jwcComboBoxChecked; } else if (ctrlName == "TreeListBox") { } else if (ctrlName == "Calendar_Year") { ctrl = this.LoadControl("~/App/jwc/jwcDateEdit.ascx") as jwcDateEdit; ctrl.DisplayFormat = "yy"; timeFieldName = "Year"; } else if (ctrlName == "Calendar_Quarter") { ctrl = this.LoadControl("~/App/jwc/jwcDateEdit.ascx") as jwcDateEdit; ctrl.DisplayFormat = "q"; timeFieldName = "Quarter"; } else if (ctrlName == "Calendar_Period") { ctrl = this.LoadControl("~/App/jwc/jwcDateEdit.ascx") as jwcDateEdit; ctrl.DisplayFormat = "mm/yy"; timeFieldName = "Period"; } else if (ctrlName == "Calendar_Day") { ctrl = this.LoadControl("~/App/jwc/jwcDateEdit.ascx") as jwcDateEdit; ctrl.DisplayFormat = "dd/mm/yy"; timeFieldName = "DateKey"; } else if (ctrlName == "Calendar_Prev") { } ctrl.ID = ctrlID; ctrl.IsEnableRange = obj.EnableRange; ctrl.FunctionJSGetValue = string.Format("{0}_GetParam", ctrl.ID.Replace('-', '_')); ctrl.KeyField = !string.IsNullOrEmpty(timeFieldName) ? timeFieldName : obj.SourceField; ctrl.DataSource = this.Get_DataField(obj.SourceField); ctrl.Caption = obj.Caption; } catch { } return(ctrl); }