/// <summary> /// 根据属性,实例化需要的数据 /// </summary> /// user:jyk /// time:2012/9/12 14:46 public void Create() { if (PageViewMeta == null) { //获取页面视图 var mgrPVM = new ManagerPageViewMeta { DalCollection = DalCollection, PageViewID = PageViewID }; PageViewMeta = mgrPVM.GetPageViewMeta(null); } if (ManagerData == null) { ManagerData = new ManagerData { Dal = DalCollection.DalCustomer, DictFormColumnMeta = ManagerMeta.GetMetaData(null), PageViewMeta = PageViewMeta }; } }
/// <summary> /// 显示表单 /// </summary> public bool ShowForm() { //True:表单控件;False:查询控件 //查询控件 bool isForm = ControlKind != PageViewType.FindForm; #region 加载配置信息 if (DicBaseCols == null) { DicBaseCols = ManagerMeta.GetMetaData(null); } //没有配置信息,退出 if (DicBaseCols == null) { if (!isForm) //查询控件没有设置配置信息 { Functions.MsgBox("", false); } else { Functions.MsgBox("表单控件没有设置配置信息", true); } return(false); } //创建字段值的容器 DicColumnsValue = ManagerMeta.CreateDicColumnValue(DicBaseCols); #endregion #region 加载控件类型 //if (dic_FormControls == null) // dic_FormControls = ColumnsInfoMgr.LoadFormControl(); //if (dic_FindControls == null) // dic_FindControls = ColumnsInfoMgr.LoadFindControl(); #endregion //定义接口,通过接口操作子控件 //开始绘制表格 Controls.Add(isForm ? new LiteralControl("<table rules=\"all\" class=\"tablem tableClass02\">") : new LiteralControl("<table class=\"tablem tableClass02\">")); Int32 index = 0; //用于多列的设置 #region 循环配置信息 foreach (KeyValuePair <int, IColumn> info in DicBaseCols) { var bInfo = (FormColumnMeta)info.Value; //判断是不是级联下拉列表框 var uniteListExtend = bInfo.ControlExtend as UniteListExtend; if (uniteListExtend != null) { if (uniteListExtend.IsFristList == false) { //不是第一个下拉列表框,略过 continue; } } #region 加载需要的子控件 Control tmpControl = isForm ? DicFormControls[bInfo.ControlKind]() : DicFindControls[bInfo.ControlKind](); #endregion var iControl = (IControlHelp)tmpControl; tmpControl.ID = "ctrl_" + bInfo.ColumnID; //设置ID //iControl.ShowMe(bInfo,dal); #region 显示字段 SetStartTr(index, bInfo); //判断是否显示<TR> //添加到表单控件里 SetStartTd(bInfo); //设置开始的TD Controls.Add(new LiteralControl(bInfo.ColName)); index += SetTDcolspan(bInfo); //设置中间的TD,一个字段占用几个TD Controls.Add(tmpControl); //添加控件 //设置第一个子控件的ClinetID if (_firstChildControlClinetID.Length == 0) { _firstChildControlClinetID = tmpControl.ClientID; } //设置帮助信息 if (bInfo is ModColumnMeta) { if (bInfo.ControlHelpStation == 3) { Controls.Add(new LiteralControl(" " + bInfo.ControlColHelp)); } } SetEndTd(bInfo); //设置结束的TD SetEndTr(index, bInfo); //判断是否显示</TR> ,有了</TR>就相当于换行了 #endregion //Add 后才会调用Onit函数 #region 替换当前登录人的一些信息 //bInfo.ControlInfo = bInfo.ControlInfo.Replace("{PersonID}", base.User.PersonID); //bInfo.ControlInfo = bInfo.ControlInfo.Replace("{UserID}", base.User.PersonID); #endregion if (!base.Page.IsPostBack) { //第一次访问 iControl.ShowMe(bInfo, ManagerMeta.DalCollection.DalCustomer, isForm); //让子控件自己描绘自己 if (ManagerMeta is ManagerFormMeta) { if (new ManagerData().TypeOperationData == ButonType.ViewData) { //设置只读 iControl.SetControlState("2"); } } } else { //回发访问 if (!isForm) //查询控件 { iControl.ShowMe(bInfo, ManagerMeta.DalCollection.DalCustomer, isForm); //让子控件自己描绘自己 } //有些控件在表单回发的时候也需要再次ShowMe switch (bInfo.ControlKind) { case ControlType.SelectRecords: //选择记录的控件,需要设置前台的onclick事件 case ControlType.UniteList: //联动下拉列表框 iControl.ShowMe(bInfo, ManagerMeta.DalCollection.DalCustomer, isForm); //让子控件自己描绘自己 break; } } index++; if (index >= _repeatColumns) { index = 0; } } #endregion #region 表格不满需要补充TD if (index != 0 && index <= _repeatColumns - 1) { //表格不满需要补充TD for (Int32 i = index; i < _repeatColumns; i++) { Controls.Add(new LiteralControl("<TD> </TD>")); Controls.Add(new LiteralControl("<TD> </TD>")); } Controls.Add(new LiteralControl("</TR>")); } #endregion Controls.Add(new LiteralControl("</Table>")); return(true); }