Beispiel #1
0
        private static DwDbColumn ParseDwDbColumn(string dbColumnStr)
        {
            DwDbColumn dwDbColumn = new DwDbColumn();

            try
            {
                string columnString = dbColumnStr.Trim();
                columnString = columnString.Remove(0, DwRes.DbColumnSectionStart.Length);
                columnString = columnString.Remove(columnString.Length - 1, 1);
                columnString = columnString.Trim();
                string[] stringArray = columnString.Split(' ');
                foreach (string str in stringArray)
                {
                    string[] stringChildArray = str.Split('=');
                    Debug.Assert(stringChildArray.Length == 2);
                    switch (stringChildArray[0])
                    {
                    case "type":
                        dwDbColumn.DataType = stringChildArray[1];
                        break;

                    case "name":
                        dwDbColumn.Name = stringChildArray[1];
                        break;

                    case "dbname":
                        dwDbColumn.DbName = RemoveQuotes(stringChildArray[1]);
                        break;

                    case "values":
                        dwDbColumn.Values = RemoveQuotes(stringChildArray[1]);
                        break;

                    default:
                        break;
                    }
                }

                return(dwDbColumn);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #2
0
        //ParseBillHead 调用
        public static IList <PbBaseTextInfo> ToPbColumnsMetadata(DwInfo dwInfo, string dwAuthName, IDictionary <string, string> dddwSourceDic, string titlename,
                                                                 Dictionary <string, string> colrefdic, IDictionary <string, string> textareadic, IDictionary <string, string> colspandic, IDictionary <string, string> multiselectdic)
        {
            IList <PbBaseTextInfo> pbBaseTextInfos = new List <PbBaseTextInfo>();

            //普通列
            foreach (DwColumn dc in dwInfo.DwColumns)
            {
                //如果控件宽度或高度为0,该控件不加入列表
                if (dc.Height == 0 || dc.Width == 0)
                {
                    continue;
                }

                DwDbColumn dwDbColumn = dwInfo.GetDwDbColumnByName(dc.Name);

                if (dwDbColumn == null)
                {
                    continue;
                }

                //if (sumdic != null && sumdic.Count() != 0)
                //{
                //    if (sumdic.ContainsKey(dc.Name))
                //    {
                //        dwDbColumn.SummaryType = sumdic[dc.Name];
                //    }
                //}

                DwText dwText = dwInfo.GetDwTextByName(dc.Name);

                //xkq. 2016-12-8 寻找[window]中ref中是否有对应text
                if (colrefdic != null && colrefdic.Count() != 0)
                {
                    if (dwText == null || dwText.Name == null)
                    {
                        if (colrefdic.ContainsKey(dc.Name))  //有关联的标签和输入框
                        {
                            string textname = colrefdic[dc.Name];
                            if (!string.IsNullOrEmpty(textname))
                            {
                                dwText = dwInfo.GetDwTextByName1(textname);
                            }
                        }
                        else  //单独的标签
                        {
                            dc.SingleText = true;
                        }
                    }
                }

                //add by ljy 2017.07.13 找出类型时textarea的字段
                if (textareadic != null && textareadic.Count() != 0)
                {
                    if (textareadic.ContainsKey(dc.Name))
                    {
                        dc.TextArea = true;
                    }
                }

                //add by ljy 2017.07.14 设置所有列的列占位数
                if (colspandic != null && colspandic.Count() != 0)
                {
                    if (colspandic.ContainsKey(dc.Name))  //有关联的标签和输入框
                    {
                        dc.ColSpan = Convert.ToInt32(colspandic[dc.Name]);
                    }
                }

                //add by ljy 2017.11.03 找出复选帮助字段
                if (multiselectdic != null && multiselectdic.Count() != 0)
                {
                    if (multiselectdic.ContainsKey(dwAuthName + "." + dc.Name))
                    {
                        dc.MultiSelect = true;
                    }
                }

                if (dc.Name.Equals("res_code"))
                {
                    dwDbColumn.DataType = "DataHelpEdit";
                    PbDataHelpEditInfo pbDataHelpEditInfo = new PbDataHelpEditInfo();
                    CommonAssignment(pbDataHelpEditInfo, dwDbColumn, dwText, dc, SqlDbType.NVarChar, dwAuthName);
                    DataRow[] drs = HelpDac.XmlHelpDT.Select("Id='" + pbDataHelpEditInfo.Name + "'");
                    if (drs.Length > 0)//系统内置的通用帮助
                    {
                        pbDataHelpEditInfo.DataHelpId = drs[0]["HelpId"].ToString();
                    }
                    pbBaseTextInfos.Add(pbDataHelpEditInfo);
                    continue;
                }

                if (dc.Name.Equals("c_name"))
                {
                    continue;
                }

                //if(dc.Name.Equals("msunit"))
                //{
                //    sqlDbType = SqlDbType.NVarChar;
                //    dc.ControlType = DwControlType.TextEdit;
                //}

                SqlDbType sqlDbType = DwDbTypeConvert.ToSqlDbType(dwDbColumn.DataType);

                switch (sqlDbType)
                {
                case SqlDbType.NVarChar:
                    switch (dc.ControlType)
                    {
                    case DwControlType.CheckBoxEdit:
                        PbCheckboxInfo checkboxInfo = new PbCheckboxInfo();
                        CommonAssignment(checkboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(checkboxInfo);
                        break;

                    case DwControlType.RedioBoxEdit:
                        PbRadioboxInfo pbRadioboxInfo = new PbRadioboxInfo();
                        CommonAssignment(pbRadioboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbRadioboxInfo.PbPairValueInfos = ConvertToPairValueInfo(dwDbColumn.Values);
                        pbBaseTextInfos.Add(pbRadioboxInfo);
                        break;

                    case DwControlType.ComboBoxEdit:
                        PbComboboxInfo pbComboboxInfo = new PbComboboxInfo();
                        CommonAssignment(pbComboboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbComboboxInfo.PbComboboxValueInfos = ConvertToPairValueInfo(dwDbColumn.Values);
                        pbBaseTextInfos.Add(pbComboboxInfo);
                        break;

                    case DwControlType.DataHelpEdit:
                        PbDataHelpEditInfo pbDataHelpEditInfo = new PbDataHelpEditInfo();
                        CommonAssignment(pbDataHelpEditInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        SetHelpId(pbDataHelpEditInfo, dddwSourceDic);          //设置helpid
                        pbBaseTextInfos.Add(pbDataHelpEditInfo);
                        break;

                    case DwControlType.RichTextEdit:
                        PbRichTextInfo pbRichTextInfo = new PbRichTextInfo();
                        CommonAssignment(pbRichTextInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(pbRichTextInfo);
                        break;

                    case DwControlType.TextEdit:
                        PbTextInfo textInfo = new PbTextInfo();
                        CommonAssignment(textInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(textInfo);
                        break;

                    default:
                        PbTextInfo textInfo1 = new PbTextInfo();
                        CommonAssignment(textInfo1, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(textInfo1);
                        break;
                    }
                    break;

                case SqlDbType.DateTime:
                    PbDateTimeTextInfo dateTimeTextInfo = new PbDateTimeTextInfo();
                    CommonAssignment(dateTimeTextInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                    pbBaseTextInfos.Add(dateTimeTextInfo);
                    break;

                case SqlDbType.Int:
                    switch (dc.ControlType)
                    {
                    case DwControlType.TextEdit:
                        PbIntTextInfo intTextInfo = new PbIntTextInfo();
                        CommonAssignment(intTextInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(intTextInfo);
                        break;

                    case DwControlType.CheckBoxEdit:
                        PbCheckboxInfo checkboxInfo = new PbCheckboxInfo();
                        CommonAssignment(checkboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(checkboxInfo);
                        break;

                    case DwControlType.RedioBoxEdit:
                        PbRadioboxInfo pbRadioboxInfo = new PbRadioboxInfo();
                        CommonAssignment(pbRadioboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(pbRadioboxInfo);
                        break;

                    case DwControlType.ComboBoxEdit:
                        PbComboboxInfo pbComboboxInfo = new PbComboboxInfo();
                        CommonAssignment(pbComboboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbComboboxInfo.PbComboboxValueInfos = ConvertToPairValueInfo(dwDbColumn.Values);
                        pbBaseTextInfos.Add(pbComboboxInfo);
                        break;

                    case DwControlType.DataHelpEdit:
                        PbDataHelpEditInfo pbDataHelpEditInfo = new PbDataHelpEditInfo();
                        CommonAssignment(pbDataHelpEditInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        SetHelpId(pbDataHelpEditInfo, dddwSourceDic);          //设置helpid
                        pbBaseTextInfos.Add(pbDataHelpEditInfo);
                        break;

                    case DwControlType.RichTextEdit:
                        PbRichTextInfo pbRichTextInfo = new PbRichTextInfo();
                        CommonAssignment(pbRichTextInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(pbRichTextInfo);
                        break;

                    default:
                        PbIntTextInfo intTextInfo1 = new PbIntTextInfo();
                        CommonAssignment(intTextInfo1, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(intTextInfo1);
                        break;
                    }
                    break;

                case SqlDbType.Decimal:
                    switch (dc.ControlType)
                    {
                    case DwControlType.CheckBoxEdit:
                        PbCheckboxInfo checkboxInfo = new PbCheckboxInfo();
                        CommonAssignment(checkboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(checkboxInfo);
                        break;

                    case DwControlType.RedioBoxEdit:
                        PbRadioboxInfo pbRadioboxInfo = new PbRadioboxInfo();
                        CommonAssignment(pbRadioboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbRadioboxInfo.PbPairValueInfos = ConvertToPairValueInfo(dwDbColumn.Values);
                        pbBaseTextInfos.Add(pbRadioboxInfo);
                        break;

                    case DwControlType.ComboBoxEdit:
                        PbComboboxInfo pbComboboxInfo = new PbComboboxInfo();
                        CommonAssignment(pbComboboxInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbComboboxInfo.PbComboboxValueInfos = ConvertToPairValueInfo(dwDbColumn.Values);
                        pbBaseTextInfos.Add(pbComboboxInfo);
                        break;

                    case DwControlType.DataHelpEdit:
                        PbDataHelpEditInfo pbDataHelpEditInfo = new PbDataHelpEditInfo();
                        CommonAssignment(pbDataHelpEditInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        SetHelpId(pbDataHelpEditInfo, dddwSourceDic);          //设置helpid
                        pbBaseTextInfos.Add(pbDataHelpEditInfo);
                        break;

                    case DwControlType.RichTextEdit:
                        PbRichTextInfo pbRichTextInfo = new PbRichTextInfo();
                        CommonAssignment(pbRichTextInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(pbRichTextInfo);
                        break;

                    case DwControlType.TextEdit:
                        PbTextInfo textInfo = new PbTextInfo();
                        CommonAssignment(textInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(textInfo);
                        break;

                    default:
                        PbDecimalTextInfo pbDecimalTextInfo = new PbDecimalTextInfo();
                        CommonAssignment(pbDecimalTextInfo, dwDbColumn, dwText, dc, sqlDbType, dwAuthName);
                        pbBaseTextInfos.Add(pbDecimalTextInfo);
                        break;
                    }
                    break;

                default:
                    break;
                }
            }

            //按钮列
            foreach (DwButton db in dwInfo.DwButtons)
            {
                //如果控件宽度或高度为0,该控件不加入列表
                if (db.Height == 0 || db.Width == 0)
                {
                    continue;
                }

                PbButtonInfo buttonInfo = new PbButtonInfo();

                buttonInfo.Name      = db.Name;
                buttonInfo.FullName  = db.Name;
                buttonInfo.LeftText  = db.Text;
                buttonInfo.Height    = db.Height;
                buttonInfo.Width     = db.Width;
                buttonInfo.TextColor = db.Color;
                buttonInfo.Visible   = db.Visible;

                buttonInfo.XPos       = db.XPos;
                buttonInfo.YPos       = db.YPos;
                buttonInfo.LabelWidth = db.Width;
                pbBaseTextInfos.Add(buttonInfo);
            }

            //纯文本列
            foreach (DwText dt in dwInfo.DwTexts)
            {
                bool isTitle = false;

                //如果控件宽度或高度为0,该控件不加入列表
                if (dt.Height == 0 || dt.Width == 0)
                {
                    continue;
                }

                //存在于列标签和列单元格的关联关系中,说明不是独立标签,是作为文本框的标签,则跳过
                if (colrefdic != null && colrefdic.ContainsValue(dt.Name))
                {
                    continue;
                }

                if (dt.Name.Equals(titlename) && !string.IsNullOrEmpty(titlename))
                {
                    isTitle = true;  //该标签作为标题
                }
                else
                {
                    //name最后两位不是"_t"的为独立标签
                    if (dt.Name.Substring(dt.Name.Length - 2, 2) == "_t")
                    {
                        continue;
                    }
                }

                PbLabelInfo labelInfo = new PbLabelInfo();

                //add by ljy 2018.05.21 设置所有列的列占位数
                if (colspandic != null && colspandic.Count() != 0)
                {
                    if (colspandic.ContainsKey(dt.Name))  //有关联的标签和输入框
                    {
                        labelInfo.ColSpan = Convert.ToInt32(colspandic[dt.Name]);
                    }
                }

                labelInfo.IsTitle        = isTitle;
                labelInfo.Name           = dt.Name;
                labelInfo.FullName       = dt.Name;
                labelInfo.LeftText       = dt.Text;
                labelInfo.Height         = dt.Height;
                labelInfo.Width          = dt.Width;
                labelInfo.TextColor      = dt.Color;
                labelInfo.LabelTextColor = dt.LabelTextColor;
                labelInfo.Visible        = dt.Visible;

                labelInfo.XPos = dt.XPos;
                labelInfo.YPos = dt.YPos;

                labelInfo.Font       = dt.Font;
                labelInfo.Align      = dt.Align;
                labelInfo.LabelWidth = dt.Width;

                pbBaseTextInfos.Add(labelInfo);
            }

            return(pbBaseTextInfos);
        }
Beispiel #3
0
        private static void CommonAssignment(PbBaseTextInfo baseTextInfo, DwDbColumn dwDbColumn, DwText dwText, DwColumn dc, SqlDbType dbType, string dwAuthName)
        {
            try
            {
                if (string.IsNullOrEmpty(dwAuthName))
                {
                    baseTextInfo.FullName = dc.Name;
                }
                else
                {
                    baseTextInfo.FullName = dwAuthName + "." + dc.Name;
                }

                baseTextInfo.Height    = dc.Height;
                baseTextInfo.MaxLength = dc.MaxLength;
                baseTextInfo.Name      = dc.Name;
                baseTextInfo.TextColor = dc.Color;

                baseTextInfo.Visible      = dc.Visible;
                baseTextInfo.DefaultValue = dc.DefaultValue;
                baseTextInfo.Tag          = dc.Tag;
                baseTextInfo.Format       = dc.Format;
                baseTextInfo.EditMask     = dc.EditMask;

                //赋上必输和保护
                baseTextInfo.IsMustInput = dc.Mustinput;
                baseTextInfo.IsProtect   = dc.Protect;

                baseTextInfo.SingleText  = dc.SingleText;  //是否为单独标签
                baseTextInfo.TextArea    = dc.TextArea;    //是否为多行文本框
                baseTextInfo.ColSpan     = dc.ColSpan;     //列占位数
                baseTextInfo.MultiSelect = dc.MultiSelect; //是否多选帮助
                baseTextInfo.YPos        = dc.YPos;

                baseTextInfo.Color           = dc.Color;           //设置grid某一列字体的颜色
                baseTextInfo.backgroundColor = dc.BackgroundColor; //设置grid某一列背景颜色

                //设置列的保护属性表达式
                if (dc.ProtectExp.Contains("if"))
                {
                    PbExpressionImp pbExpressionImp = new PbExpressionImp();
                    pbExpressionImp.Expression           = dc.ProtectExp;
                    pbExpressionImp.ExpressionType       = (PbExpressionType)17;
                    baseTextInfo.IsReadOnlyExpressionImp = pbExpressionImp;
                }

                if (dwText == null)
                {
                    baseTextInfo.LeftText   = string.Empty;
                    baseTextInfo.XPos       = dc.XPos;
                    baseTextInfo.Width      = dc.Width;
                    baseTextInfo.LabelWidth = dc.Width;
                }
                else
                {
                    baseTextInfo.LeftText       = dwText.Text;
                    baseTextInfo.XPos           = dwText.XPos;
                    baseTextInfo.LabelTextColor = dwText.LabelTextColor;
                    if (dc.ControlType == DwControlType.CheckBoxEdit && dc.XPos < dwText.XPos)//checkbox的情况要单独讨论,考虑到标签是在选择框的右边。
                    {
                        baseTextInfo.Width      = dwText.XPos + dwText.Width - dc.XPos;
                        baseTextInfo.LabelWidth = dwText.Width + dc.Width;
                    }
                    else
                    {
                        baseTextInfo.Width = dc.XPos - dwText.XPos + dc.Width;
                        if (dc.XPos == dwText.XPos)
                        {
                            baseTextInfo.LabelWidth = dc.Width;
                        }
                        else
                        {
                            baseTextInfo.LabelWidth = dc.XPos - dwText.XPos;
                        }
                    }
                }
                baseTextInfo.ColumnInfo.ColumnDataType = dbType;
                string[] arrayStr = dwDbColumn.DbName.Split('.');
                Debug.Assert(arrayStr.Length == 2);
                baseTextInfo.ColumnInfo.ColumnName = arrayStr[1];
                if (string.IsNullOrEmpty(dwAuthName))
                {
                    baseTextInfo.ColumnInfo.TableName = arrayStr[0];
                }
                else
                {
                    baseTextInfo.ColumnInfo.TableName = dwAuthName;
                }

                //if (!string.IsNullOrEmpty(dwDbColumn.SummaryType))
                //{
                //    switch (dwDbColumn.SummaryType)
                //    {
                //        case "avg":
                //            dwDbColumn.SummaryType = "average";
                //            break;
                //        case "count":
                //            dwDbColumn.SummaryType = "count";
                //            break;
                //        case "max":
                //            dwDbColumn.SummaryType = "max";
                //            break;
                //        case "min":
                //            dwDbColumn.SummaryType = "min";
                //            break;
                //        case "sum":
                //            dwDbColumn.SummaryType = "sum";
                //            break;
                //    }
                //    baseTextInfo.SummaryType = dwDbColumn.SummaryType;
                //}
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                throw;
            }
        }