//赋值操作 private void ShowInfo(int _id) { BLL.plugin_lable bll = new BLL.plugin_lable(); Model.plugin_lable model = bll.GetModel(_id); txtTitle.Text = model.title; txtName.Text = model.call_index; txtName.Attributes.Add("ajaxurl", "../tools/ajax.ashx?action=validate&old_name=" + Utils.UrlEncode(model.call_index)); txtName.Focus(); txtSort.Text = model.sort_id.ToString(); rblHide.SelectedValue = model.is_lock.ToString(); ddlType.SelectedValue = model.type.ToString(); txtContent.Value = model.content; contentType = model.type; }
//修改操作 private bool DoEdit(int _id) { BLL.plugin_lable bll = new BLL.plugin_lable(); Model.plugin_lable model = bll.GetModel(_id); model.title = txtTitle.Text; model.call_index = txtName.Text; model.is_lock = int.Parse(rblHide.SelectedValue); model.sort_id = int.Parse(txtSort.Text); model.type = int.Parse(ddlType.SelectedValue); model.content = txtContent.Value; if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改标签内容:" + model.title); return(true); } return(false); }
/// <summary> /// 组合成对象实体 /// </summary> /// <param name="row">一行数据</param> /// <returns>Model.plugin_lable</returns> private Model.plugin_lable DataRowToModel(DataRow row) { Model.plugin_lable model = new Model.plugin_lable(); if (row != null) { if (null != row["id"] && "" != row["id"].ToString()) { model.id = int.Parse(row["id"].ToString()); } if (null != row["call_index"]) { model.call_index = row["call_index"].ToString(); } if (null != row["title"]) { model.title = row["title"].ToString(); } if (null != row["type"] && "" != row["type"].ToString()) { model.type = int.Parse(row["type"].ToString()); } if (null != row["sort_id"] && "" != row["sort_id"].ToString()) { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (null != row["content"]) { model.content = row["content"].ToString(); } if (null != row["user_name"]) { model.user_name = row["user_name"].ToString(); } if (null != row["is_lock"] && "" != row["is_lock"].ToString()) { model.is_lock = int.Parse(row["is_lock"].ToString()); } if (null != row["add_time"] && "" != row["add_time"].ToString()) { model.add_time = DateTime.Parse(row["add_time"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.plugin_lable</param> /// <returns>True or False</returns> public bool Update(Model.plugin_lable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [" + databaseprefix + "plugin_lable] set "); strSql.Append("call_index=@call_index,"); strSql.Append("title=@title,"); strSql.Append("type=@type,"); strSql.Append("sort_id=@sort_id,"); strSql.Append("content=@content,"); strSql.Append("user_name=@user_name,"); strSql.Append("is_lock=@is_lock,"); strSql.Append("add_time=@add_time"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@call_index", SqlDbType.NVarChar, 50), new SqlParameter("@title", SqlDbType.NVarChar, 255), new SqlParameter("@type", SqlDbType.TinyInt, 1), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@user_name", SqlDbType.NVarChar, 100), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.call_index; parameters[1].Value = model.title; parameters[2].Value = model.type; parameters[3].Value = model.sort_id; parameters[4].Value = model.content; parameters[5].Value = model.user_name; parameters[6].Value = model.is_lock; parameters[7].Value = model.add_time; parameters[8].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } return(false); }
//增加操作 private bool DoAdd() { BLL.plugin_lable bll = new BLL.plugin_lable(); Model.plugin_lable model = new Model.plugin_lable(); model.title = txtTitle.Text; model.call_index = txtName.Text; model.is_lock = int.Parse(rblHide.SelectedValue); model.sort_id = int.Parse(txtSort.Text); model.type = Utils.StrToInt(ddlType.SelectedValue, 0); model.content = txtContent.Value; model.add_time = DateTime.Now; Model.manager adminModel = GetAdminInfo(); model.user_name = adminModel.real_name; if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "添加标签内容:" + model.title); return(true); } return(false); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.plugin_lable</param> /// <returns>ID</returns> public int Add(Model.plugin_lable model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [" + databaseprefix + "plugin_lable]("); strSql.Append("call_index,title,type,sort_id,content,user_name,is_lock,add_time"); strSql.Append(") values("); strSql.Append("@call_index,@title,@type,@sort_id,@content,@user_name,@is_lock,@add_time)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@call_index", SqlDbType.NVarChar, 50), new SqlParameter("@title", SqlDbType.NVarChar, 255), new SqlParameter("@type", SqlDbType.TinyInt, 1), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@user_name", SqlDbType.NVarChar, 100), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@add_time", SqlDbType.DateTime) }; parameters[0].Value = model.call_index; parameters[1].Value = model.title; parameters[2].Value = model.type; parameters[3].Value = model.sort_id; parameters[4].Value = model.content; parameters[5].Value = model.user_name; parameters[6].Value = model.is_lock; parameters[7].Value = model.add_time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (null != obj) { return(Convert.ToInt32(obj)); } else { return(0); } }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.plugin_lable</param> /// <returns>True Or False</returns> public bool Update(Model.plugin_lable model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.plugin_lable</param> /// <returns>ID</returns> public int Add(Model.plugin_lable model) { return(dal.Add(model)); }