Пример #1
0
        /// <summary>
        /// 根据key 得到int val
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public int GetValIntByKey(string key)
        {
            try
            {
                return(int.Parse(this.GetValStrByKey(key)));
            }
            catch (Exception ex)
            {
                //if (SystemConfig.IsDebug == false)
                //    throw new Exception("@[" + this.EnMap.GetAttrByKey(key).Desc + "]请输入数字,您输入的是[" + this.GetValStrByKey(key) + "]。");
                //else
                //    throw new Exception("@表[" + this.EnDesc + "]在获取属性[" + key + "]值,出现错误,不能将[" + this.GetValStringByKey(key) + "]转换为int类型.错误信息:" + ex.Message + "@请检查是否在存储枚举类型时,您在SetValbyKey中没有转换。正确做法是:this.SetValByKey( Key ,(int)value)  ");

                string v = this.GetValStrByKey(key).ToLower();
                if (v == "true")
                {
                    this.SetValByKey(key, 1);
                    return(1);
                }
                if (v == "false")
                {
                    this.SetValByKey(key, 0);
                    return(0);
                }

                if (key == "OID")
                {
                    this.SetValByKey("OID", 0);
                    return(0);
                }

                if (this.GetValStrByKey(key) == "")
                {
                    Attr attr = this.EnMap.GetAttrByKey(key);
                    if (attr.IsNull)
                    {
                        return(567567567);
                    }
                    else
                    {
                        return(int.Parse(attr.DefaultVal.ToString()));
                    }
                }

                //else
                //{
                //    return int.Parse(this.EnMap.GetAttrByKey(key).DefaultVal.ToString());
                //}

                if (SystemConfig.IsDebug == false)
                {
                    throw new Exception("@[" + this.EnMap.GetAttrByKey(key).Desc + "]请输入数字,您输入的是[" + this.GetValStrByKey(key) + "]。");
                }
                else
                {
                    throw new Exception("@表[" + this.EnDesc + "]在获取属性[" + key + "]值,出现错误,不能将[" + this.GetValStringByKey(key) + "]转换为int类型.错误信息:" + ex.Message + "@请检查是否在存储枚举类型时,您在SetValbyKey中没有转换。正确做法是:this.SetValByKey( Key ,(int)value)  ");
                }
            }
        }
Пример #2
0
        public void Add(Attr attr, bool isShowSelectedAll, string relationalDtlKey)
        {
            AttrSearch en = new AttrSearch();

            en.HisAttr          = attr;
            en.IsShowAll        = isShowSelectedAll;
            en.RelationalDtlKey = relationalDtlKey;
            en.Key = attr.Key;
            this.InnerList.Add(en);
        }
Пример #3
0
        public DataTable DoGroupReturnTable(Entity en, Attrs attrsOfGroupKey, Attr attrGroup, GroupWay gw, OrderWay ow)
        {
            switch (en.EnMap.EnDBUrl.DBType)
            {
            case DBType.Oracle:
                return(DoGroupReturnTableOracle(en, attrsOfGroupKey, attrGroup, gw, ow));

            default:
                return(DoGroupReturnTableSqlServer(en, attrsOfGroupKey, attrGroup, gw, ow));
            }
        }
Пример #4
0
        public void Add(Attr attr)
        {
            if (attr.Field == null || attr.Field == "")
            {
                throw new Exception("属性设置错误:您不能设置 key='" + attr.Key + "',得字段值为空");
            }

            bool k = attr.IsKeyEqualField;

            this.Add(attr, true, false);
        }
Пример #5
0
        public void AddTBDecimal(string key, string _Field, decimal defaultVal, string desc, bool uiVisable, bool isReadonly)
        {
            Attr attr = new Attr();

            attr.Key          = key;
            attr.Field        = _Field;
            attr.DefaultVal   = defaultVal;
            attr.MyDataType   = DataType.AppDouble;
            attr.Desc         = desc;
            attr.UITBShowType = TBType.Decimal;
            attr.UIVisible    = uiVisable;
            attr.UIIsReadonly = isReadonly;
            this.Add(attr);
        }
Пример #6
0
        public void AddTBDate(string key, string field, string defaultVal, string desc, bool uiVisable, bool isReadonly)
        {
            Attr attr = new Attr();

            attr.Key          = key;
            attr.Field        = field;
            attr.DefaultVal   = defaultVal;
            attr.MyDataType   = DataType.AppDate;
            attr.Desc         = desc;
            attr.UITBShowType = TBType.Date;
            attr.UIVisible    = uiVisable;
            attr.UIIsReadonly = isReadonly;
            attr.MaxLength    = 20;
            this.Add(attr);
        }
