Beispiel #1
0
        //form列获取
        public string GetngCustomFormHelp(ExtControlBase controlBase)
        {
            NGCommonHelp commonHelp = new NGCommonHelp();

            commonHelp = controlBase as NGCommonHelp;

            string colXtype = commonHelp.XType;

            //是多选帮助
            if (commonHelp.MultiSelect)
            {
                colXtype = "ngCustFormMutilHelp";
            }

            sb = string.Format(@"
                    xtype: '{0}', 
                    fieldLabel: Lang.{2}||'{1}', 
                    name: '{3}', 
                    id: '{3}',
                    itemId: '{3}', 
                    mustInput: {4},
                    colspan: {5},
                    valueField: '{6}',
                    displayField: '{7}',
                    listFields: '{8}',
                    listHeadTexts: '{9}',
                    helpid: '{10}',
                    hidden: {11},
                    readOnly: {12},
                    x: {13},
                    y: {14},
                    width: {15},
                    value: '{16}',
                    fieldStyle:'color:{17}',
                    labelStyle:'color:{18}'
                 ", colXtype, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name,
                               controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan,
                               commonHelp.ValueField, commonHelp.DisplayField, commonHelp.ListFields,
                               commonHelp.ListHeadTexts, commonHelp.Helpid, controlBase.Visible.Equals(true) ? "false" : "true",
                               controlBase.Protect.Equals(true) ? "true" : "false", controlBase.XPos, controlBase.YPos,
                               controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle);
            return(sb);
        }
Beispiel #2
0
        public static NGCommonHelp GetRichHelp(PbBaseControlInfo pbCtl, DataRow dr)
        {
            PbDataHelpEditInfo pbDataHelp = (PbDataHelpEditInfo)pbCtl;
            NGCommonHelp       ngRichHelp = new NGCommonHelp();

            string xtypeStr = string.Empty;

            DataRow[] xmlDrs = HelpDac.XmlHelpDT.Select("Id='" + pbDataHelp.Name + "'");
            if (xmlDrs.Length > 0)
            {
                xtypeStr = xmlDrs[0]["xtype"].ToString().Trim();

                if (xtypeStr == "WbsHelpField" || xtypeStr == "CbsHelpField")
                {
                    ngRichHelp.OutFilter = "pc";
                }
            }

            //组件类型名不为空,说明是组件,组件ValueField等从xml文件取
            if (!string.IsNullOrEmpty(xtypeStr))
            {
                ngRichHelp.ValueField   = xmlDrs[0]["Code"].ToString();
                ngRichHelp.DisplayField = xmlDrs[0]["Name"].ToString();
            }
            else
            {
                //project_table.phid,如果带表名则去掉表名
                var codefield = dr["codefield"].ToString().Trim();
                var namefield = dr["namefield"].ToString().Trim();

                if (codefield.IndexOf(".") > 0)
                {
                    codefield = codefield.Substring(codefield.IndexOf(".") + 1).Trim();
                }
                if (namefield.IndexOf(".") > 0)
                {
                    namefield = namefield.Substring(namefield.IndexOf(".") + 1).Trim();
                }

                ngRichHelp.ValueField   = codefield;
                ngRichHelp.DisplayField = namefield;
            }

            ngRichHelp.ID            = pbDataHelp.Id;
            ngRichHelp.Name          = pbDataHelp.Name;
            ngRichHelp.FieldLabel    = pbDataHelp.LeftText;
            ngRichHelp.MustInput     = pbDataHelp.IsMustInput;
            ngRichHelp.XType         = "ngRichHelp";
            ngRichHelp.CmpName       = xtypeStr;
            ngRichHelp.Visible       = pbDataHelp.Visible;
            ngRichHelp.MustInput     = pbDataHelp.IsMustInput;
            ngRichHelp.Protect       = pbDataHelp.IsProtect;
            ngRichHelp.Helpid        = dr["helpid"].ToString();
            ngRichHelp.ListFields    = ngRichHelp.ValueField + "," + ngRichHelp.DisplayField;
            ngRichHelp.ListHeadTexts = "代码,名称";
            ngRichHelp.MultiSelect   = pbDataHelp.MultiSelect;
            ngRichHelp.FieldStyle    = GetRgb(pbDataHelp.TextColor);
            ngRichHelp.LabelStyle    = GetRgb(pbDataHelp.LabelTextColor);

            return(ngRichHelp);
        }
