示例#1
0
        public bool SaveConfig(BaseConfig_DT model, int DT_id)
        {
            //return SerializationHelper.Save(model, this.xmlpath);
            Type           type = model.GetType();
            Lebi_DT_Config cf;

            foreach (System.Reflection.PropertyInfo p in type.GetProperties())
            {
                if (p.GetValue(model, null) == null)
                {
                    continue;
                }
                cf = B_Lebi_DT_Config.GetModel("DT_id = " + DT_id + " and Name='" + p.Name + "'");
                if (cf == null)
                {
                    cf       = new Lebi_DT_Config();
                    cf.Name  = p.Name;
                    cf.Value = p.GetValue(model, null).ToString();
                    cf.DT_id = DT_id;
                    B_Lebi_DT_Config.Add(cf);
                }
                else
                {
                    cf.Name  = p.Name;
                    cf.Value = p.GetValue(model, null).ToString();
                    B_Lebi_DT_Config.Update(cf);
                }
            }
            ShopCache.SetBaseConfig(DT_id);//更新缓存
            return(true);
        }
示例#2
0
            /// <summary>
            /// 得到一个对象实体 by id
            /// </summary>
            public Lebi_DT_Config GetModel(int id)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select  top 1  * from [Lebi_DT_Config] ");
                strSql.Append(" where id=@id");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id", SqlDbType.Int, 4)
                };
                parameters[0].Value = id;

                Lebi_DT_Config model = new Lebi_DT_Config();
                DataSet        ds    = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), parameters);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                    }
                    model.Name  = ds.Tables[0].Rows[0]["Name"].ToString();
                    model.Value = ds.Tables[0].Rows[0]["Value"].ToString();
                    if (ds.Tables[0].Rows[0]["DT_id"].ToString() != "")
                    {
                        model.DT_id = int.Parse(ds.Tables[0].Rows[0]["DT_id"].ToString());
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
示例#3
0
            /// <summary>
            /// 得到一个对象实体 by SQLpara
            /// </summary>
            public Lebi_DT_Config GetModel(SQLPara para)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("select top 1 * from [Lebi_DT_Config] ");
                if (para.Where != "")
                {
                    strSql.Append(" where " + para.Where + "");
                }
                Lebi_DT_Config model = new Lebi_DT_Config();
                DataSet        ds    = SqlUtils.SqlUtilsInstance.TextExecuteDataset(strSql.ToString(), para.Para);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                    {
                        model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                    }
                    model.Name  = ds.Tables[0].Rows[0]["Name"].ToString();
                    model.Value = ds.Tables[0].Rows[0]["Value"].ToString();
                    if (ds.Tables[0].Rows[0]["DT_id"].ToString() != "")
                    {
                        model.DT_id = int.Parse(ds.Tables[0].Rows[0]["DT_id"].ToString());
                    }
                    return(model);
                }
                else
                {
                    return(null);
                }
            }
示例#4
0
            /// <summary>
            /// 增加一条数据
            /// </summary>
            public int Add(Lebi_DT_Config model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("insert into [Lebi_DT_Config](");
                strSql.Append("Name,Value,DT_id)");
                strSql.Append(" values (");
                strSql.Append("@Name,@Value,@DT_id)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Name",  model.Name),
                    new SqlParameter("@Value", model.Value),
                    new SqlParameter("@DT_id", model.DT_id)
                };

                object obj = SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters);

                if (obj == null)
                {
                    return(1);
                }
                else
                {
                    return(Convert.ToInt32(obj));
                }
            }
示例#5
0
        /// <summary>
        /// 获取一个设置值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public static string Get(string key)
        {
            Lebi_DT_Config conf = B_Lebi_DT_Config.GetModel("DT_id = " + ShopPage.GetDT() + " and Name='" + key + "'");

            if (conf == null)
            {
                return("");
            }
            return(conf.Value);
        }
示例#6
0
 /// <summary>
 /// 安全方式绑定对象表单
 /// </summary>
 public Lebi_DT_Config SafeBindForm(Lebi_DT_Config model)
 {
     if (HttpContext.Current.Request["Name"] != null)
     {
         model.Name = Shop.Tools.RequestTool.RequestSafeString("Name");
     }
     if (HttpContext.Current.Request["Value"] != null)
     {
         model.Value = Shop.Tools.RequestTool.RequestSafeString("Value");
     }
     if (HttpContext.Current.Request["DT_id"] != null)
     {
         model.DT_id = Shop.Tools.RequestTool.RequestInt("DT_id", 0);
     }
     return(model);
 }
