Esempio n. 1
0
//        public ParamGroup(string sqlParam, string tmplParam,

        public ParamGroup(string sqlParam, string tmplPatam,
                          GroupNames paramGroup, List <FieldBase> fields, FieldFunc ownField)
        {
            string[] sqlArray   = sqlParam.Split(')')[0].Split(new Char[] { ' ', ',' });
            string[] paramArray = tmplPatam.Split(new Char[] { ' ', ',', ')' });
            GroupName = paramGroup.ToString();

            for (int i = 0; i < sqlArray.Length; i++)
            {
                if (i >= paramArray.Length)
                {
                    msgError += String.Format(";missed param. {0}", sqlArray[i]);
                    if (GroupNames.outPar != paramGroup)
                    {
                        AllFound = false;
                    }
                    break;
                }

                string resName = paramArray[i];
                if (paramGroup == GroupNames.outPar)
                {
                    resName = String.Format("{0}.{1}", ownField.ResName, resName);
                }
                FieldBase field = fields.Find(x => (x.ResName == resName) & (x.Attr != attrName.Myltiply));
                if (field == null)
                {
                    var multyFiels = fields.FindAll(x => x.Attr == attrName.Myltiply);
                    field = multyFiels.Find(x => (x as FieldMultiply).NameVal1 == resName | (x as FieldMultiply).NameVal2 == resName);
                }
                bool isSystem = !paramArray[i].Any(Char.IsLower);
                if ((field == null) && !isSystem)
                {
                    msgError += String.Format(";missed field {0}", paramArray[i]);
                    if (GroupNames.outPar != paramGroup)
                    {
                        AllFound = false;
                    }
                    continue;
                }

                ParamBase newParam = null;
                switch (paramGroup)
                {
                case GroupNames.outPar:
                    newParam = new ParamAnswer(paramArray[i], sqlArray[i], ownField, field);
                    break;

                default:
                    if (isSystem)
                    {
                        newParam = new ParamSys(paramArray[i], sqlArray[i], ownField);
                    }
                    else
                    {
                        newParam = new ParamToSql(paramArray[i], sqlArray[i], ownField, field);
                    }
                    break;
                }
                if (newParam != null)
                {
                    Add(newParam);
                }
            }
            if ((paramGroup != GroupNames.outPar) && AllFound)
            {
                foreach (ParamBase param in this)
                {
                    if (!param.XlsExist)
                    {
                        AllFound = false;
                        break;
                    }
                }
            }
        }