Beispiel #3
0
        public static NGCommonHelp GetCustomFormHelp(PbBaseControlInfo pbCtl)
        {
            PbDataHelpEditInfo pbDataHelp       = (PbDataHelpEditInfo)pbCtl;
            NGCommonHelp       ngCustomFormHelp = new NGCommonHelp();

            ngCustomFormHelp.ID          = pbDataHelp.Id;
            ngCustomFormHelp.Name        = pbDataHelp.Name;
            ngCustomFormHelp.FieldLabel  = pbDataHelp.LeftText;
            ngCustomFormHelp.MustInput   = pbDataHelp.IsMustInput;
            ngCustomFormHelp.XType       = "ngCustomFormHelp";
            ngCustomFormHelp.Visible     = pbDataHelp.Visible;
            ngCustomFormHelp.MustInput   = pbDataHelp.IsMustInput;
            ngCustomFormHelp.Protect     = pbDataHelp.IsProtect;
            ngCustomFormHelp.Helpid      = pbDataHelp.DataHelpId;
            ngCustomFormHelp.OutFilter   = "";
            ngCustomFormHelp.MultiSelect = pbDataHelp.MultiSelect;
            ngCustomFormHelp.FieldStyle  = GetRgb(pbDataHelp.TextColor);
            ngCustomFormHelp.LabelStyle  = GetRgb(pbDataHelp.LabelTextColor);

            //查帮助信息
            DataTable dt = SUP.CustomForm.DataAccess.Common.GetHelpInfo(ngCustomFormHelp.Helpid);

            //这时候需要去数据库查 helpid
            if (dt != null && dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["fromsql"].Equals("1")) //弹出帮助类型的
                {
                    ngCustomFormHelp.ValueField    = dt.Rows[0]["col_data"].ToString();
                    ngCustomFormHelp.DisplayField  = dt.Rows[0]["col_view"].ToString();
                    ngCustomFormHelp.ListFields    = dt.Rows[0]["col_data"].ToString() + "," + dt.Rows[0]["col_view"].ToString();
                    ngCustomFormHelp.ListHeadTexts = dt.Rows[0]["datetitle"].ToString() + "," + dt.Rows[0]["viewtitle"].ToString();
                }
                else
                {
                    //下拉式两列的帮助
                    ngCustomFormHelp.XType         = "ngComboBox";
                    ngCustomFormHelp.QueryMode     = "local";
                    ngCustomFormHelp.ValueField    = "code";
                    ngCustomFormHelp.DisplayField  = "name";
                    ngCustomFormHelp.ListFields    = "code,name";
                    ngCustomFormHelp.ListHeadTexts = "代码,名称";

                    foreach (DataRow info in dt.Rows)
                    {
                        ngCustomFormHelp.Data.Add(string.Format(@"code:'{0}',name:'{1}'", info["phid"].ToString(), info["base_name"].ToString()));
                    }
                }

                //--设置sql中的过滤填充值
                string sql       = dt.Rows[0]["sql_str"].ToString() + " ";
                string outfilter = string.Empty;

                //得到sql中:和空格之间的串
                string          start      = @"\:";
                string          end        = @"\ ";
                Regex           rg         = new Regex("(?<=(" + start + "))[.\\s\\S]*?(?=(" + end + "))", RegexOptions.Multiline | RegexOptions.Singleline);
                MatchCollection macths     = rg.Matches(sql);
                int             bracketPos = 0;
                string          tempValue  = string.Empty;

                if (macths.Count > 0)
                {
                    for (int i = 0; i < macths.Count; i++)
                    {
                        tempValue = macths[i].Value;

                        //去掉可能存在的小括号符
                        do
                        {
                            tempValue  = tempValue.Replace(")", " ");
                            bracketPos = tempValue.IndexOf(")");
                        } while (bracketPos != (-1));

                        outfilter += ";" + tempValue.Trim();
                    }

                    outfilter = outfilter.Substring(1, outfilter.Length - 1);  //去掉第一个多余的分号
                    ngCustomFormHelp.OutFilter = outfilter;
                }
                //--end
            }
            else
            {
                ngCustomFormHelp.ValueField    = "code";
                ngCustomFormHelp.DisplayField  = "name";
                ngCustomFormHelp.ListFields    = "code,name";
                ngCustomFormHelp.ListHeadTexts = "代码,名称";
            }

            return(ngCustomFormHelp);
        }
Beispiel #4
0
        public string GetngRichHelp(ExtControlBase controlBase)
        {
            NGCommonHelp richHelp = new NGCommonHelp();

            richHelp = controlBase as NGCommonHelp;

            //是组件类型
            if (!string.IsNullOrEmpty(richHelp.CmpName))
            {
                string isValidate = "false";
                if (richHelp.CmpName == "WbsHelpField" || richHelp.CmpName == "CbsHelpField")
                {
                    isValidate = "true";
                }

                sb = string.Format(@"
                    xtype: '{0}', 
                    fieldLabel: Lang.{2}||'{1}', 
                    name: '{3}', 
                    id: '{3}',
                    itemId: '{3}',
                    mustInput: {4},
                    colspan: {5},
                    //helpid: '{6}',
                    ORMMode: {7},
                    hidden: {8},
                    readOnly: {9},
                    x: {10},
                    y: {11},
                    width: {12},
                    value: '{13}',
                    fieldStyle: 'color:{14};',
                    labelStyle: 'color:{15}',
                    acceptInput: {16}
                 ", richHelp.CmpName, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name,
                                   controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan,
                                   richHelp.Helpid, "true", controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false",
                                   controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle, isValidate);
            }
            else
            {
                string colXtype = richHelp.XType;

                //是多选帮助
                if (richHelp.MultiSelect)
                {
                    colXtype = "ngMultiRichHelp";
                }

                sb = string.Format(@"
                    xtype: '{0}', 
                    fieldLabel: Lang.{2}||'{1}', 
                    name: '{3}', 
                    id: '{3}',
                    itemId: '{3}',
                    mustInput: {4},
                    colspan: {5},
                    valueField: '{6}',
                    displayField: '{7}',
                    listFields: '{8}',
                    listHeadTexts: '{9}',
                    helpid: '{10}',
                    ORMMode: {11},
                    hidden: {12},
                    readOnly: {13},
                    x: {14},
                    y: {15},
                    width: {16},
                    value: '{17}',
                    fieldStyle:'color:{18}',
                    labelStyle:'color:{19}'
                 ", colXtype, controlBase.FieldLabel, FormTableName + "_" + controlBase.Name, controlBase.Name,
                                   controlBase.MustInput.Equals(true) && controlBase.Visible.Equals(true) ? "true" : "false", controlBase.ColSpan,
                                   richHelp.ValueField, richHelp.DisplayField, richHelp.ListFields, richHelp.ListHeadTexts, richHelp.Helpid,
                                   "false", controlBase.Visible.Equals(true) ? "false" : "true", controlBase.Protect.Equals(true) ? "true" : "false",
                                   controlBase.XPos, controlBase.YPos, controlBase.Width, controlBase.DefaultValue, controlBase.FieldStyle, controlBase.LabelStyle);
            }

            return(sb);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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
        }
Beispiel #8
0
        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);
        }