protected void rbl_ValueFrom_SelectedIndexChanged(object sender, EventArgs e) { tbx_searchvalue.Text = ""; tbx_searchvalue.Attributes["onfocus"] = ""; cbl_SearchValue.Items.Clear(); tbx_searchvalue.Visible = false; cbl_SearchValue.Visible = false; MCSSelectControl1.Visible = false; MCSTreeControl1.Visible = false; ddl_Param.Visible = false; if (rbl_ValueFrom.SelectedValue == "M") { #region 条件选择 UD_ModelFields modelfield = new UD_ModelFieldsBLL(new Guid(ddl_Field.SelectedValue), true).Model; if (modelfield == null) { return; } switch (modelfield.RelationType) { case 1: //字典关联 cbl_SearchValue.DataTextField = "Value"; cbl_SearchValue.DataValueField = "Key"; cbl_SearchValue.DataSource = DictionaryBLL.GetDicCollections(modelfield.RelationTableName); cbl_SearchValue.DataBind(); cbl_SearchValue.Visible = true; break; case 2: //实体表关联 if (!string.IsNullOrEmpty(modelfield.SearchPageURL)) { //通过查询控件查询 MCSSelectControl1.PageUrl = modelfield.SearchPageURL; MCSSelectControl1.Visible = true; } else if (new UD_TableListBLL(modelfield.RelationTableName).Model.TreeFlag == "Y") { MCSTreeControl1.DataSource = null; if (modelfield.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); MCSTreeControl1.DataSource = staff.GetStaffOrganizeCity(); if (MCSTreeControl1.DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { MCSTreeControl1.RootValue = "0"; MCSTreeControl1.SelectValue = "0"; } else { MCSTreeControl1.RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); MCSTreeControl1.SelectValue = staff.Model.OrganizeCity.ToString(); } #endregion } else { //通过树形结构查询 MCSTreeControl1.TableName = modelfield.RelationTableName; MCSTreeControl1.RootValue = "0"; MCSTreeControl1.SelectValue = "0"; } MCSTreeControl1.DataBind(); MCSTreeControl1.Visible = true; } else { //其他关联方式的实体表 cbl_SearchValue.DataTextField = "Value"; cbl_SearchValue.DataValueField = "Key"; cbl_SearchValue.DataSource = TreeTableBLL.GetRelationTableSourceData(modelfield.RelationTableName, modelfield.RelationValueField, modelfield.RelationTextField); cbl_SearchValue.DataBind(); cbl_SearchValue.Visible = true; } break; default: //非关联字段 tbx_searchvalue.Visible = true; break; } #endregion } else { ddl_Param.Visible = true; } }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { if (DataSet == Guid.Empty) { return; } IList <Rpt_DataSetParams> paramfields = new Rpt_DataSetBLL(DataSet, true).GetParams(); if (paramfields.Count == 0) { return; //无参数 } HtmlTable T_Content = new HtmlTable(); string[] tablestyles = new string[] { "tabForm", "dataLabel", "dataField" }; T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel tr_panel.ID = "DataSetParamPanel"; HtmlTableCell tc_panel = new HtmlTableCell(); #region The title of the panel HtmlTable tb_panel_title = new HtmlTable(); tb_panel_title.CellPadding = 0; tb_panel_title.CellSpacing = 0; tb_panel_title.Width = "100%"; tb_panel_title.Height = "28px"; tb_panel_title.Border = 0; tb_panel_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_panel_title = new HtmlTableRow(); HtmlTableCell tc_panel_title = new HtmlTableCell(); tc_panel_title.InnerHtml = "<h3>请设置统计报表参数信息</h3>"; tr_panel_title.Cells.Add(tc_panel_title); tb_panel_title.Rows.Add(tr_panel_title); tc_panel.Controls.Add(tb_panel_title); #endregion #region The content of the panel int FieldCount = 3; HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = tablestyles[0]; int i = 0; foreach (Rpt_DataSetParams param in paramfields) { string ControlID = "Param_" + param.ParamName.Replace("@", ""); //判断该控件是否已存在 if (ParamControlsInfo.ContainsKey(ControlID)) { continue; } ParamControlsInfo.Add(ControlID, param); if (param.Visible == "Y") { #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = tablestyles[1]; tc_displayname.InnerText = param.DisplayName; if (tc_displayname.InnerText.Length <= 6) { tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; } else { tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;"; } tc_displayname.Attributes["nowrap"] = "nowrap"; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = tablestyles[2]; i++; WebControl control = null; int RelationType = param.RelationType; string RelationTableName = param.RelationTableName; string RelationValueField = param.RelationValueField; string RelationTextField = param.RelationTextField; #region 根据控件类型生成相应的控件 switch (param.ControlType) { case 1: //Label control = new Label(); ((Label)control).Text = GetDefaule(param.DefaultValue); break; case 2: //TextBox control = new TextBox(); if (param.DataType == 4) { control.Attributes["onfocus"] = "WdatePicker();"; } ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 3: //DropDownList control = new DropDownList(); if (RelationType == 1) //Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); if (param.DataType != 5) { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); } else { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); } if (param.DefaultValue != "") { if (((DropDownList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) { ((DropDownList)control).SelectedValue = GetDefaule(param.DefaultValue); } } break; case 4: //RadioButtonList control = new RadioButtonList(); if (RelationType == 1) //Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) { ((RadioButtonList)control).SelectedIndex = 0; } if (param.DefaultValue != "") { if (((RadioButtonList)control).Items.FindByValue(GetDefaule(param.DefaultValue)) != null) { ((RadioButtonList)control).SelectedValue = GetDefaule(param.DefaultValue); } } break; case 5: //MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; ((TextBox)control).Text = GetDefaule(param.DefaultValue); break; case 6: //TextBox supports search control = new MCSSelectControl(); control.ID = ControlID; if (param.SearchPageURL != "") { ((MCSSelectControl)control).PageUrl = param.SearchPageURL; } if (param.DefaultValue != "") { control.Init += new EventHandler(control_Init); } break; case 7: //MCSTreeControl control = new MCSTreeControl(); control.ID = ControlID; if (param.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } } #endregion } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } if (param.DefaultValue != "") { if (((MCSTreeControl)control).SelectValue == "0" || ((MCSTreeControl)control).SelectValue == "") { ((MCSTreeControl)control).SelectValue = GetDefaule(param.DefaultValue); } } break; } #endregion control.ID = ControlID; control.Enabled = param["Enable"] != "N"; int controlwidth = 0; if (int.TryParse(param["ControlWidth"], out controlwidth)) { control.Width = new Unit(controlwidth); } tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (param["IsRequireField"] == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = " *"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } if (param.ControlType == 2 || param.ControlType == 5) { if (param["IsRequireField"] == "Y") { RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(_requiredfieldvalidator); } if (param.DataType == 1 || param.DataType == 2 || param.DataType == 4) //非varchar 字符串 { CompareValidator _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; if (param.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (param.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (param.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } else { if (param.RegularExpression != "") { RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = param.RegularExpression; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } } } #endregion tr_panel_detail.Cells.Add(tc_control); #endregion } } #endregion tc_panel.Controls.Add(tb_panel_content); tr_panel.Cells.Add(tc_panel); T_Content.Rows.Add(tr_panel); }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { Hashtable _htDataObjectdControlsInfo = new Hashtable(); HtmlTable T_Content = new HtmlTable(); T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); HtmlTableRow T_tr_title = new HtmlTableRow(); HtmlTableCell T_tc_title = new HtmlTableCell(); T_tr_title.Cells.Add(T_tc_title); T_Content.Rows.Add(T_tr_title); #region The title of the panel HtmlTable tb_title = new HtmlTable(); T_tc_title.Controls.Add(tb_title); tb_title.CellPadding = 0; tb_title.CellSpacing = 0; tb_title.Width = "100%"; tb_title.Height = "30px"; tb_title.Border = 0; tb_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_title = new HtmlTableRow(); HtmlTableCell tc_title = new HtmlTableCell(); tr_title.Cells.Add(tc_title); tb_title.Rows.Add(tr_title); tc_title.InnerHtml = "<h3>工作流提交的数据字段内容</h3>"; #endregion #region The content of the panel HtmlTableRow T_tr_panelcontent = new HtmlTableRow(); T_tr_panelcontent.ID = "T_tr_panelcontent"; HtmlTableCell T_tc_panelcontent = new HtmlTableCell(); T_tr_panelcontent.Cells.Add(T_tc_panelcontent); T_Content.Rows.Add(T_tr_panelcontent); HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = "tabForm"; T_tc_panelcontent.Controls.Add(tb_panel_content); IList <EWF_Flow_DataObject> _dataobjects = new EWF_Flow_AppBLL(App).GetDataObjectList(); int i = 0; foreach (EWF_Flow_DataObject _dataobject in _dataobjects) { if (_dataobject.Visible == "N") { continue; } #region 判断该控件是否已存在 if (_htDataObjectdControlsInfo.Contains(_dataobject.Name)) { continue; } #endregion #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = "dataLabel"; tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; tc_displayname.Attributes["nowrap"] = "nowrap"; tc_displayname.InnerText = _dataobject.DisplayName; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = "dataField"; if (_dataobject.ColSpan > 0) { if (i + _dataobject.ColSpan <= FieldCount) { tc_control.ColSpan = 2 * _dataobject.ColSpan - 1; i = i + _dataobject.ColSpan; } else { tc_control.ColSpan = 2 * (FieldCount - i) - 1; i = 0; } } else { i++; } WebControl control = null; int RelationType = _dataobject.RelationType; string RelationTableName = _dataobject.RelationTableName; string RelationValueField = _dataobject.RelationValueField; string RelationTextField = _dataobject.RelationTextField; #region 根据控件类型生成相应的控件 switch (_dataobject.ControlType) { case 1: //Label control = new Label(); break; case 2: //TextBox control = new TextBox(); if (_dataobject.DataType == 4) { control.Attributes["onfocus"] = "setday(this);"; } break; case 3: //DropDownList control = new DropDownList(); if (RelationType == 1) //Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); break; case 4: //RadioButtonList control = new RadioButtonList(); if (RelationType == 1) //Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) { ((RadioButtonList)control).SelectedIndex = 0; } break; case 5: //MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; if (_dataobject.ControlHeight > 0) { ((TextBox)control).Height = new Unit(_dataobject.ControlHeight); } break; case 6: //TextBox supports search control = new MCSSelectControl(); control.ID = "C_" + _dataobject.Name.ToString(); if (RelationType == 2) //Relation to the model table { ((MCSSelectControl)control).PageUrl = _dataobject.SearchPageURL; } break; case 7: //MCSTreeControl control = new MCSTreeControl(); if (RelationType == 2) //Relation to the model table { control.ID = "C_" + _dataobject.Name.ToString(); //在设置控件DataSource之前,必须要有ID属性 Shen Gang 20090110 if (_dataobject.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } } #endregion } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; } } break; } #endregion control.ID = "C_" + _dataobject.Name.ToString(); control.Enabled = _dataobject.Enable.ToUpper() == "Y"; control.ToolTip = _dataobject.Description; if (_dataobject.ControlWidth > 0) { control.Width = _dataobject.ControlWidth; } tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (_dataobject.IsRequireField == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = "*"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } //add validate control for the textbox if (_dataobject.ControlType == 2 || _dataobject.ControlType == 5) { RequiredFieldValidator _requiredfieldvalidator = null; CompareValidator _comparevalidator = null; RegularExpressionValidator _regularexpressionvalidator = null; if (_dataobject.IsRequireField == "Y") { _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; _requiredfieldvalidator.ValidationGroup = _validationgroup; tc_control.Controls.Add(_requiredfieldvalidator); } if (_dataobject.DataType == 1 || _dataobject.DataType == 2 || _dataobject.DataType == 4) //非varchar 字符串 { _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; _comparevalidator.ValidationGroup = _validationgroup; if (_dataobject.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (_dataobject.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (_dataobject.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } else { if (_dataobject.RegularExpression != "") { _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = _dataobject.RegularExpression; _regularexpressionvalidator.ValidationGroup = ValidationGroup; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } } } #endregion tr_panel_detail.Cells.Add(tc_control); #endregion #region Record the info of the control created DataObjectControlInfo dataobjectcontrolinfo = new DataObjectControlInfo(); dataobjectcontrolinfo.ControlName = control.ID; dataobjectcontrolinfo.ControlType = _dataobject.ControlType; dataobjectcontrolinfo.DataObjectID = _dataobject.ID; dataobjectcontrolinfo.DataObjectName = _dataobject.Name; _htDataObjectdControlsInfo.Add(dataobjectcontrolinfo.DataObjectName, dataobjectcontrolinfo); #endregion } #endregion ViewState["HTDataObjectControlInfo"] = _htDataObjectdControlsInfo; if (new EWF_Flow_AppBLL(App).Model.RelateBusiness.ToUpper() == "Y") { SetPanelEnable(false); } }
/// <summary> /// Init the components of the panel through the special pageid /// </summary> private void InitComponents() { HtmlTable T_Content = new HtmlTable(); T_Content.CellPadding = 0; T_Content.CellSpacing = 0; T_Content.Width = "100%"; T_Content.Border = 0; T_Content.ID = "T_Content_" + ID; this.Controls.Add(T_Content); UD_DetailViewBLL _DetailViewBll = new UD_DetailViewBLL(DetailViewCode, true); IList <UD_Panel> _panellist = _DetailViewBll.GetDetailPanels(); Hashtable _htFieldControlsInfo = new Hashtable(); foreach (UD_Panel _panelmodel in _panellist) { HtmlTableRow tr_panel = new HtmlTableRow();//Create one TableRow for a panel tr_panel.ID = _panelmodel.Code; if (_panelmodel.Enable.ToUpper() == "N") { tr_panel.Visible = false; } HtmlTableCell tc_panel = new HtmlTableCell(); string _tablestytle = _panelmodel.TableStyle; string[] _tablestyles = _panelmodel.TableStyle.Split(new char[] { ',' }); if (_tablestyles.Length < 3) { _tablestyles = ("tabForm,dataLabel,dataField").Split(new char[] { ',' }); } #region The title of the panel if (_panelmodel.Name != "") { HtmlTable tb_panel_title = new HtmlTable(); tb_panel_title.CellPadding = 0; tb_panel_title.CellSpacing = 0; tb_panel_title.Width = "100%"; tb_panel_title.Height = "28px"; tb_panel_title.Border = 0; tb_panel_title.Attributes["class"] = "h3Row"; HtmlTableRow tr_panel_title = new HtmlTableRow(); HtmlTableCell tc_panel_title = new HtmlTableCell(); tc_panel_title.InnerHtml = "<h3>" + _panelmodel.Name + "</h3>"; tr_panel_title.Cells.Add(tc_panel_title); tb_panel_title.Rows.Add(tr_panel_title); tc_panel.Controls.Add(tb_panel_title); } #endregion #region The content of the panel IList <UD_Panel_ModelFields> fields = new UD_PanelBLL(_panelmodel.ID, true).GetModelFields(); int FieldCount = _panelmodel.FieldCount; HtmlTable tb_panel_content = new HtmlTable(); tb_panel_content.Width = "100%"; tb_panel_content.Attributes["class"] = _tablestyles[0]; int i = 0; foreach (UD_Panel_ModelFields _panel_modelfields in fields) { if (_panel_modelfields.Visible == "N") { continue; } UD_ModelFields _modelfieldsmodel = new UD_ModelFieldsBLL(_panel_modelfields.FieldID, true).Model; UD_TableList _tablemodel = new UD_TableListBLL(_modelfieldsmodel.TableID, true).Model; #region 判断该控件是否已存在 if (_htFieldControlsInfo.Contains(_tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName)) { continue; } #endregion #region 判断是否要增加新行 HtmlTableRow tr_panel_detail; if (i >= FieldCount || i == 0) { tr_panel_detail = new HtmlTableRow(); tb_panel_content.Rows.Add(tr_panel_detail); i = 0; } else { tr_panel_detail = tb_panel_content.Rows[tb_panel_content.Rows.Count - 1]; } #endregion #region 增加Label Cell HtmlTableCell tc_displayname = new HtmlTableCell(); tc_displayname.Attributes["Class"] = _tablestyles[1]; tc_displayname.InnerText = string.IsNullOrEmpty(_panel_modelfields.LabelText) ? _modelfieldsmodel.DisplayName : _panel_modelfields.LabelText; if (tc_displayname.InnerText.Length <= 6) { tc_displayname.Attributes["Style"] = "width: 80px; height: 18px;"; } else { tc_displayname.Attributes["Style"] = "width: 100px; height: 18px;"; } tc_displayname.Attributes["nowrap"] = "nowrap"; tr_panel_detail.Cells.Add(tc_displayname); #endregion #region 增加Field Cell HtmlTableCell tc_control = new HtmlTableCell(); tc_control.Attributes["Class"] = _tablestyles[2]; if (_panel_modelfields.ColSpan > 0) { if (i + _panel_modelfields.ColSpan <= FieldCount) { tc_control.ColSpan = 2 * _panel_modelfields.ColSpan - 1; i = i + _panel_modelfields.ColSpan; } else { tc_control.ColSpan = 2 * (FieldCount - i) - 1; i = 0; } } else { i++; } WebControl control = null; int RelationType = _modelfieldsmodel.RelationType; string RelationTableName = _modelfieldsmodel.RelationTableName; string RelationValueField = _modelfieldsmodel.RelationValueField; string RelationTextField = _modelfieldsmodel.RelationTextField; #region 根据控件类型生成相应的控件 switch (_panel_modelfields.ControlType) { case 1: //Label control = new Label(); break; case 2: //TextBox control = new TextBox(); if (_modelfieldsmodel.DataType == 4) { control.Attributes["onfocus"] = "WdatePicker();"; } break; case 3: //DropDownList control = new DropDownList(); if (RelationType == 1) //Relation to the dictionary { ((DropDownList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((DropDownList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((DropDownList)control).DataTextField = "Value"; ((DropDownList)control).DataValueField = "Key"; ((DropDownList)control).DataBind(); if (_modelfieldsmodel.DataType != 5) { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", "0")); } else { ((DropDownList)control).Items.Insert(0, new ListItem("请选择...", Guid.Empty.ToString())); } break; case 4: //RadioButtonList control = new RadioButtonList(); if (RelationType == 1) //Relation to the dictionary { ((RadioButtonList)control).DataSource = DictionaryBLL.GetDicCollections(RelationTableName, true); } else if (RelationType == 2) //Relation to the model table { ((RadioButtonList)control).DataSource = TreeTableBLL.GetRelationTableSourceData(RelationTableName, RelationValueField, RelationTextField); } else { break; } ((RadioButtonList)control).RepeatColumns = 6; ((RadioButtonList)control).RepeatDirection = RepeatDirection.Horizontal; ((RadioButtonList)control).DataTextField = "Value"; ((RadioButtonList)control).DataValueField = "Key"; ((RadioButtonList)control).DataBind(); if (((RadioButtonList)control).Items.Count != 0) { ((RadioButtonList)control).SelectedIndex = 0; } break; case 5: //MutiLinesTextBox control = new TextBox(); ((TextBox)control).TextMode = TextBoxMode.MultiLine; if (_panel_modelfields.ControlHeight > 0) { ((TextBox)control).Height = new Unit(_panel_modelfields.ControlHeight); } break; case 6: //TextBox supports search control = new MCSSelectControl(); if (RelationType == 2) //Relation to the model table { control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; if (_panel_modelfields.SearchPageURL != "") { ((MCSSelectControl)control).PageUrl = _panel_modelfields.SearchPageURL; } else if (_modelfieldsmodel.SearchPageURL != "") { ((MCSSelectControl)control).PageUrl = _modelfieldsmodel.SearchPageURL; } } break; case 7: //MCSTreeControl control = new MCSTreeControl(); if (RelationType == 2) //Relation to the model table { control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; if (_modelfieldsmodel.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取所能管辖的片区 if (System.Web.HttpContext.Current.Session["AccountType"] == null || (int)System.Web.HttpContext.Current.Session["AccountType"] == 1) { //员工 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); ((MCSTreeControl)control).DataSource = staff.GetStaffOrganizeCity(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (((MCSTreeControl)control).DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = staff.Model.OrganizeCity.ToString(); } } } else if ((int)System.Web.HttpContext.Current.Session["AccountType"] == 2 && System.Web.HttpContext.Current.Session["OrganizeCity"] != null) { //商业客户 int city = (int)System.Web.HttpContext.Current.Session["OrganizeCity"]; Addr_OrganizeCityBLL citybll = new Addr_OrganizeCityBLL(city); ((MCSTreeControl)control).DataSource = citybll.GetAllChildNodeIncludeSelf(); ((MCSTreeControl)control).RootValue = citybll.Model.SuperID.ToString(); ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = city.ToString(); } } #endregion } else if (_modelfieldsmodel.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity") { ((MCSTreeControl)control).TableName = "MCS_SYS.dbo.Addr_OfficialCity"; ((MCSTreeControl)control).IDColumnName = "ID"; ((MCSTreeControl)control).NameColumnName = "Name"; ((MCSTreeControl)control).ParentColumnName = "SuperID"; ((MCSTreeControl)control).RootValue = "0"; if (!Page.IsPostBack) { ((MCSTreeControl)control).SelectValue = "0"; } } else { ((MCSTreeControl)control).TableName = RelationTableName; ((MCSTreeControl)control).IDColumnName = RelationValueField; ((MCSTreeControl)control).NameColumnName = RelationTextField; ((MCSTreeControl)control).ParentColumnName = "SuperID"; } } break; } #endregion control.ID = _tablemodel.ModelClassName + "_" + _modelfieldsmodel.FieldName; control.Enabled = _panel_modelfields.Enable.ToUpper() == "Y"; if (_panel_modelfields.ControlWidth > 0) { control.Width = _panel_modelfields.ControlWidth; } tc_control.Controls.Add(control); #region 如果是文本框时,加上输入验证控件 if (_panel_modelfields.IsRequireField == "Y") { Label lbl_reqinfo = new Label(); lbl_reqinfo.Text = " *"; lbl_reqinfo.ForeColor = System.Drawing.Color.Red; tc_control.Controls.Add(lbl_reqinfo); } if (_panel_modelfields.ControlType == 2 || _panel_modelfields.ControlType == 5) { if (_panel_modelfields.IsRequireField == "Y") { RequiredFieldValidator _requiredfieldvalidator = new RequiredFieldValidator(); _requiredfieldvalidator.ControlToValidate = control.ID; _requiredfieldvalidator.Display = ValidatorDisplay.Dynamic; _requiredfieldvalidator.ErrorMessage = "必填"; _requiredfieldvalidator.ForeColor = System.Drawing.Color.Red; _requiredfieldvalidator.ValidationGroup = _validationgroup; tc_control.Controls.Add(_requiredfieldvalidator); } if (_panel_modelfields.RegularExpression != "") { RegularExpressionValidator _regularexpressionvalidator = new RegularExpressionValidator(); _regularexpressionvalidator.ControlToValidate = control.ID; _regularexpressionvalidator.ErrorMessage = "数据格式不正确"; _regularexpressionvalidator.ForeColor = System.Drawing.Color.Red; _regularexpressionvalidator.ValidationExpression = _panel_modelfields.RegularExpression; _regularexpressionvalidator.ValidationGroup = ValidationGroup; _regularexpressionvalidator.Display = ValidatorDisplay.Dynamic; tc_control.Controls.Add(_regularexpressionvalidator); } else { if (_modelfieldsmodel.DataType == 1 || _modelfieldsmodel.DataType == 2 || _modelfieldsmodel.DataType == 4) //非varchar 字符串 { CompareValidator _comparevalidator = new CompareValidator(); _comparevalidator.ControlToValidate = control.ID; _comparevalidator.Operator = ValidationCompareOperator.DataTypeCheck; _comparevalidator.Display = ValidatorDisplay.Dynamic; _comparevalidator.ForeColor = System.Drawing.Color.Red; _comparevalidator.ValidationGroup = _validationgroup; if (_modelfieldsmodel.DataType == 1)//int { _comparevalidator.Type = ValidationDataType.Integer; _comparevalidator.ErrorMessage = "应为整数"; } if (_modelfieldsmodel.DataType == 2)//decimal { _comparevalidator.Type = ValidationDataType.Double; _comparevalidator.ErrorMessage = "应为数字"; } if (_modelfieldsmodel.DataType == 4)//datetime { _comparevalidator.Type = ValidationDataType.Date; _comparevalidator.ErrorMessage = "日期格式不正确"; } tc_control.Controls.Add(_comparevalidator); } } } #endregion if (!string.IsNullOrEmpty(_panel_modelfields.Description)) { Label lb = new Label(); lb.Text = " " + _panel_modelfields.Description; tc_control.Controls.Add(lb); } tr_panel_detail.Cells.Add(tc_control); #endregion #region 将控件记录到字段控件HashTable中 FieldControlInfo fieldcontrolinfo = new FieldControlInfo(); fieldcontrolinfo.FieldID = _modelfieldsmodel.ID; fieldcontrolinfo.FieldName = _modelfieldsmodel.FieldName; fieldcontrolinfo.ModelName = _tablemodel.ModelClassName; fieldcontrolinfo.ControlType = _panel_modelfields.ControlType; fieldcontrolinfo.ControlName = control.ID; fieldcontrolinfo.DisplayMode = _panel_modelfields.DisplayMode; fieldcontrolinfo.Panel_Field_ID = _panel_modelfields.ID; _htFieldControlsInfo.Add(fieldcontrolinfo.ControlName, fieldcontrolinfo); #endregion } #endregion tc_panel.Controls.Add(tb_panel_content); tr_panel.Cells.Add(tc_panel); T_Content.Rows.Add(tr_panel); } ViewState["FieldControlsInfo"] = _htFieldControlsInfo; }
protected void ddl_Field_SelectedIndexChanged(object sender, EventArgs e) { tbx_searchvalue.Text = ""; tbx_searchvalue.Attributes["onfocus"] = ""; cbl_SearchValue.Items.Clear(); ddl_op.Items.Clear(); ddl_TreeLevel.Visible = false; tbx_searchvalue.Visible = false; cbl_SearchValue.Visible = false; MCSSelectControl1.Visible = false; MCSTreeControl1.Visible = false; #region 条件选择 UD_ModelFields modelfield = null; try { modelfield = new UD_ModelFieldsBLL(new Guid(ddl_Field.SelectedValue), true).Model; } catch { } if (modelfield == null) { #region 外部自定义条件 ddl_op.Items.Add(new ListItem("等于", "=")); ddl_op.Items.Add(new ListItem("大于", ">")); ddl_op.Items.Add(new ListItem("大于等于", ">=")); ddl_op.Items.Add(new ListItem("小于", "<")); ddl_op.Items.Add(new ListItem("小于等于", "<=")); ddl_op.Items.Add(new ListItem("不等于", "<>")); tbx_searchvalue.Visible = true; #endregion } else { switch (modelfield.RelationType) { case 1: #region 字典关联 cbl_SearchValue.DataTextField = "Value"; cbl_SearchValue.DataValueField = "Key"; cbl_SearchValue.DataSource = DictionaryBLL.GetDicCollections(modelfield.RelationTableName); cbl_SearchValue.DataBind(); cbl_SearchValue.Visible = true; ddl_op.Items.Insert(0, new ListItem("值", "SELECTITEM")); break; #endregion case 2: #region 实体表关联 if (!string.IsNullOrEmpty(modelfield.SearchPageURL)) { //通过查询控件查询 MCSSelectControl1.PageUrl = modelfield.SearchPageURL; MCSSelectControl1.Visible = true; } else if (new UD_TableListBLL(modelfield.RelationTableName).Model.TreeFlag == "Y") { if (modelfield.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { #region 如果为管理片区字段,则取员工所能管辖的片区 Org_StaffBLL staff = new Org_StaffBLL((int)System.Web.HttpContext.Current.Session["UserID"]); MCSTreeControl1.DataSource = staff.GetStaffOrganizeCity(); if (MCSTreeControl1.DataSource.Select("ID = 1").Length > 0 || staff.Model.OrganizeCity == 0) { MCSTreeControl1.RootValue = "0"; MCSTreeControl1.SelectValue = "0"; } else { MCSTreeControl1.RootValue = new Addr_OrganizeCityBLL(staff.Model.OrganizeCity).Model.SuperID.ToString(); MCSTreeControl1.SelectValue = staff.Model.OrganizeCity.ToString(); } #endregion } else { //通过树形结构查询 MCSTreeControl1.DataSource = null; MCSTreeControl1.TableName = modelfield.RelationTableName; MCSTreeControl1.RootValue = "0"; MCSTreeControl1.SelectValue = "0"; } MCSTreeControl1.DataBind(); MCSTreeControl1.Visible = true; #region 如果是管理片区或行政城市,可以选择指定的树形级别 if (modelfield.RelationTableName == "MCS_SYS.dbo.Addr_OrganizeCity") { ddl_TreeLevel.Items.Clear(); ddl_TreeLevel.Items.Insert(0, new ListItem("所属于", "100")); ddl_TreeLevel.Items.Insert(1, new ListItem("当前值", "0")); ddl_TreeLevel.Visible = true; } else if (modelfield.RelationTableName == "MCS_SYS.dbo.Addr_OfficialCity") { ddl_TreeLevel.Items.Clear(); ddl_TreeLevel.Items.Insert(0, new ListItem("所属于", "100")); ddl_TreeLevel.Items.Insert(1, new ListItem("当前值", "0")); ddl_TreeLevel.Visible = true; } #endregion } else { //其他关联方式的实体表 cbl_SearchValue.DataTextField = "Value"; cbl_SearchValue.DataValueField = "Key"; cbl_SearchValue.DataSource = TreeTableBLL.GetRelationTableSourceData(modelfield.RelationTableName, modelfield.RelationValueField, modelfield.RelationTextField); cbl_SearchValue.DataBind(); cbl_SearchValue.Visible = true; } ddl_op.Items.Insert(0, new ListItem("值", "SELECTITEM")); break; #endregion default: #region 非关联字段 switch (modelfield.DataType) { case 1: //整型(int) case 2: //小数(decimal) ddl_op.Items.Add(new ListItem("等于", "=")); ddl_op.Items.Add(new ListItem("大于", ">")); ddl_op.Items.Add(new ListItem("大于等于", ">=")); ddl_op.Items.Add(new ListItem("小于", "<")); ddl_op.Items.Add(new ListItem("小于等于", "<=")); ddl_op.Items.Add(new ListItem("不等于", "<>")); break; case 3: //字符串(varchar) case 6: //字符串(nvarchar) case 8: //ntext ddl_op.Items.Add(new ListItem("等于", "=")); ddl_op.Items.Add(new ListItem("相似", "like")); ddl_op.Items.Add(new ListItem("起始于", "StartWith")); ddl_op.Items.Add(new ListItem("不起始于", "NotStartWith")); break; case 4: //日期(datetime) ddl_op.Items.Add(new ListItem("等于", "=")); ddl_op.Items.Add(new ListItem("大于等于", ">=")); ddl_op.Items.Add(new ListItem("小于等于", "<=")); ddl_op.Visible = true; tbx_searchvalue.Attributes["onfocus"] = "setday(this)"; break; case 5: //GUID(uniqueidentifier) case 7: //bit ddl_op.Items.Add(new ListItem("等于", "=")); ddl_op.Items.Add(new ListItem("不等于", "<>")); break; } tbx_searchvalue.Visible = true; break; #endregion } ddl_op.Items.Add(new ListItem("不为空", "NOTNULL")); ddl_op.Items.Add(new ListItem("为空", "ISNULL")); } #endregion ddl_op.SelectedIndex = 0; }