/// <summary> /// 保存 /// </summary> /// <param name="artCategory"></param> /// <returns></returns> public String Save(ArtCategory artCategory) { if (string.IsNullOrEmpty(artCategory.CatId)) { return(Add(artCategory)); } else { return(Update(artCategory)); } }
/// <summary> /// 修改文章类型表 /// </summary> /// <param name="index">文章类型表对象</param> /// <returns></returns> public int Update(ArtCategory index) { string sql = "update Art_Category set Cat_Id=@Cat_Id,Cat_Name=@Cat_Name,Cat_Remark=@Cat_Remark,Cat_Order=@Cat_Order,Create_By=@Create_By,Create_Time=@Create_Time,UpDate_By=@UpDate_By,UpDate_Time=@UpDate_Time where Cat_Id=@Cat_Id"; SQLiteParameter[] parm = new SQLiteParameter[] { new SQLiteParameter("@Cat_Id", index.CatId), new SQLiteParameter("@Cat_Name", index.CatName), new SQLiteParameter("@Cat_Remark", index.CatRemark), new SQLiteParameter("@Cat_Order", index.CatOrder), new SQLiteParameter("@Create_By", index.CreateBy), new SQLiteParameter("@Create_Time", index.CreateTime), new SQLiteParameter("@UpDate_By", index.UpdateBy), new SQLiteParameter("@UpDate_Time", index.UpdateTime) }; return(SqlLiteHelper.ExecuteNonQuery(sql, CommandType.Text, parm)); }
/// <summary> /// 增加文章类型表 /// </summary> /// <param name="index">文章类型表对象</param> /// <returns></returns> public int Add(ArtCategory index) { string sql = string.Format("insert into Art_Category(Cat_Id,Cat_Name,Cat_Remark,Cat_Order,Create_By,Create_Time,UpDate_By,UpDate_Time) values(@Cat_Id,@Cat_Name,@Cat_Remark,@Cat_Order,@Create_By,@Create_Time,@UpDate_By,@UpDate_Time)"); SQLiteParameter[] parm = new SQLiteParameter[] { new SQLiteParameter("@Cat_Id", index.CatId), new SQLiteParameter("@Cat_Name", index.CatName), new SQLiteParameter("@Cat_Remark", index.CatRemark), new SQLiteParameter("@Cat_Order", index.CatOrder), new SQLiteParameter("@Create_By", index.CreateBy), new SQLiteParameter("@Create_Time", index.CreateTime), new SQLiteParameter("@UpDate_By", index.UpdateBy), new SQLiteParameter("@UpDate_Time", index.UpdateTime) }; return(SqlLiteHelper.ExecuteNonQuery(sql, CommandType.Text, parm)); }
public ActionResult AddArtCategory(ArtCategory cat) { if (ModelState.IsValid) { db.ArtCategories.Add(cat); // (Modelvar).().Add(value entered in parameters) if (db.SaveChanges() > 0) // { TempData["msg"] = "Category Created"; return(RedirectToAction("Account")); } else { return(View()); } } return(View()); }
/// <summary> /// 修改 /// </summary> /// <returns>影响的行数</returns> public int Update(ArtCategory artCategory) { return(dLArtCategory.Update(artCategory)); }
/// <summary> /// 新增 /// </summary> /// <returns>影响的行数</returns> public int Add(ArtCategory artCategory) { return(dLArtCategory.Add(artCategory)); }
public CategoryView(ArtCategory category, string iconName) { this.category = category; isOptional = category.isOptional; icon = Resources.Load <Texture>(iconName); }
/// <summary> /// 查询所有数据 /// </summary> /// <returns></returns> public List <ArtCategory> Select(HashTableExp hash, String sqlWhere) { List <ArtCategory> list = new List <ArtCategory>(); string sql = "select Cat_Id,Cat_Name,Cat_Remark,Cat_Order,Create_By,Create_Time,UpDate_By,UpDate_Time from Art_Category where 1=1 "; #region 查询条件 if (hash != null) { if (hash["CatId"] != null) { sql += string.Format(" and Cat_Id='{0}'", hash["CatId"]); } if (hash["CatName"] != null) { sql += string.Format(" and Cat_Name='{0}'", hash["CatName"]); } if (hash["CatRemark"] != null) { sql += string.Format(" and Cat_Remark='{0}'", hash["CatRemark"]); } if (hash["CatOrder"] != null) { sql += string.Format(" and Cat_Order='{0}'", hash["CatOrder"]); } if (hash["CreateBy"] != null) { sql += string.Format(" and Create_By='{0}'", hash["CreateBy"]); } if (hash["CreateTime"] != null) { sql += string.Format(" and Create_Time='{0}'", hash["CreateTime"]); } if (hash["UpdateBy"] != null) { sql += string.Format(" and UpDate_By='{0}'", hash["UpdateBy"]); } if (hash["UpdateTime"] != null) { sql += string.Format(" and UpDate_Time='{0}'", hash["UpdateTime"]); } } #endregion sql += sqlWhere + " order by Cat_Order asc"; DataTable dt = SqlLiteHelper.GetTable(sql, CommandType.Text); for (int i = 0; i < dt.Rows.Count; i++) { ArtCategory index = new ArtCategory(); index.CatId = dt.Rows[i]["Cat_Id"].GetString(); index.CatName = dt.Rows[i]["Cat_Name"].GetString(); index.CatRemark = dt.Rows[i]["Cat_Remark"].GetString(); index.CatOrder = dt.Rows[i]["Cat_Order"].GetInt32(); index.CreateBy = dt.Rows[i]["Create_By"].GetString(); index.CreateTime = dt.Rows[i]["Create_Time"].GetDateTime(); index.UpdateBy = dt.Rows[i]["UpDate_By"].GetString(); index.UpdateTime = dt.Rows[i]["UpDate_Time"].GetDateTime(); list.Add(index); } return(list); }