Esempio n. 1
0
        public void InitXlsFields()
        {
            var resField = FindAll(x => x.IsActive &&
                                   ((x.Attr == attrName.Field) | (x.Attr == attrName.Myltiply) | ((x.Attr == attrName.System) && (x as FieldSystem).isField))
                                   ).OrderBy(x => x.Npp);

            ResTable           = new DataTable();
            ResTable.TableName = "ResTable";
            ResTable.Locale    = CultureInfo.InvariantCulture;
            foreach (FieldBase field in resField)
            {
                if (field.Attr == attrName.Field)
                {
                    ResTable.Columns.Add(field.ResName, field.Type);
                }
                else if ((field.Attr == attrName.Answer) & (field.ResName.IndexOf(".") > 0))
                {
                    ResTable.Columns.Add(field.ResName.Split('.')[1], typeof(string));
                }
                else if (field.Attr == attrName.Const)
                {
                    ResTable.Columns.Add(field.ResName, typeof(string));
                }
                else if (field.Attr == attrName.System)
                {
                    ResTable.Columns.Add(field.ResName, field.Type);
                }
                else if (field.Attr == attrName.Myltiply)
                {
                    FieldMultiply mField = (field as FieldMultiply);
                    ResTable.Columns.Add(mField.NameVal1, mField.Type);
                    ResTable.Columns.Add(mField.NameVal2, mField.Type2);
                }
            }
        }
Esempio n. 2
0
        //public void AddField(DataRow row,
        //    short npp, string resName,string xlsName,bool isPrint,
        //                    string type, short size, bool isPos,
        //                    attrName attr=0,bool isActive = true)

        public void AddField(DataRow row)
        {
            attrName attr    = (attrName)row["attr"];
            bool     isPrint = (bool)row["isPrint"];

            idHead = (int)row["idHead"];

            if (this.Count == 0)
            {
                printAllFields = false;
            }
            if ((row["resName"].ToString() == "*") && (attr == attrName.Const))
            {
                if ((row["xlsName"].ToString() == "*") && isPrint)
                {
                    printAllFields = true;
                }
                return;
            }

            FieldBase newField = null;

            switch (attr)
            {
            case attrName.Answer:
                newField = new FieldAnswer(row, this);
                break;

            case attrName.Const:
                newField = new FieldConst(row, this);
                break;

            case attrName.Expr:
                newField = new FieldExpr(row, this);
                break;

            case attrName.Func:
                newField = new FieldFunc(row, this);
                ((FieldFunc)newField).onInitProgressBar += this.onInitProgressBar;
                ((FieldFunc)newField).onStepProgressBar += this.onStepProgressBar;
                ((FieldFunc)newField).onHideProgressBar += this.onHideProgressBar;
                break;

            case attrName.System:
                newField = new FieldSystem(row, this);
                break;

            case attrName.Myltiply:
                newField = new FieldMultiply(row, this);
                break;

            default:
                newField = new FieldXls(row, this);
                break;
            }
            if (newField != null)
            {
                this.Add(newField);
            }
        }