/// <summary> /// 组合成对象实体 /// </summary> /// <param name="row">一行数据</param> /// <returns>Model.plugin_menu_class</returns> private Model.plugin_menu_class DataRowToModel(DataRow row) { Model.plugin_menu_class model = new Model.plugin_menu_class(); if (row != null) { if (null != row["id"] && "" != row["id"].ToString()) { model.id = int.Parse(row["id"].ToString()); } if (null != row["title"]) { model.title = row["title"].ToString(); } if (null != row["is_lock"] && "" != row["is_lock"].ToString()) { model.is_lock = int.Parse(row["is_lock"].ToString()); } if (null != row["sort_id"] && "" != row["sort_id"].ToString()) { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (null != row["is_sys"] && "" != row["is_sys"].ToString()) { model.is_sys = int.Parse(row["is_sys"].ToString()); } if (null != row["color"]) { model.color = row["color"].ToString(); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.plugin_menu_class</param> /// <returns>True or False</returns> public bool Update(Model.plugin_menu_class model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [" + databaseprefix + "plugin_menu_class] set "); strSql.Append("title=@title,"); strSql.Append("is_lock=@is_lock,"); strSql.Append("sort_id=@sort_id,"); strSql.Append("is_sys=@is_sys,"); strSql.Append("color=@color"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@is_sys", SqlDbType.TinyInt, 1), new SqlParameter("@color", SqlDbType.NVarChar, 20), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.title; parameters[1].Value = model.is_lock; parameters[2].Value = model.sort_id; parameters[3].Value = model.is_sys; parameters[4].Value = model.color; parameters[5].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } return(false); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.plugin_menu_class</param> /// <returns>ID</returns> public int Add(Model.plugin_menu_class model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [" + databaseprefix + "plugin_menu_class]("); strSql.Append("title,is_lock,sort_id,is_sys,color"); strSql.Append(") values("); strSql.Append("@title,@is_lock,@sort_id,@is_sys,@color)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@is_sys", SqlDbType.TinyInt, 1), new SqlParameter("@color", SqlDbType.NVarChar, 20) }; parameters[0].Value = model.title; parameters[1].Value = model.is_lock; parameters[2].Value = model.sort_id; parameters[3].Value = model.is_sys; parameters[4].Value = model.color; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (null != obj) { return(Convert.ToInt32(obj)); } else { return(0); } }
private void ShowInfo(int _id) { BLL.plugin_menu_class bll = new BLL.plugin_menu_class(); Model.plugin_menu_class model = bll.GetModel(_id); txtTitle.Text = model.title; txtColor.Text = model.color; txtSort.Text = model.sort_id.ToString(); rblHide.SelectedValue = model.is_lock.ToString(); }
private bool DoAdd() { BLL.plugin_menu_class bll = new BLL.plugin_menu_class(); Model.plugin_menu_class model = new Model.plugin_menu_class(); model.title = txtTitle.Text; model.color = txtColor.Text; model.is_lock = Utils.StrToInt(rblHide.SelectedValue, 0); model.sort_id = Utils.StrToInt(txtSort.Text.Trim(), 99); if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "添加菜单类别内容:" + model.title); //记录日志 return(true); } return(false); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model">Model.plugin_menu_class</param> /// <returns>True Or False</returns> public bool Update(Model.plugin_menu_class model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="model">Model.plugin_menu_class</param> /// <returns>ID</returns> public int Add(Model.plugin_menu_class model) { return(dal.Add(model)); }