Beispiel #1
0
        /// <summary>
        /// 给实体赋值
        /// </summary>
        /// <param name="model">实体</param>
        /// <param name="colName">列名</param>
        /// <param name="value">值</param>
        public void SetModelValue(DataAccess.Model.SYS_PARAMATERS model, string colName, object value)
        {
            if (model == null || string.IsNullOrEmpty(colName))
            {
                return;
            }

            //返回指定条件的实体
            switch (colName)
            {
            case "Id":
                model.Id = (int)value;
                break;

            case "Code":
                model.Code = (string)value;
                break;

            case "VALUE":
                model.VALUE = (string)value;
                break;

            case "KEY_CN":
                model.KEY_CN = (string)value;
                break;

            case "MEMO":
                model.MEMO = (string)value;
                break;

            case "Area_Id":
                model.Area_Id = (string)value;
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 返回实体中指定字段名的值
        /// </summary>
        /// <param name="model">实体</param>
        /// <param name="colName">获取的字段名</param>
        /// <returns></returns>
        private object GetFieldValue(DataAccess.Model.SYS_PARAMATERS model, string colName)
        {
            if (model == null || string.IsNullOrEmpty(colName))
            {
                return(null);
            }
            //返回指定的列值
            switch (colName)
            {
            case "Id":
                return(model.Id);

            case "Code":
                return(model.Code);

            case "VALUE":
                return(model.VALUE);

            case "KEY_CN":
                return(model.KEY_CN);

            case "MEMO":
                return(model.MEMO);

            case "Area_Id":
                return(model.Area_Id);
            }

            return(null);
        }
Beispiel #3
0
        /// <summary>
        /// 将SYS_PARAMATERS记录实体由普通的实体(DataAccess.Model.SYS_PARAMATERS)转换为SubSonic插件生成的实体
        /// </summary>
        /// <param name="model">普通的实体(DataAccess.Model.SYS_PARAMATERS)</param>
        /// <returns>SYS_PARAMATERS</returns>
        public SYS_PARAMATERS Transform(DataAccess.Model.SYS_PARAMATERS model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new SYS_PARAMATERS
            {
                Id = model.Id,
                AREA_ID = model.AREA_ID,
                COL_ORDER_TYPE = model.COL_ORDER_TYPE,
                ORDER_PRICE_TYPE = model.ORDER_PRICE_TYPE,
                QUANTITY_TYPE = model.QUANTITY_TYPE,
                EXPECT_DATE_TYPE = model.EXPECT_DATE_TYPE,
                PRD_BOM_TYPE = model.PRD_BOM_TYPE,
                CRT_DATETIME = model.CRT_DATETIME,
                CRT_USER_ID = model.CRT_USER_ID,
                MOD_DATETIME = model.MOD_DATETIME,
                MOD_USER_ID = model.MOD_USER_ID,
                LAST_UPDATE = model.LAST_UPDATE,
                MEMO = model.MEMO,
                PALN_TYPE = model.PALN_TYPE,
            });
        }
Beispiel #4
0
        /// <summary>
        /// 更新IIS缓存中指定Id记录
        /// </summary>
        /// <param name="model">记录实体</param>
        public void SetModelForCache(DataAccess.Model.SYS_PARAMATERS model)
        {
            //从缓存中读取记录列表
            var list = GetList();

            //从缓存中删除记录
            DelCache(model.Id);
            //添加记录
            list.Add(model);
        }
Beispiel #5
0
        /// <summary>
        /// 返回实体中指定字段名的值
        /// </summary>
        /// <param name="model">实体</param>
        /// <param name="colName">获取的字段名</param>
        /// <returns></returns>
        private object GetFieldValue(DataAccess.Model.SYS_PARAMATERS model, string colName)
        {
            if (model == null || string.IsNullOrEmpty(colName))
            {
                return(null);
            }
            //返回指定的列值
            switch (colName)
            {
            case "Id":
                return(model.Id);

            case "AREA_ID":
                return(model.AREA_ID);

            case "COL_ORDER_TYPE":
                return(model.COL_ORDER_TYPE);

            case "ORDER_PRICE_TYPE":
                return(model.ORDER_PRICE_TYPE);

            case "QUANTITY_TYPE":
                return(model.QUANTITY_TYPE);

            case "EXPECT_DATE_TYPE":
                return(model.EXPECT_DATE_TYPE);

            case "PRD_BOM_TYPE":
                return(model.PRD_BOM_TYPE);

            case "CRT_DATETIME":
                return(model.CRT_DATETIME);

            case "CRT_USER_ID":
                return(model.CRT_USER_ID);

            case "MOD_DATETIME":
                return(model.MOD_DATETIME);

            case "MOD_USER_ID":
                return(model.MOD_USER_ID);

            case "LAST_UPDATE":
                return(model.LAST_UPDATE);

            case "MEMO":
                return(model.MEMO);

            case "PALN_TYPE":
                return(model.PALN_TYPE);
            }

            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// 给实体赋值
        /// </summary>
        /// <param name="model">实体</param>
        /// <param name="dic">列名与值</param>
        public void SetModelValue(DataAccess.Model.SYS_PARAMATERS model, Dictionary <string, object> dic)
        {
            if (model == null || dic == null)
            {
                return;
            }

            //遍历字典,逐个给字段赋值
            foreach (var d in dic)
            {
                SetModelValue(model, d.Key, d.Value);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 将SYS_PARAMATERS记录实体由普通的实体(DataAccess.Model.SYS_PARAMATERS)转换为SubSonic插件生成的实体
        /// </summary>
        /// <param name="model">普通的实体(DataAccess.Model.SYS_PARAMATERS)</param>
        /// <returns>SYS_PARAMATERS</returns>
        public SYS_PARAMATERS Transform(DataAccess.Model.SYS_PARAMATERS model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new SYS_PARAMATERS
            {
                Id = model.Id,
                Code = model.Code,
                VALUE = model.VALUE,
                KEY_CN = model.KEY_CN,
                MEMO = model.MEMO,
                Area_Id = model.Area_Id,
            });
        }
Beispiel #8
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.SYS_PARAMATERS</returns>
        public DataAccess.Model.SYS_PARAMATERS GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.SYS_PARAMATERS           model      = null;
                Expression <Func <SYS_PARAMATERS, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "Code":
                    model      = list.SingleOrDefault(x => x.Code == (string)value);
                    expression = x => x.Code == (string)value;
                    break;

                case "VALUE":
                    model      = list.SingleOrDefault(x => x.VALUE == (string)value);
                    expression = x => x.VALUE == (string)value;
                    break;

                case "KEY_CN":
                    model      = list.SingleOrDefault(x => x.KEY_CN == (string)value);
                    expression = x => x.KEY_CN == (string)value;
                    break;

                case "MEMO":
                    model      = list.SingleOrDefault(x => x.MEMO == (string)value);
                    expression = x => x.MEMO == (string)value;
                    break;

                case "Area_Id":
                    model      = list.SingleOrDefault(x => x.Area_Id == (string)value);
                    expression = x => x.Area_Id == (string)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = SYS_PARAMATERS.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取SYS_PARAMATERS表记录时出现异常", e);

                return(null);
            }
        }
Beispiel #9
0
        /// <summary>
        /// 给实体赋值
        /// </summary>
        /// <param name="model">实体</param>
        /// <param name="colName">列名</param>
        /// <param name="value">值</param>
        public void SetModelValue(DataAccess.Model.SYS_PARAMATERS model, string colName, object value)
        {
            if (model == null || string.IsNullOrEmpty(colName))
            {
                return;
            }

            //返回指定条件的实体
            switch (colName)
            {
            case "Id":
                model.Id = (int)value;
                break;

            case "AREA_ID":
                model.AREA_ID = (string)value;
                break;

            case "COL_ORDER_TYPE":
                model.COL_ORDER_TYPE = (int)value;
                break;

            case "ORDER_PRICE_TYPE":
                model.ORDER_PRICE_TYPE = (int)value;
                break;

            case "QUANTITY_TYPE":
                model.QUANTITY_TYPE = (int)value;
                break;

            case "EXPECT_DATE_TYPE":
                model.EXPECT_DATE_TYPE = (int)value;
                break;

            case "PRD_BOM_TYPE":
                model.PRD_BOM_TYPE = (int)value;
                break;

            case "CRT_DATETIME":
                model.CRT_DATETIME = (DateTime)value;
                break;

            case "CRT_USER_ID":
                model.CRT_USER_ID = (string)value;
                break;

            case "MOD_DATETIME":
                model.MOD_DATETIME = (DateTime)value;
                break;

            case "MOD_USER_ID":
                model.MOD_USER_ID = (string)value;
                break;

            case "LAST_UPDATE":
                model.LAST_UPDATE = (DateTime)value;
                break;

            case "MEMO":
                model.MEMO = (string)value;
                break;

            case "PALN_TYPE":
                model.PALN_TYPE = (int)value;
                break;
            }
        }
Beispiel #10
0
        /// <summary>
        /// 从IIS缓存中获取指定Id记录
        /// </summary>
        /// <param name="conditionColName">条件列名</param>
        /// <param name="value">条件值</param>
        /// <returns>DataAccess.Model.SYS_PARAMATERS</returns>
        public DataAccess.Model.SYS_PARAMATERS GetModelForCache(string conditionColName, object value)
        {
            try
            {
                //从缓存中获取List
                var list = GetList();
                DataAccess.Model.SYS_PARAMATERS           model      = null;
                Expression <Func <SYS_PARAMATERS, bool> > expression = null;

                //返回指定条件的实体
                switch (conditionColName)
                {
                case "Id":
                    model      = list.SingleOrDefault(x => x.Id == (int)value);
                    expression = x => x.Id == (int)value;
                    break;

                case "AREA_ID":
                    model      = list.SingleOrDefault(x => x.AREA_ID == (string)value);
                    expression = x => x.AREA_ID == (string)value;
                    break;

                case "COL_ORDER_TYPE":
                    model      = list.SingleOrDefault(x => x.COL_ORDER_TYPE == (int)value);
                    expression = x => x.COL_ORDER_TYPE == (int)value;
                    break;

                case "ORDER_PRICE_TYPE":
                    model      = list.SingleOrDefault(x => x.ORDER_PRICE_TYPE == (int)value);
                    expression = x => x.ORDER_PRICE_TYPE == (int)value;
                    break;

                case "QUANTITY_TYPE":
                    model      = list.SingleOrDefault(x => x.QUANTITY_TYPE == (int)value);
                    expression = x => x.QUANTITY_TYPE == (int)value;
                    break;

                case "EXPECT_DATE_TYPE":
                    model      = list.SingleOrDefault(x => x.EXPECT_DATE_TYPE == (int)value);
                    expression = x => x.EXPECT_DATE_TYPE == (int)value;
                    break;

                case "PRD_BOM_TYPE":
                    model      = list.SingleOrDefault(x => x.PRD_BOM_TYPE == (int)value);
                    expression = x => x.PRD_BOM_TYPE == (int)value;
                    break;

                case "CRT_DATETIME":
                    model      = list.SingleOrDefault(x => x.CRT_DATETIME == (DateTime)value);
                    expression = x => x.CRT_DATETIME == (DateTime)value;
                    break;

                case "CRT_USER_ID":
                    model      = list.SingleOrDefault(x => x.CRT_USER_ID == (string)value);
                    expression = x => x.CRT_USER_ID == (string)value;
                    break;

                case "MOD_DATETIME":
                    model      = list.SingleOrDefault(x => x.MOD_DATETIME == (DateTime)value);
                    expression = x => x.MOD_DATETIME == (DateTime)value;
                    break;

                case "MOD_USER_ID":
                    model      = list.SingleOrDefault(x => x.MOD_USER_ID == (string)value);
                    expression = x => x.MOD_USER_ID == (string)value;
                    break;

                case "LAST_UPDATE":
                    model      = list.SingleOrDefault(x => x.LAST_UPDATE == (DateTime)value);
                    expression = x => x.LAST_UPDATE == (DateTime)value;
                    break;

                case "MEMO":
                    model      = list.SingleOrDefault(x => x.MEMO == (string)value);
                    expression = x => x.MEMO == (string)value;
                    break;

                case "PALN_TYPE":
                    model      = list.SingleOrDefault(x => x.PALN_TYPE == (int)value);
                    expression = x => x.PALN_TYPE == (int)value;
                    break;

                default:
                    return(null);
                }

                if (model == null)
                {
                    //从数据库中读取
                    var tem = SYS_PARAMATERS.SingleOrDefault(expression);
                    if (tem == null)
                    {
                        return(null);
                    }
                    else
                    {
                        //对查询出来的实体进行转换
                        model = Transform(tem);

                        return(model);
                    }
                }
                else
                {
                    return(model);
                }
            }
            catch (Exception e)
            {
                //记录日志
                CommonBll.WriteLog("从IIS缓存中获取SYS_PARAMATERS表记录时出现异常", e);

                return(null);
            }
        }