Пример #7
0
        private void AddRefAttrText(Attr attr)
        {
            if (attr.MyFieldType == FieldType.FK ||
                attr.MyFieldType == FieldType.Enum ||
                attr.MyFieldType == FieldType.PKEnum ||
                attr.MyFieldType == FieldType.PKFK)
            {
                Attr myattr = new Attr();
                myattr.MyFieldType   = FieldType.RefText;
                myattr.MyDataType    = DataType.AppString;
                myattr.UIContralType = UIContralType.TB;
                myattr.UIWidth       = attr.UIWidth * 2;
                myattr.Key           = attr.Key + "Text";


                myattr.UIIsReadonly = true;
                myattr.UIBindKey    = attr.UIBindKey;
                // myattr.UIBindKeyOfEn = attr.UIBindKeyOfEn;
                myattr.HisFKEns = attr.HisFKEns;



                //myattr.Desc=attr.Desc+"名称";

                string desc = myattr.Desc = "名称";
                if (desc.IndexOf("编号") >= 0)
                {
                    myattr.Desc = attr.Desc.Replace("编号", "名称");
                }
                else
                {
                    myattr.Desc = attr.Desc + "名称";
                }

                if (attr.UIContralType == UIContralType.DDL)
                {
                    myattr.UIVisible = false;
                }

                this.InnerList.Add(myattr);


                //this.Add(myattr,true);
            }
        }
Пример #8
0
        /// <summary>
        /// 自定义枚举类型
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="field">字段</param>
        /// <param name="defaultVal">默认</param>
        /// <param name="desc">描述</param>
        /// <param name="sysEnumKey">Key</param>
        public void AddDDLSysEnum(string key, string field, int defaultVal, string desc, bool isUIVisable, bool isUIEnable, string sysEnumKey, string cfgVal)
        {
            Attr attr = new Attr();

            attr.Key           = key;
            attr.Field         = field;
            attr.DefaultVal    = defaultVal;
            attr.MyDataType    = DataType.AppInt;
            attr.MyFieldType   = FieldType.Enum;
            attr.Desc          = desc;
            attr.UIContralType = UIContralType.DDL;
            attr.UIDDLShowType = DDLShowType.SysEnum;
            attr.UIBindKey     = sysEnumKey;
            attr.UITag         = cfgVal;
            attr.UIVisible     = isUIVisable;
            attr.UIIsReadonly  = isUIEnable;
            this.Add(attr);
        }
Пример #9
0
        public void AddTBStringDoc(string key, string field, string defaultVal, string desc, bool uiVisable, bool isReadonly, int minLength, int maxLength, int tbWith, int rows)
        {
            Attr attr = new Attr();

            attr.Key          = key;
            attr.Field        = field;
            attr.DefaultVal   = defaultVal;
            attr.MyDataType   = DataType.AppString;
            attr.Desc         = desc;
            attr.UITBShowType = TBType.TB;
            attr.UIVisible    = uiVisable;
            attr.UIWidth      = 300;
            attr.UIIsReadonly = isReadonly;
            attr.MaxLength    = maxLength;
            attr.MinLength    = minLength;
            attr.MyFieldType  = FieldType.Normal;
            attr.UIHeight     = rows;
            this.Add(attr);
        }
Пример #10
0
        protected void AddTBString(string key, string field, object defaultVal,
                                   FieldType _FieldType, TBType tbType, string desc, bool uiVisable, bool isReadonly, int minLength, int maxLength, int tbWith)
        {
            Attr attr = new Attr();

            attr.Key          = key;
            attr.Field        = field;
            attr.DefaultVal   = defaultVal;
            attr.MyDataType   = DataType.AppString;
            attr.Desc         = desc;
            attr.UITBShowType = tbType;
            attr.UIVisible    = uiVisable;
            attr.UIWidth      = tbWith;
            attr.UIIsReadonly = isReadonly;
            attr.MaxLength    = maxLength;
            attr.MinLength    = minLength;
            attr.MyFieldType  = _FieldType;
            this.Add(attr);
        }
Пример #11
0
        /// <summary>
        /// 加入一个属性。
        /// </summary>
        /// <param name="attr">attr</param>
        /// <param name="isAddHisRefText">isAddHisRefText</param>
        public void Add(Attr attr, bool isAddHisRefText, bool isAddHisRefName)
        {
            foreach (Attr myattr in this)
            {
                if (myattr.Key == attr.Key)
                {
                    return;
                }
            }

            this.InnerList.Add(attr);

            if (isAddHisRefText)
            {
                this.AddRefAttrText(attr);
            }

            if (isAddHisRefName)
            {
                this.AddRefAttrName(attr);
            }
        }
