Esempio n. 1
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;
            }
        }
Esempio n. 2
0
        private static DwColumn ParseDwColumn(string dwColumnStr, IDictionary <string, string> coldic)
        {
            DwColumn dwColumn = new DwColumn();

            try
            {
                string columnString = dwColumnStr.Trim();
                columnString = columnString.Remove(0, DwRes.ColumnSectionStart.Length);
                columnString = columnString.Remove(columnString.Length - 1, 1);
                columnString = columnString.Trim();

                //--替换非分隔用的空格为#号
                if (columnString.IndexOf("[general]", StringComparison.OrdinalIgnoreCase) < 0)  //说明有掩码值
                {
                    int posFormat = columnString.IndexOf("format=", StringComparison.OrdinalIgnoreCase);
                    int posQuot   = columnString.IndexOf("\"", posFormat + 8);
                    int posSpace  = columnString.IndexOf(" ", posFormat, posQuot);

                    //format值中有空格存在
                    if (posSpace > -1 && posSpace < posQuot)
                    {
                        columnString = columnString.Remove(posSpace, 1).Insert(posSpace, "#");
                    }
                }
                //--end

                string[] stringArray = columnString.Split(' ');
                int      step        = 1;

                for (int i = 0; i < stringArray.Length; i += step)
                {
                    string str = stringArray[i].Trim();

                    if (string.IsNullOrWhiteSpace(str))
                    {
                        continue;
                    }

                    string[] stringChildArray = str.Split('=');

                    if (stringChildArray.Length == 3)
                    {
                        stringChildArray[1] += "=" + stringChildArray[2];
                    }

                    if (stringChildArray.Length == 1)
                    {
                        step             = 2;
                        str              = stringArray[i] + " " + stringArray[i + 1];
                        stringChildArray = str.Split('=');
                    }
                    else if (stringChildArray.Length == 2 || stringChildArray.Length == 3)
                    {
                        step = 1;
                    }
                    else
                    {
                        continue;
                    }

                    Debug.Assert(stringChildArray.Length == 2);
                    switch (stringChildArray[0])
                    {
                    case "color":
                        dwColumn.Color = Convert.ToInt64(RemoveQuotes(stringChildArray[1]));
                        break;

                    case "name":
                        dwColumn.Name = stringChildArray[1];
                        if (coldic != null)
                        {
                            dwColumn.Mustinput = Convert.ToBoolean(Convert.ToInt32(coldic[dwColumn.Name]));
                        }
                        break;

                    case "visible":
                        dwColumn.Visible = Convert.ToBoolean(Convert.ToInt32(RemoveQuotes(stringChildArray[1])));
                        break;

                    case "protect":
                        //如:protect="1" 和 protect="0	1"
                        if (stringChildArray[1].Contains("1") && !stringChildArray[1].Contains("0"))
                        {
                            dwColumn.Protect = true;
                        }
                        else
                        {
                            dwColumn.Protect = false;
                        }

                        //protect="0	if( ddlbcol_1='9', 0, 1 )"
                        dwColumn.ProtectExp = stringChildArray[1];
                        break;

                    case "x":
                        dwColumn.XPos = Convert.ToInt32(RemoveQuotes(stringChildArray[1]));
                        break;

                    case "y":
                        dwColumn.YPos = Convert.ToInt32(RemoveQuotes(stringChildArray[1]));
                        break;

                    case "width":
                        dwColumn.Width = Convert.ToInt32(RemoveQuotes(stringChildArray[1]));
                        break;

                    case "height":
                        dwColumn.Height = Convert.ToInt32(RemoveQuotes(stringChildArray[1]));
                        break;

                    case "format":
                        stringChildArray[1] = stringChildArray[1].Replace("#", " ");
                        dwColumn.Format     = RemoveQuotes(stringChildArray[1]);
                        break;

                    case "tabsequence":
                        dwColumn.TabSequence = Convert.ToInt32(stringChildArray[1]);
                        break;

                    case "edit.limit":
                        dwColumn.MaxLength = Convert.ToInt32(stringChildArray[1]);
                        break;

                    case "tag":
                        dwColumn.Tag = RemoveQuotes(stringChildArray[1]);
                        break;

                    case "editmask.mask":
                        dwColumn.EditMask = RemoveQuotes(stringChildArray[1]);
                        dwColumn.EditMask = dwColumn.EditMask.Replace('#', '0');
                        break;

                    case "background.color":    //列的背景颜色268435456 1073741824
                        dwColumn.BackgroundColor = (Convert.ToInt64(RemoveQuotes(stringChildArray[1])) == 536870912 || Convert.ToInt64(RemoveQuotes(stringChildArray[1])) == 67108864 ||
                                                    Convert.ToInt64(RemoveQuotes(stringChildArray[1])) == 268435456 || Convert.ToInt64(RemoveQuotes(stringChildArray[1])) == 1073741824) ? 0: Convert.ToInt64(RemoveQuotes(stringChildArray[1]));
                        break;

                    case "":
                        break;

                    default:
                        break;
                    }

                    if (stringChildArray[0].StartsWith("radiobuttons", StringComparison.OrdinalIgnoreCase))
                    {
                        dwColumn.ControlType = DwControlType.RedioBoxEdit;
                    }
                    else if (stringChildArray[0].StartsWith("checkbox", StringComparison.OrdinalIgnoreCase))
                    {
                        dwColumn.ControlType = DwControlType.CheckBoxEdit;
                    }
                    else if (stringChildArray[0].StartsWith("ddlb", StringComparison.OrdinalIgnoreCase))
                    {
                        dwColumn.ControlType = DwControlType.ComboBoxEdit;
                    }
                    else if (stringChildArray[0].StartsWith("dddw", StringComparison.OrdinalIgnoreCase))
                    {
                        dwColumn.ControlType = DwControlType.DataHelpEdit;
                    }
                    else if (stringChildArray[0].StartsWith("richedit", StringComparison.OrdinalIgnoreCase))
                    {
                        dwColumn.ControlType = DwControlType.RichTextEdit;
                    }
                }

                return(dwColumn);
            }
            catch (Exception)
            {
                throw;
            }
        }