示例#7
0
        /// <summary>
        /// 设置一个设置值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public static void Set(string key, string value)
        {
            Lebi_DT_Config conf = B_Lebi_DT_Config.GetModel("DT_id = " + ShopPage.GetDT() + " and Name='" + key + "'");

            if (conf == null)
            {
                conf       = new Lebi_DT_Config();
                conf.Name  = key;
                conf.Value = value;
                B_Lebi_DT_Config.Add(conf);
            }
            else
            {
                conf.Value = value;
                B_Lebi_DT_Config.Update(conf);
            }
        }
示例#8
0
            /// <summary>
            /// 更新一条数据
            /// </summary>
            public void Update(Lebi_DT_Config model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("update [Lebi_DT_Config] set ");
                strSql.Append("[Name]=@Name,");
                strSql.Append("[Value]=@Value,");
                strSql.Append("[DT_id]=@DT_id");
                strSql.Append(" where id=" + model.id);
                OleDbParameter[] parameters =
                {
                    new OleDbParameter("@Name",  model.Name),
                    new OleDbParameter("@Value", model.Value),
                    new OleDbParameter("@DT_id", model.DT_id)
                };

                AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters);
            }
示例#9
0
            /// <summary>
            /// 增加一条数据
            /// </summary>
            public int Add(Lebi_DT_Config model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("insert into [Lebi_DT_Config](");
                strSql.Append("[Name],[Value],[DT_id])");
                strSql.Append(" values (");
                strSql.Append("@Name,@Value,@DT_id)");
                OleDbParameter[] parameters =
                {
                    new OleDbParameter("@Name",  model.Name),
                    new OleDbParameter("@Value", model.Value),
                    new OleDbParameter("@DT_id", model.DT_id)
                };

                AccessUtils.Instance.TextExecuteNonQuery(strSql.ToString(), parameters);
                return(1);
            }
示例#10
0
            /// <summary>
            /// 对象实体绑定数据
            /// </summary>
            public Lebi_DT_Config ReaderBind(IDataReader dataReader)
            {
                Lebi_DT_Config model = new Lebi_DT_Config();
                object         ojb;

                ojb = dataReader["id"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.id = (int)ojb;
                }
                model.Name  = dataReader["Name"].ToString();
                model.Value = dataReader["Value"].ToString();
                ojb         = dataReader["DT_id"];
                if (ojb != null && ojb != DBNull.Value)
                {
                    model.DT_id = (int)ojb;
                }
                return(model);
            }
示例#11
0
            /// <summary>
            /// 更新一条数据
            /// </summary>
            public void Update(Lebi_DT_Config model)
            {
                StringBuilder strSql = new StringBuilder();

                strSql.Append("update [Lebi_DT_Config] set ");
                strSql.Append("Name= @Name,");
                strSql.Append("Value= @Value,");
                strSql.Append("DT_id= @DT_id");
                strSql.Append(" where id=@id");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@id",    SqlDbType.Int,       4),
                    new SqlParameter("@Name",  SqlDbType.NVarChar, 50),
                    new SqlParameter("@Value", SqlDbType.NText),
                    new SqlParameter("@DT_id", SqlDbType.Int, 4)
                };
                parameters[0].Value = model.id;
                parameters[1].Value = model.Name;
                parameters[2].Value = model.Value;
                parameters[3].Value = model.DT_id;

                SqlUtils.SqlUtilsInstance.TextExecuteNonQuery(strSql.ToString(), parameters);
            }
示例#12
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_DT_Config model)
 {
     D_Lebi_DT_Config.Instance.Update(model);
 }
示例#13
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_DT_Config model)
 {
     return(D_Lebi_DT_Config.Instance.Add(model));
 }
示例#14
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_DT_Config SafeBindForm(Lebi_DT_Config model)
 {
     return(D_Lebi_DT_Config.Instance.SafeBindForm(model));
 }