Пример #12
0
 public decimal GetValMoneyByKey(string key)
 {
     try
     {
         return(decimal.Parse(this.GetValDecimalByKey(key).ToString("0.00")));
     }
     catch
     {
         if (this.GetValStringByKey(key) == "")
         {
             Attr attr = this.EnMap.GetAttrByKey(key);
             if (attr.IsNull)
             {
                 return(567567567);
             }
             else
             {
                 return(decimal.Parse(attr.DefaultVal.ToString()));
             }
         }
         return(0);
     }
 }
Пример #13
0
 /// <summary>
 /// 根据key 得到flaot val
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public float GetValFloatByKey(string key)
 {
     try
     {
         return(float.Parse(float.Parse(this.Row.GetValByKey(key).ToString()).ToString("0.00")));
     }
     catch
     {
         if (this.GetValStringByKey(key) == "")
         {
             Attr attr = this.EnMap.GetAttrByKey(key);
             if (attr.IsNull)
             {
                 return(567567567);
             }
             else
             {
                 return(float.Parse(attr.DefaultVal.ToString()));
             }
         }
         return(0);
     }
 }
Пример #14
0
        /// <summary>
        /// 于实体有关系的操作。
        /// </summary>
        /// <param name="key">健值</param>
        /// <param name="field">字段</param>
        /// <param name="defaultVal">默认值</param>
        /// <param name="dataType">DataType类型</param>
        /// <param name="desc">描述</param>
        /// <param name="ens">实体集合</param>
        /// <param name="refKey">关联的建</param>
        /// <param name="refText">关联的Text</param>
        public void AddDDLEntities(string key, string field, object defaultVal, int dataType, FieldType _fildType, string desc, Entities ens, string refKey, string refText, bool uiIsEnable)
        {
            Attr attr = new Attr();

            attr.Key         = key;
            attr.Field       = field;
            attr.DefaultVal  = defaultVal;
            attr.MyDataType  = dataType;
            attr.MyFieldType = _fildType;

            attr.Desc          = desc;
            attr.UIContralType = UIContralType.DDL;
            attr.UIDDLShowType = DDLShowType.Ens;
            attr.UIBindKey     = ens.ToString();
            //attr.UIBindKeyOfEn = ens.GetNewEntity.ToString();
            attr.HisFKEns = ens;

            attr.HisFKEns      = ens;
            attr.UIRefKeyText  = refText;
            attr.UIRefKeyValue = refKey;
            attr.UIIsReadonly  = uiIsEnable;
            this.Add(attr, true, false);
        }
Пример #15
0
        public void AddBoolen(string key, bool defaultVal, string desc)
        {
            Attr attr = new Attr();

            attr.Key   = key;
            attr.Field = key;

            if (defaultVal)
            {
                attr.DefaultVal = 1;
            }
            else
            {
                attr.DefaultVal = 0;
            }

            attr.MyDataType    = DataType.AppBoolean;
            attr.Desc          = desc;
            attr.UIContralType = UIContralType.CheckBok;
            attr.UIIsReadonly  = true;
            attr.UIVisible     = true;
            this.Add(attr);
        }
