public static NGComboBox GetCombox(PbBaseControlInfo pbCtl) { PbComboboxInfo pbComb = (PbComboboxInfo)pbCtl; NGComboBox ngComb = new NGComboBox(); ngComb.ID = pbComb.Id; ngComb.Name = pbComb.Name; ngComb.FieldLabel = pbComb.LeftText; ngComb.MustInput = pbComb.IsMustInput; ngComb.XType = "ngComboBox"; ngComb.Visible = pbComb.Visible; ngComb.MustInput = pbComb.IsMustInput; ngComb.Protect = pbComb.IsProtect; ngComb.FieldStyle = GetRgb(pbComb.TextColor); ngComb.LabelStyle = GetRgb(pbComb.LabelTextColor); ngComb.QueryMode = "local"; foreach (var info in pbComb.PbComboboxValueInfos) { ngComb.Data.Add(string.Format(@"code:'{0}', name:'{1}'", info.SaveValue, info.DisplayValue)); } return(ngComb); }
public string GetngComboBox(ExtControlBase controlBase) { if (controlBase is NGComboBox) { sb = string.Format(@" xtype: '{0}', fieldLabel: Lang.{2}||'{1}', id: '{3}', name: '{3}', mustInput: {4}, colspan: {5}, hidden: {6}, readOnly: {7}, x: {8}, y: {9}, width: {10}, value: '{11}', fieldStyle:'color:{12}', labelStyle:'color:{13}', editable: false, trigger1Cls: 'x-form-clear-trigger', onTrigger1Click: function () {{ this.clearValue(); }}, queryMode: 'local', valueField: 'code', displayField: 'name', data:[ ", "ngComboBox", controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle); NGComboBox ngComboBox = controlBase as NGComboBox; for (int i = 0; i < ngComboBox.Data.Count; i++) { sb += "\t\t\t\t\t\t\t\t{" + ngComboBox.Data[i] + "}"; if (i == ngComboBox.Data.Count - 1) { sb += "\r\n"; } else { sb += ",\r\n"; } } } else if (controlBase is NGCommonHelp) { sb = string.Format(@" xtype: '{0}', fieldLabel: '{1}', name: '{2}', id: '{2}', itemId: '{2}', mustInput: {3}, colspan: {4}, hidden: {5}, readOnly: {6}, x: {7}, y: {8}, width: {9}, editable: false, trigger1Cls: 'x-form-clear-trigger', onTrigger1Click: function () {{ this.clearValue(); }}, queryMode: 'local', valueField: 'code', displayField: 'name', listFields: 'code,name', listHeadTexts: '代码,名称', data:[ ", "ngComboBox", controlBase.FieldLabel, controlBase.Name, controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan, controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos, controlBase.Width); NGCommonHelp commonHelp = controlBase as NGCommonHelp; for (int i = 0; i < commonHelp.Data.Count; i++) { sb += "\t\t\t\t\t\t\t\t{" + commonHelp.Data[i] + "}"; if (i == commonHelp.Data.Count - 1) { sb += "\r\n"; } else { sb += ",\r\n"; } } } sb += "\t\t\t\t\t\t\t]\r\n\t\t\t\t\t\t"; return(sb); }
public IList <ExtControlInfoBase> GetIndividualQueryPanel(string pageId, string ocode, string logid) { #region 获取控件 DataTable dt = queryPanelDac.GetIndividualQueryPanelInfo(pageId, ocode, logid); IList <ExtControlInfoBase> list = new List <ExtControlInfoBase>(); if (dt.Rows.Count == 0) { return(list);//无内嵌查询 } #region 缓存处理 string cachedKey = new StringBuilder().Append(CACHEDID).Append("_") .Append(ocode).Append("_").Append(logid).Append("_").Append(pageId).ToString(); string cachedTimeKey = cachedKey + "time";//时间戳缓存键 string localTimeStamp = HttpRuntime.Cache.Get(cachedTimeKey) as String; string cachedSrvTimeStamp = NG.Cache.Client.CacheClient.Instance.GetData(MAINKEY, cachedTimeKey) as String; if (localTimeStamp == cachedSrvTimeStamp)//本地时间戳与缓存服务器的时间戳比对 { IList <ExtControlInfoBase> cachedList = HttpRuntime.Cache.Get(cachedKey) as IList <ExtControlInfoBase>; if (cachedList != null) { return(cachedList); } } #endregion //获取内嵌查询多语言键值对 Dictionary <string, string> langDic = SUP.Common.DataAccess.LangInfo.GetLabelLang(pageId); string tables = GetTableNames(dt); DataTable PropertyDt = queryPanelDac.GetPropertyDt(tables); RichHelpDac richHelpDac = new RichHelpDac(); foreach (DataRow dr in dt.Rows) { ExtControlInfoBase col = new ExtControlInfoBase(); string searchetable = dr["searchtable"].ToString(); string searchfield = dr["searchfield"].ToString(); string fieldname = dr["searchfield"].ToString(); string langkey = dr["langkey"].ToString();;//全部 fieldname = GetPropertyName(PropertyDt, searchetable, searchfield, fieldname); //处理itemId string itemId = fieldname; fieldname = DealDataType(dr, fieldname); fieldname = DealOperation(dr, fieldname); fieldname += "*" + dr["isaddtowhere"].ToString();//是否直接参与查询 string label = dr["fname_chn"].ToString();//标签名 if (langDic.ContainsKey(langkey) && !string.IsNullOrEmpty(langDic[langkey])) { label = langDic[langkey];//取多语言 } string xtype = string.Empty; string displayfield = ""; string valuefield = ""; string namefield = ""; string codefield = ""; string usercodefield = string.Empty; //用户编码 string usercodePro = string.Empty; //用户编码对应的属性名 switch (dr["controltype"].ToString()) { case "TextBox": xtype = "ngText"; break; case "CompositeTextBox": xtype = "ngRichHelp"; NGRichHelp richhelp = new NGRichHelp(); richhelp.helpid = dr["controlflag"].ToString(); richhelp.xtype = xtype; richhelp.name = fieldname; richhelp.itemId = itemId; richhelp.fieldLabel = label; richhelp.matchFieldWidth = false; //if (dr["matchfieldwidth"] != null && dr["matchfieldwidth"] != DBNull.Value) //{ // if (dr["matchfieldwidth"].ToString() == "0") // { // richhelp.matchFieldWidth = false; // } //} //else //{ // richhelp.matchFieldWidth = false;//为空也设置为false //} richhelp.showAutoHeader = false; if (!string.IsNullOrEmpty(richhelp.helpid)) { SUP.Common.DataEntity.CommonHelpEntity helpEntity = richHelpDac.GetCommonHelpItem(richhelp.helpid); namefield = helpEntity.NameField; codefield = helpEntity.CodeField; codefield = this.DeleteTableName(codefield); namefield = this.DeleteTableName(namefield); usercodefield = helpEntity.UserCodeField; string tablename = helpEntity.TableName; displayfield = helpEntity.NameProperty; valuefield = helpEntity.CodeProperty; usercodefield = this.DeleteTableName(usercodefield); valuefield = this.DeleteTableName(valuefield); displayfield = this.DeleteTableName(displayfield); if (string.IsNullOrWhiteSpace(usercodefield)) { usercodefield = codefield; } else { usercodePro = helpEntity.UserCodeProperty; } if (string.IsNullOrEmpty(displayfield) && string.IsNullOrEmpty(valuefield)) { richhelp.displayField = namefield; richhelp.valueField = codefield; richhelp.usercodeField = usercodefield; richhelp.ORMMode = false;//richhelp这个必须为false } else { if (tablename.IndexOf(",") > 0 || tablename.IndexOf("=") > 0) //表名有多表关联,属性无法正确获取,不走orm { richhelp.ORMMode = false; //richhelp这个必须为false } richhelp.displayField = displayfield; richhelp.valueField = valuefield; richhelp.usercodeField = usercodePro; } } richhelp.listFields = richhelp.usercodeField + "," + richhelp.displayField + "," + richhelp.valueField; richhelp.value = dr["defaultdata"].ToString(); richhelp.listHeadTexts = "代码,名称"; richhelp.clientSqlFilter = dr["sqlfilter"].ToString(); //sql过滤条件 list.Add(richhelp); continue; case "NGCustomFormHelp": xtype = "ngCustomFormHelp"; NGCustomFormHelp customhelp = new NGCustomFormHelp(); //自定义表单的帮助 customhelp.helpid = dr["controlflag"].ToString(); customhelp.xtype = xtype; customhelp.name = fieldname; customhelp.itemId = itemId; customhelp.fieldLabel = label; customhelp.showAutoHeader = false; if (!string.IsNullOrEmpty(customhelp.helpid)) { SUP.CustomForm.DataAccess.HelpDac customdac = new CustomForm.DataAccess.HelpDac(); SUP.CustomForm.DataEntity.HelpEntity helpEntity = customdac.GetCustomFormHelpItem(customhelp.helpid); namefield = helpEntity.NameField; codefield = helpEntity.CodeField; if (codefield.IndexOf(".") > 0) { codefield = codefield.Split('.')[1]; // } if (namefield.IndexOf(".") > 0) { namefield = namefield.Split('.')[1]; } usercodefield = helpEntity.NoField; customhelp.displayField = namefield; customhelp.valueField = codefield; customhelp.usercodeField = usercodefield; customhelp.ORMMode = false; } customhelp.listFields = customhelp.usercodeField + "," + customhelp.displayField + "," + customhelp.valueField; customhelp.value = dr["defaultdata"].ToString(); customhelp.listHeadTexts = "代码,名称"; customhelp.clientSqlFilter = dr["sqlfilter"].ToString(); //sql过滤条件 list.Add(customhelp); continue; case "DateBox": xtype = "ngDate"; break; case "DateTimeBox": xtype = "ngDateTime"; break; case "DropDownList": xtype = "ngComboBox"; NGComboBox combo = new NGComboBox(); combo.helpid = dr["controlflag"].ToString(); if (dr["matchfieldwidth"] != null && dr["matchfieldwidth"] != DBNull.Value) { if (dr["matchfieldwidth"].ToString() == "0") { combo.matchFieldWidth = false; } } if (!string.IsNullOrEmpty(combo.helpid)) { SUP.Common.DataEntity.CommonHelpEntity helpEntity = richHelpDac.GetCommonHelpItem(combo.helpid); combo.queryMode = "remote"; namefield = helpEntity.NameField; codefield = helpEntity.CodeField; usercodefield = helpEntity.UserCodeField; codefield = this.DeleteTableName(codefield); namefield = this.DeleteTableName(namefield); string tablename = helpEntity.TableName; displayfield = helpEntity.NameProperty; valuefield = helpEntity.CodeProperty; if (string.IsNullOrWhiteSpace(usercodefield)) { usercodefield = codefield; } else { usercodePro = helpEntity.UserCodeProperty; } if (string.IsNullOrEmpty(displayfield) && string.IsNullOrEmpty(valuefield)) { combo.displayField = namefield; combo.valueField = codefield; combo.usercodeField = usercodefield; combo.ORMMode = false;//richhelp这个必须为false } else { if (tablename.IndexOf(",") > 0 || tablename.IndexOf("=") > 0) //表名有多表关联,属性无法正确获取,不走orm { combo.ORMMode = false; //richhelp这个必须为false } combo.displayField = displayfield; combo.valueField = valuefield; combo.usercodeField = usercodePro; } if (namefield == codefield) //不相等出两列 { combo.listFields = combo.displayField; combo.listHeadTexts = "名称"; } else { combo.listFields = combo.usercodeField + "," + combo.displayField + "," + combo.valueField; combo.listHeadTexts = "编码,名称"; } } else { if (string.IsNullOrWhiteSpace(dr["datasource"].ToString())) { throw new Exception(string.Format("内嵌查询字段【{0}】类型为下拉,但未配置数据源!", itemId)); } combo.data = ColumnInfoBuilder.TranslateData(dr["datasource"].ToString(), '|', ':'); combo.queryMode = "local"; } combo.xtype = xtype; combo.name = fieldname; combo.itemId = itemId; combo.fieldLabel = label; combo.value = dr["defaultdata"].ToString(); combo.clientSqlFilter = dr["sqlfilter"].ToString(); //sql过滤条件 list.Add(combo); continue; case "CheckBoxList": xtype = "ngCheckbox"; break; case "AutoCompleteWithCommonHelpControl": xtype = "ngCommonHelp"; namefield = dr["namefield"].ToString(); codefield = dr["codefield"].ToString(); NGCommonHelp commonHelp = new NGCommonHelp(); commonHelp.helpid = dr["controlflag"].ToString(); displayfield = DataConverterHelper.FieldToProperty(dr["tablename"].ToString(), namefield); valuefield = DataConverterHelper.FieldToProperty(dr["tablename"].ToString(), codefield); if (string.IsNullOrEmpty(codefield) && string.IsNullOrEmpty(namefield)) //从xml取数 { DataEntity.CommonHelpEntity item = new CommonHelpDac().GetHelpItem(commonHelp.helpid); commonHelp.displayField = item.NameField; commonHelp.valueField = item.CodeField; } else if (string.IsNullOrEmpty(dr["modelname"].ToString()) && string.IsNullOrEmpty(displayfield) && string.IsNullOrEmpty(valuefield)) { commonHelp.displayField = namefield; commonHelp.valueField = codefield; } else { commonHelp.displayField = dr["modelname"].ToString() + '.' + displayfield; commonHelp.valueField = dr["modelname"].ToString() + '.' + valuefield; } commonHelp.xtype = xtype; commonHelp.fieldLabel = label; commonHelp.name = fieldname; list.Add(commonHelp); continue; case "ngOrgHelp": xtype = "ngOrgHelp"; //组织组件 break; case "ngProjectHelp": xtype = "ngProjectHelp"; //项目组件 break; case "ngCustomFileHelp": xtype = "ngCustomFileHelp"; //客户 break; case "ngSupplyFileHelp": xtype = "ngSupplyFileHelp"; //供应商 break; case "ngEnterpriseHelp": xtype = "ngEnterpriseHelp"; //往来单位 break; case "ngEmpHelp": xtype = "ngEmpHelp"; //员工 break; case "WbsHelpField": xtype = "WbsHelpField"; //wbs break; case "ItemDataHelpField": xtype = "ItemDataHelpField"; //物料帮助 break; case "CntInfoHelpField": xtype = "CntInfoHelpField"; //合同帮助 break; //增加numberfield控件 case "numberfield": xtype = "numberfield"; //数字控件 break; default: xtype = "ngText"; break; } col = IndividualInfoFactory.GetControlInfo(xtype, fieldname, label, string.Empty, 100, 2);//内嵌查询最大长度100,2位小数 col.value = dr["defaultdata"].ToString(); list.Add(col); } #region 缓存处理 //缓存起来 HttpRuntime.Cache.Remove(cachedKey);//先remove HttpRuntime.Cache.Add(cachedKey, list, null, DateTime.Now.AddDays(1), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); string time = DateTime.Now.ToString("yyyyMMddhhmmss"); //时间戳本地缓存 HttpRuntime.Cache.Remove(cachedTimeKey);//先remove HttpRuntime.Cache.Add(cachedTimeKey, time, null, DateTime.Now.AddDays(1), Cache.NoSlidingExpiration, CacheItemPriority.NotRemovable, null); NG.Cache.Client.CacheClient.Instance.Add(MAINKEY, cachedTimeKey, time);//外部缓存存放时间戳 #endregion return(list); #endregion }
public static ExtControlInfoBase GetControlInfo(string xtype, string name, string label, string fieldtype, int length, int declen) { ExtControlInfoBase control = null; switch (xtype) { case "ngText": NGText text = new NGText(); text.maxLength = length; control = text; break; case "ngTextArea": NGTextArea ctl = new NGTextArea(); ctl.maxLength = length; control = ctl; break; case "ngDate": control = new NGDate(); break; case "ngDateTime": control = new NGDateTime(); break; case "ngNumber": control = GetNumberCtl(fieldtype, length, declen, false); break; case "ngPercent": control = GetNumberCtl(fieldtype, length, declen, true); break; case "ngComboBox": control = new NGComboBox(); break; case "ngCommonHelp": control = new NGCommonHelp(); break; case "ngRichHelp": control = new NGRichHelp(); break; case "ngRadio": control = new NGComboBox(); break; case "ngCheckbox": control = new NGCheckbox(); break; default: control = new NGText(); break; } if (xtype == "ngPercent") { control.xtype = "ngNumber"; } else { control.xtype = xtype; } control.name = name; if (name.IndexOf("*") > 0) { control.itemId = name.Split('*')[0]; } else { control.itemId = name; } control.fieldLabel = label; return(control); }
public static List <ExtGridColumn> GetListColumns(IList <PbBaseTextInfo> pbcontrols) { SortedList <int, PbBaseControlInfo> list = new SortedList <int, PbBaseControlInfo>(); List <ExtGridColumn> columns = new List <ExtGridColumn>(); foreach (PbBaseControlInfo item in pbcontrols) { if (list.ContainsKey(item.XPos)) //如果x坐标重复,则跳过 //0000000038 这里有重复的 { continue; } list.Add(item.XPos, item);//以x坐标排序 } foreach (KeyValuePair <int, PbBaseControlInfo> element in list) { PbBaseTextInfo textInfo = element.Value as PbBaseTextInfo; if (textInfo != null) { ExtGridColumn col = new ExtGridColumn(); if (textInfo.Name.Equals("t_sum")) { continue; } col.Header = textInfo.LeftText; col.DataIndex = textInfo.Name; col.Datatype = SqlTypeConverter.ConvertToExtControl(textInfo.ColumnInfo.ColumnDataType); col.DefaultValue = textInfo.DefaultValue; col.Width = textInfo.Width; //Grid每一列的宽度 col.RgbColor = ControlConverter.GetRgb(textInfo.Color); //grid列的字体颜色 col.BackgroundColor = ControlConverter.GetRgb(textInfo.backgroundColor); //grid列的背景颜色 ExtControlBase column = ControlConverter.ConvertToExtControl(textInfo); //转换下xtype的类型; col.Protect = column.Protect; col.MustInput = column.MustInput; col.Format = column.Format; col.EditMask = column.EditMask; col.editor.XType = column.XType; if (col.editor.XType == "ngCustomFormHelp" || col.editor.XType == "ngRichHelp") { var temp = column as NGHelpBase; if (temp.Helpid == "itemdata") { col.DataIndex = "itemid"; col.Header = "物资"; col.editor.ValueField = "phid"; col.editor.DisplayField = "itemname"; col.editor.ListFields = "itemid,c_name,spec,msname"; col.editor.ListHeadTexts = "编码,名称,规格,单位"; col.editor.Helpid = temp.Helpid; } else { col.editor.ValueField = temp.ValueField; col.editor.DisplayField = temp.DisplayField; col.editor.ListFields = temp.ListFields; col.editor.ListHeadTexts = temp.ListHeadTexts; col.editor.CmpName = temp.CmpName; col.editor.OutFilter = temp.OutFilter; col.editor.Helpid = temp.Helpid; col.editor.MultiSelect = temp.MultiSelect; } } else if (col.editor.XType == "ngComboBox") { if (column is NGComboBox) { NGComboBox temp = column as NGComboBox; col.editor.QueryMode = temp.QueryMode; col.editor.Data = temp.Data; } else if (column is NGCommonHelp) { NGCommonHelp temp = column as NGCommonHelp; col.editor.QueryMode = temp.QueryMode; col.editor.Data = temp.Data; } } else if (col.editor.XType == "ngRadio") { var temp = column as NGRadio; col.editor.Items = temp.Items; } columns.Add(col); } } return(columns); }