Ejemplo n.º 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);
        }
Ejemplo n.º 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);
                }
            }
Ejemplo n.º 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);
                }
            }
Ejemplo n.º 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));
                }
            }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
            }
Ejemplo n.º 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);
            }
Ejemplo n.º 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);
            }
Ejemplo n.º 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);
            }
Ejemplo n.º 12
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public static void Update(Lebi_DT_Config model)
 {
     D_Lebi_DT_Config.Instance.Update(model);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public static int Add(Lebi_DT_Config model)
 {
     return(D_Lebi_DT_Config.Instance.Add(model));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// 安全方式绑定表单数据
 /// </summary>
 public static Lebi_DT_Config SafeBindForm(Lebi_DT_Config model)
 {
     return(D_Lebi_DT_Config.Instance.SafeBindForm(model));
 }