Пример #16
0
        /// <summary>
        /// 用户风格1
        /// </summary>
        /// <returns></returns>
        private static DataTable ToTable1(Entity en)
        {
            string col1 = "字段名1";
            string col2 = "内容1";
            string col3 = "字段名2";
            string col4 = "内容2";

            //string enterNote=null;
            //			if (this.EnMap.Dtls.Count==0 || this.EnMap.AttrsOfOneVSM.Count==0)
            //				enterNote="内容1";
            //			else
            //				enterNote="保存后才能编辑关联信息";


            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn(col1, typeof(string)));
            dt.Columns.Add(new DataColumn(col2, typeof(string)));
            dt.Columns.Add(new DataColumn(col3, typeof(string)));
            dt.Columns.Add(new DataColumn(col4, typeof(string)));


            for (int i = 0; i < en.EnMap.HisPhysicsAttrs.Count; i++)
            {
                DataRow dr   = dt.NewRow();
                Attr    attr = en.EnMap.HisPhysicsAttrs[i];
                dr[col1] = attr.Desc;
                dr[col2] = en.GetValByKey(attr.Key);

                i++;
                if (i == en.EnMap.HisPhysicsAttrs.Count)
                {
                    dt.Rows.Add(dr);
                    break;
                }
                attr     = en.EnMap.HisPhysicsAttrs[i];
                dr[col3] = attr.Desc;
                dr[col4] = en.GetValByKey(attr.Key);
                dt.Rows.Add(dr);
            }


            // 如果实体需要附件。
            if (en.EnMap.AdjunctType != AdjunctType.None)
            {
                // 加入附件信息。
                DataRow dr1 = dt.NewRow();
                dr1[col1] = "附件";
                dr1[col2] = "编辑附件";
                //dr["输入项目2"]="附件信息";

                dt.Rows.Add(dr1);
            }
            // 明细
            foreach (EnDtl dtl in en.EnMap.Dtls)
            {
                DataRow dr = dt.NewRow();
                dr[col1] = dtl.Desc;
                dr[col2] = "EnsName_" + dtl.Ens.ToString() + "_RefKey_" + dtl.RefKey;
                //dr["输入项目2"]="明细信息";
                dt.Rows.Add(dr);
            }
            // 多对多的关系
            foreach (AttrOfOneVSM attr in en.EnMap.AttrsOfOneVSM)
            {
                DataRow dr = dt.NewRow();
                dr[col1] = attr.Desc;
                dr[col2] = "OneVSM" + attr.EnsOfMM.ToString();
                //dr["输入项目2"]="多选";
                dt.Rows.Add(dr);
            }
            return(dt);
        }
Пример #17
0
        /// <summary>
        /// 分组查询,返回datatable.
        /// </summary>
        /// <param name="attrsOfGroupKey"></param>
        /// <param name="groupValField"></param>
        /// <param name="gw"></param>
        /// <returns></returns>
        public DataTable DoGroupReturnTable1(Entity en, Attrs attrsOfGroupKey, Attr attrGroup, GroupWay gw, OrderWay ow)
        {
            #region  生成要查询的语句
            string fields = "";
            string str    = "";
            foreach (Attr attr in attrsOfGroupKey)
            {
                if (attr.Field == null)
                {
                    continue;
                }
                str     = "," + attr.Field;
                fields += str;
            }

            if (attrGroup.Key == "MyNum")
            {
                switch (gw)
                {
                case GroupWay.BySum:
                    fields += ", COUNT(*) AS MyNum";
                    break;

                case GroupWay.ByAvg:
                    fields += ", AVG(*)   AS MyNum";
                    break;

                default:
                    throw new Exception("no such case:");
                }
            }
            else
            {
                switch (gw)
                {
                case GroupWay.BySum:
                    fields += ",SUM(" + attrGroup.Field + ") AS " + attrGroup.Key;
                    break;

                case GroupWay.ByAvg:
                    fields += ",AVG(" + attrGroup.Field + ") AS " + attrGroup.Key;
                    break;

                default:
                    throw new Exception("no such case:");
                }
            }

            string by = "";
            foreach (Attr attr in attrsOfGroupKey)
            {
                if (attr.Field == null)
                {
                    continue;
                }

                str = "," + attr.Field;
                by += str;
            }
            by = by.Substring(1);
            //string sql
            string sql = "SELECT " + fields.Substring(1) + " FROM " + this.En.EnMap.PhysicsTable + " WHERE " + this._sql + " Group BY " + by;
            #endregion

            #region
            Map map = new Map();
            map.PhysicsTable = "@VT@";
            map.Attrs        = attrsOfGroupKey;
            map.Attrs.Add(attrGroup);
            #endregion .

            //string sql1=SqlBuilder.SelectSQLOfMS( map )+" "+SqlBuilder.GenerFormWhereOfMS( en,map) + "   AND ( " + this._sql+" ) "+_endSql;

            string sql1 = SqlBuilder.SelectSQLOfMS(map) + " " + SqlBuilder.GenerFormWhereOfMS(en, map);

            sql1 = sql1.Replace("@TopNum", "");
            sql1 = sql1.Replace("FROM @VT@", "FROM (" + sql + ") VT");
            sql1 = sql1.Replace("@VT@", "VT");
            sql1 = sql1.Replace("TOP", "");
            if (ow == OrderWay.OrderByUp)
            {
                sql1 += " ORDER BY " + attrGroup.Key + " DESC ";
            }
            else
            {
                sql1 += " ORDER BY " + attrGroup.Key;
            }
            return(DBAccess.RunSQLReturnTable(sql1));
        }