Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(LPWeb.Model.Template_EmailSkins model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Template_EmailSkins(");
            strSql.Append("Name,[Desc],HTMLBody,[Enabled],[Default])");
            strSql.Append(" values (");
            strSql.Append("@Name,@Desc,@HTMLBody,@Enabled,@Default)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",     SqlDbType.NVarChar,  255),
                new SqlParameter("@Desc",     SqlDbType.NVarChar,  500),
                new SqlParameter("@HTMLBody", SqlDbType.NVarChar),
                new SqlParameter("@Enabled",  SqlDbType.Bit,         1),
                new SqlParameter("@Default",  SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.Name;
            parameters[1].Value = model.Desc;
            parameters[2].Value = model.HTMLBody;
            parameters[3].Value = model.Enabled;
            parameters[4].Value = model.Default;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.Template_EmailSkins GetModel(int EmailSkinId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 EmailSkinId,Name,[Desc],HTMLBody,[Enabled],[Default] from Template_EmailSkins ");
            strSql.Append(" where EmailSkinId=@EmailSkinId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EmailSkinId", SqlDbType.Int, 4)
            };
            parameters[0].Value = EmailSkinId;

            LPWeb.Model.Template_EmailSkins model = new LPWeb.Model.Template_EmailSkins();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["EmailSkinId"].ToString() != "")
                {
                    model.EmailSkinId = int.Parse(ds.Tables[0].Rows[0]["EmailSkinId"].ToString());
                }
                model.Name     = ds.Tables[0].Rows[0]["Name"].ToString();
                model.Desc     = ds.Tables[0].Rows[0]["Desc"] != DBNull.Value ? ds.Tables[0].Rows[0]["Desc"].ToString() : "";
                model.HTMLBody = ds.Tables[0].Rows[0]["HTMLBody"] != DBNull.Value ? ds.Tables[0].Rows[0]["HTMLBody"].ToString() : "";
                if (ds.Tables[0].Rows[0]["Enabled"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Enabled"].ToString() == "1") || (ds.Tables[0].Rows[0]["Enabled"].ToString().ToLower() == "true"))
                    {
                        model.Enabled = true;
                    }
                    else
                    {
                        model.Enabled = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["Default"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Default"].ToString() == "1") || (ds.Tables[0].Rows[0]["Default"].ToString().ToLower() == "true"))
                    {
                        model.Default = true;
                    }
                    else
                    {
                        model.Default = false;
                    }
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <LPWeb.Model.Template_EmailSkins> DataTableToList(DataTable dt)
        {
            List <LPWeb.Model.Template_EmailSkins> modelList = new List <LPWeb.Model.Template_EmailSkins>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                LPWeb.Model.Template_EmailSkins model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new LPWeb.Model.Template_EmailSkins();
                    if (dt.Rows[n]["EmailSkinId"].ToString() != "")
                    {
                        model.EmailSkinId = int.Parse(dt.Rows[n]["EmailSkinId"].ToString());
                    }
                    model.Name     = dt.Rows[n]["Name"].ToString();
                    model.Desc     = dt.Rows[n]["Desc"].ToString();
                    model.HTMLBody = dt.Rows[n]["HTMLBody"].ToString();
                    if (dt.Rows[n]["Enabled"].ToString() != "")
                    {
                        if ((dt.Rows[n]["Enabled"].ToString() == "1") || (dt.Rows[n]["Enabled"].ToString().ToLower() == "true"))
                        {
                            model.Enabled = true;
                        }
                        else
                        {
                            model.Enabled = false;
                        }
                    }
                    if (dt.Rows[n]["Default"].ToString() != "")
                    {
                        if ((dt.Rows[n]["Default"].ToString() == "1") || (dt.Rows[n]["Default"].ToString().ToLower() == "true"))
                        {
                            model.Default = true;
                        }
                        else
                        {
                            model.Default = false;
                        }
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(LPWeb.Model.Template_EmailSkins model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Template_EmailSkins set ");
            strSql.Append("Name=@Name,");
            strSql.Append("[Desc]=@Desc,");
            strSql.Append("HTMLBody=@HTMLBody,");
            strSql.Append("[Enabled]=@Enabled,");
            strSql.Append("[Default]=@Default");
            strSql.Append(" where EmailSkinId=@EmailSkinId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@EmailSkinId", SqlDbType.Int,         4),
                new SqlParameter("@Name",        SqlDbType.NVarChar,  255),
                new SqlParameter("@Desc",        SqlDbType.NVarChar,  500),
                new SqlParameter("@HTMLBody",    SqlDbType.NVarChar),
                new SqlParameter("@Enabled",     SqlDbType.Bit,         1),
                new SqlParameter("@Default",     SqlDbType.Bit, 1)
            };
            parameters[0].Value = model.EmailSkinId;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Desc;
            parameters[3].Value = model.HTMLBody;
            parameters[4].Value = model.Enabled;
            parameters[5].Value = model.Default;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(LPWeb.Model.Template_EmailSkins model)
 {
     return(dal.Update(model));
 }
Example #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(LPWeb.Model.Template_EmailSkins model)
 {
     return(dal.Add(model));
 }