Esempio n. 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Forum_Medal DataRowToModel(DataRow row)
        {
            if (row != null)
            {
                Model.Forum_Medal model = new Model.Forum_Medal();

                if (row["Id"].ToString() != "")
                {
                    model.Id = int.Parse(row["Id"].ToString());
                }
                model.Name        = row["Name"].ToString();
                model.Image       = row["Image"].ToString();
                model.Description = row["Description"].ToString();
                model.Url         = row["Url"].ToString();
                if (row["Available"].ToString() != "")
                {
                    model.Available = int.Parse(row["Available"].ToString());
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        private void ShowInfo(int _id)
        {
            BLL.Forum_Medal   bll   = new BLL.Forum_Medal();
            Model.Forum_Medal model = bll.GetModel(_id);
            //编写赋值操作Begin


            txtName.Text               = model.Name;
            txtImage.Text              = model.Image;
            txtDescription.Text        = model.Description;
            txtUrl.Text                = model.Url;
            rblAvailable.SelectedValue = model.Available.ToString();

            //编写赋值操作End
        }
Esempio n. 3
0
        private bool DoAdd()
        {
            Model.Forum_Medal model = new Model.Forum_Medal();
            BLL.Forum_Medal   bll   = new BLL.Forum_Medal();
            //编写添加操作Begin

            model.Name        = txtName.Text;
            model.Image       = txtImage.Text;
            model.Description = txtDescription.Text;
            model.Url         = txtUrl.Text;
            model.Available   = Convert.ToInt32(rblAvailable.SelectedValue);
            //编写添加操作End

            if (bll.Add(model) > 0)
            {
                AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加dt_Forum_Medal:"
                            + model.Name); //记录日志
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Forum_Medal model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "Forum_Medal set ");

            strSql.Append(" Name = @Name , ");
            strSql.Append(" Image = @Image , ");
            strSql.Append(" Description = @Description , ");
            strSql.Append(" Url = @Url , ");
            strSql.Append(" Available = @Available  ");
            strSql.Append(" where Id=@Id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",          SqlDbType.Int,        4),
                new SqlParameter("@Name",        SqlDbType.NVarChar, 128),
                new SqlParameter("@Image",       SqlDbType.NVarChar, 256),
                new SqlParameter("@Description", SqlDbType.NVarChar, 256),
                new SqlParameter("@Url",         SqlDbType.NVarChar, 256),
                new SqlParameter("@Available",   SqlDbType.TinyInt, 1)
            };

            parameters[0].Value = model.Id;
            parameters[1].Value = model.Name;
            parameters[2].Value = model.Image;
            parameters[3].Value = model.Description;
            parameters[4].Value = model.Url;
            parameters[5].Value = model.Available;
            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
        private bool DoEdit(int _id)
        {
            bool result = false;

            BLL.Forum_Medal   bll   = new BLL.Forum_Medal();
            Model.Forum_Medal model = bll.GetModel(_id);

            //编写编辑操作Begin
            model.Name        = txtName.Text;
            model.Image       = txtImage.Text;
            model.Description = txtDescription.Text;
            model.Url         = txtUrl.Text;
            model.Available   = Convert.ToInt32(rblAvailable.SelectedValue);
            //编写编辑操作End

            if (bll.Update(model))
            {
                AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改管理员:" + model.Name); //记录日志
                result = true;
            }

            return(result);
        }
Esempio n. 6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Forum_Medal model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + databaseprefix + "Forum_Medal(");
            strSql.Append("Name,Image,Description,Url,Available");
            strSql.Append(") values (");
            strSql.Append("@Name,@Image,@Description,@Url,@Available");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Name",        SqlDbType.NVarChar, 128),
                new SqlParameter("@Image",       SqlDbType.NVarChar, 256),
                new SqlParameter("@Description", SqlDbType.NVarChar, 256),
                new SqlParameter("@Url",         SqlDbType.NVarChar, 256),
                new SqlParameter("@Available",   SqlDbType.TinyInt, 1)
            };

            parameters[0].Value = model.Name;
            parameters[1].Value = model.Image;
            parameters[2].Value = model.Description;
            parameters[3].Value = model.Url;
            parameters[4].Value = model.Available;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.Forum_Medal model)
 {
     return(dal.Update(model));
 }
Esempio n. 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Model.Forum_Medal model)
 {
     return(dal.Add(model));
 }