private void ShowInfo(int _id)
 {
     DTcms.BLL.photo_attribute   bll   = new BLL.photo_attribute();
     DTcms.Model.photo_attribute model = bll.GetModel(_id);
     txtTitle.Text         = model.title;
     txtRemark.Text        = model.remark;
     ddlType.SelectedValue = model.type.ToString();
     txtDefaultValue.Text  = model.default_value;
     txtSortId.Text        = model.sort_id.ToString();
 }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DTcms.Model.photo_attribute GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,channel_id,title,remark,type,default_value,sort_id,add_time from dt_photo_attribute ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            DTcms.Model.photo_attribute model = new DTcms.Model.photo_attribute();
            DataSet ds = DbHelperSQL.Query(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());
                }
                if (ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }
                model.title  = ds.Tables[0].Rows[0]["title"].ToString();
                model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                if (ds.Tables[0].Rows[0]["type"].ToString() != "")
                {
                    model.type = int.Parse(ds.Tables[0].Rows[0]["type"].ToString());
                }
                model.default_value = ds.Tables[0].Rows[0]["default_value"].ToString();
                if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
        private bool DoEdit(int _id)
        {
            bool result = true;

            DTcms.BLL.photo_attribute   bll   = new BLL.photo_attribute();
            DTcms.Model.photo_attribute model = bll.GetModel(_id);
            model.title         = txtTitle.Text.Trim();
            model.remark        = txtRemark.Text.Trim();
            model.type          = int.Parse(ddlType.SelectedValue);
            model.default_value = txtDefaultValue.Text.Trim();
            model.sort_id       = int.Parse(txtSortId.Text.Trim());
            if (!bll.Update(model))
            {
                result = false;
            }

            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DTcms.Model.photo_attribute model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dt_photo_attribute set ");
            strSql.Append("channel_id=@channel_id,");
            strSql.Append("title=@title,");
            strSql.Append("remark=@remark,");
            strSql.Append("type=@type,");
            strSql.Append("default_value=@default_value,");
            strSql.Append("sort_id=@sort_id,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",            SqlDbType.Int,        4),
                new SqlParameter("@channel_id",    SqlDbType.Int,        4),
                new SqlParameter("@title",         SqlDbType.NVarChar, 100),
                new SqlParameter("@remark",        SqlDbType.NVarChar, 500),
                new SqlParameter("@type",          SqlDbType.Int,        4),
                new SqlParameter("@default_value", SqlDbType.NVarChar, 500),
                new SqlParameter("@sort_id",       SqlDbType.Int,        4),
                new SqlParameter("@add_time",      SqlDbType.DateTime)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.channel_id;
            parameters[2].Value = model.title;
            parameters[3].Value = model.remark;
            parameters[4].Value = model.type;
            parameters[5].Value = model.default_value;
            parameters[6].Value = model.sort_id;
            parameters[7].Value = model.add_time;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DTcms.Model.photo_attribute model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dt_photo_attribute(");
            strSql.Append("channel_id,title,remark,type,default_value,sort_id,add_time)");
            strSql.Append(" values (");
            strSql.Append("@channel_id,@title,@remark,@type,@default_value,@sort_id,@add_time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@channel_id",    SqlDbType.Int,        4),
                new SqlParameter("@title",         SqlDbType.NVarChar, 100),
                new SqlParameter("@remark",        SqlDbType.NVarChar, 500),
                new SqlParameter("@type",          SqlDbType.Int,        4),
                new SqlParameter("@default_value", SqlDbType.NVarChar, 500),
                new SqlParameter("@sort_id",       SqlDbType.Int,        4),
                new SqlParameter("@add_time",      SqlDbType.DateTime)
            };
            parameters[0].Value = model.channel_id;
            parameters[1].Value = model.title;
            parameters[2].Value = model.remark;
            parameters[3].Value = model.type;
            parameters[4].Value = model.default_value;
            parameters[5].Value = model.sort_id;
            parameters[6].Value = model.add_time;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public DTcms.Model.photo_attribute GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,channel_id,title,remark,type,default_value,sort_id,add_time from dt_photo_attribute ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            DTcms.Model.photo_attribute model = new DTcms.Model.photo_attribute();
            DataSet ds = DbHelperSQL.Query(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());
                }
                if (ds.Tables[0].Rows[0]["channel_id"].ToString() != "")
                {
                    model.channel_id = int.Parse(ds.Tables[0].Rows[0]["channel_id"].ToString());
                }
                model.title = ds.Tables[0].Rows[0]["title"].ToString();
                model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                if (ds.Tables[0].Rows[0]["type"].ToString() != "")
                {
                    model.type = int.Parse(ds.Tables[0].Rows[0]["type"].ToString());
                }
                model.default_value = ds.Tables[0].Rows[0]["default_value"].ToString();
                if (ds.Tables[0].Rows[0]["sort_id"].ToString() != "")
                {
                    model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }