本文整理汇总了C#中CategoryInfo类的典型用法代码示例。如果您正苦于以下问题:C# CategoryInfo类的具体用法?C# CategoryInfo怎么用?C# CategoryInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CategoryInfo类属于命名空间,在下文中一共展示了CategoryInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CateModel
public CateModel()
{
Category = new CategoryInfo();
CateSelectItem = new List<SelectListItem>();
CateType = new List<SelectListItem>();
CateList = new List<CategoryInfo>();
}
示例2: UpdateCategory
public int UpdateCategory(CategoryInfo category)
{
CheckSlug(category);
string cmdText = @"update [loachs_terms] set
[Type][email protected],
[Name][email protected],
[Slug][email protected],
[Description][email protected],
[Displayorder][email protected],
[Count][email protected],
[CreateDate][email protected]
where [email protected]";
OleDbParameter[] prams = {
OleDbHelper.MakeInParam("@Type",OleDbType.Integer,1,(int)TermType.Category),
OleDbHelper.MakeInParam("@Name",OleDbType.VarWChar,255,category.Name),
OleDbHelper.MakeInParam("@Slug",OleDbType.VarWChar,255,category.Slug),
OleDbHelper.MakeInParam("@Description",OleDbType.VarWChar,255,category.Description),
OleDbHelper.MakeInParam("@Displayorder",OleDbType.Integer,4,category.Displayorder),
OleDbHelper.MakeInParam("@Count",OleDbType.Integer,4,category.Count),
OleDbHelper.MakeInParam("@CreateDate",OleDbType.Date,8,category.CreateDate),
OleDbHelper.MakeInParam("@termid",OleDbType.Integer,1,category.CategoryId),
};
return Convert.ToInt32(OleDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams));
}
示例3: Update
/// <summary>
/// 更新
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public static int Update(CategoryInfo model)
{
string strSQL = "UPDATE Categories SET Name = @Name,Sort = @Sort,ImageUrl = @ImageUrl,LinkUrl = @LinkUrl,Introduction = @Introduction,Alias = @Alias,TemplateType = @TemplateType,IsShowFirstChildNode = @IsShowFirstChildNode,BannerAdImageUrl = @BannerAdImageUrl,IsEnabled = @IsEnabled,IsDeleted = @IsDeleted WHERE ID = @ID";
SqlParameter[] parms = {
new SqlParameter("ParentId",SqlDbType.Int),
new SqlParameter("ParentIdList",SqlDbType.NVarChar),
new SqlParameter("Sort",SqlDbType.Int),
new SqlParameter("Name",SqlDbType.NVarChar),
new SqlParameter("ImageUrl",SqlDbType.NVarChar),
new SqlParameter("LinkUrl",SqlDbType.NVarChar),
new SqlParameter("Introduction",SqlDbType.NVarChar),
new SqlParameter("Alias",SqlDbType.NVarChar),
new SqlParameter("TemplateType",SqlDbType.Int),
new SqlParameter("IsShowFirstChildNode",SqlDbType.Int),
new SqlParameter("BannerAdImageUrl",SqlDbType.NVarChar),
new SqlParameter("IsEnabled",SqlDbType.Int),
new SqlParameter("IsDeleted",SqlDbType.Int),
new SqlParameter("Id",SqlDbType.Int),
};
parms[0].Value = model.ParentId;
parms[1].Value = model.ParentIdList;
parms[2].Value = model.Sort;
parms[3].Value = model.Name == null ? string.Empty : model.Name;
parms[4].Value = model.ImageUrl == null ? string.Empty : model.ImageUrl;
parms[5].Value = model.LinkUrl == null ? string.Empty : model.LinkUrl;
parms[6].Value = model.Introduction == null ? string.Empty : model.Introduction;
parms[7].Value = model.Alias == null ? string.Empty : model.Alias;
parms[8].Value = model.TemplateType;
parms[9].Value = model.IsShowFirstChildNode;
parms[10].Value = model.BannerAdImageUrl == null ? string.Empty : model.BannerAdImageUrl;
parms[11].Value = model.IsEnabled;
parms[12].Value = model.IsDeleted;
parms[13].Value = model.Id;
return Goodspeed.Library.Data.SQLPlus.ExecuteNonQuery(CommandType.Text,strSQL,parms);
}
示例4: UpdateCategory
public int UpdateCategory(CategoryInfo category)
{
CheckSlug(category);
string cmdText = string.Format(@"update [{0}category] set
[Type][email protected],
[ParentId][email protected],
[CateName][email protected],
[Slug][email protected],
[Description][email protected],
[SortNum][email protected],
[PostCount][email protected],
[CreateTime][email protected]
where [email protected]", ConfigHelper.Tableprefix);
OleDbParameter[] prams = {
OleDbHelper.MakeInParam("@Type",OleDbType.Integer,1,(int)CategoryType.Category),
OleDbHelper.MakeInParam("@ParentId",OleDbType.Integer,4,category.ParentId),
OleDbHelper.MakeInParam("@CateName",OleDbType.VarWChar,255,category.CateName),
OleDbHelper.MakeInParam("@Slug",OleDbType.VarWChar,255,category.Slug),
OleDbHelper.MakeInParam("@Description",OleDbType.VarWChar,255,category.Description),
OleDbHelper.MakeInParam("@SortNum",OleDbType.Integer,4,category.SortNum),
OleDbHelper.MakeInParam("@PostCount",OleDbType.Integer,4,category.PostCount),
OleDbHelper.MakeInParam("@CreateTime",OleDbType.Date,8,category.CreateTime),
OleDbHelper.MakeInParam("@categoryid",OleDbType.Integer,1,category.CategoryId),
};
return Convert.ToInt32(OleDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams));
}
示例5: Save
public JsonResult Save(CategoryInfo cat)
{
if (string.IsNullOrEmpty(cat.PageName))
{
cat.PageName = cat.CateName;
}
cat.PageName = HttpHelper.HtmlEncode(StringHelper.FilterPageName(cat.PageName, "cate"));
if (cat.CategoryId > 0)
{
var oldcat = _categoryService.GetCategory(cat.CategoryId);
cat.CreateTime = oldcat.CreateTime;
cat.PostCount = oldcat.PostCount;
_categoryService.UpdateCategory(cat);
}
else
{
cat.CreateTime = DateTime.Now;
cat.PostCount = 0;
cat.CategoryId = _categoryService.InsertCategory(cat);
}
cat.TreeChar = _categoryService.GetCategoryTreeList().Find(c => c.CategoryId == cat.CategoryId).TreeChar;
return Json(cat, JsonRequestBehavior.AllowGet);
}
示例6: Compare
public int Compare(CategoryInfo info)
{
if (this.Equals(info)) {
return 0;
}
try {
Text[] texts = info.GetComponentsInChildren<Text>();
for (int i = 0; i < texts.Length; i++) {
if (texts[i].name.Equals("Rate")) {
float otherNumber = float.Parse(texts[i].text);
float myNumber = float.Parse(this.rate.text);
//There's no equal or approximate relations. Being thorough here.
if (myNumber < otherNumber) {
//Other number is larger, so we are smaller in comparison.
return -1;
}
else if (myNumber > otherNumber) {
//Other number is smaller, so we are larger in comparison.
return 1;
}
break;
}
}
}
catch (System.Exception e) {
Debug.LogError("Error parsing data from Category Info: " + e.ToString());
}
return -1;
}
示例7: InsertCategory
/// <summary>
/// 添加分类
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
public int InsertCategory(CategoryInfo category)
{
CheckSlug(category);
string cmdText = @"insert into [loachs_terms]
(
[Type],[Name],[Slug],[Description],[Displayorder],[Count],[CreateDate]
)
values
(
@Type,@Name,@Slug,@Description,@Displayorder,@Count,@CreateDate
)";
OleDbParameter[] prams = {
OleDbHelper.MakeInParam("@Type",OleDbType.Integer,1,(int)TermType.Category),
OleDbHelper.MakeInParam("@Name",OleDbType.VarWChar,255,category.Name),
OleDbHelper.MakeInParam("@Slug",OleDbType.VarWChar,255,category.Slug),
OleDbHelper.MakeInParam("@Description",OleDbType.VarWChar,255,category.Description),
OleDbHelper.MakeInParam("@Displayorder",OleDbType.Integer,4,category.Displayorder),
OleDbHelper.MakeInParam("@Count",OleDbType.Integer,4,category.Count),
OleDbHelper.MakeInParam("@CreateDate",OleDbType.Date,8,category.CreateDate)
};
OleDbHelper.ExecuteScalar(CommandType.Text, cmdText, prams);
int newId = Convert.ToInt32(OleDbHelper.ExecuteScalar("select top 1 [termid] from [loachs_terms] order by [termid] desc"));
return newId;
}
示例8: Update
/// <summary>
/// 更新数据
/// </summary>
/// <param name="mod">CategoryInfo</param>
/// <returns>受影响行数</returns>
public int Update(CategoryInfo mod)
{
using (DbConnection conn = db.CreateConnection())
{
conn.Open();
using (DbTransaction tran = conn.BeginTransaction())
{
try
{
using (DbCommand cmd = db.GetStoredProcCommand("SP_Category_Update"))
{
db.AddInParameter(cmd, "@CategoryID", DbType.Int32, mod.CategoryID);
db.AddInParameter(cmd, "@CategoryName", DbType.String, mod.CategoryName);
db.AddInParameter(cmd, "@State", DbType.Int32, mod.State);
db.AddInParameter(cmd, "@IsDeleted", DbType.Int32, mod.IsDeleted);
db.AddInParameter(cmd, "@Sort", DbType.Int32, mod.Sort);
tran.Commit();
return db.ExecuteNonQuery(cmd);
}
}
catch (Exception e)
{
tran.Rollback();
throw e;
}
finally
{
conn.Close();
}
}
}
}
示例9: Delete
/// <summary>
/// 删除分类
/// </summary>
/// <param name="category"></param>
/// <returns></returns>
public int Delete(CategoryInfo category)
{
string cmdText = string.Format("delete from [{0}category] where [categoryid] = @categoryid", ConfigHelper.Tableprefix);
using (var conn = new DapperHelper().OpenConnection())
{
return conn.Execute(cmdText, new { categoryid = category.CategoryId });
}
}
示例10: SerializeInternal
private void SerializeInternal(CategoryInfo model, IDictionary<string, object> result)
{
result.Add("categoryid", model.CategoryID);
result.Add("categoryname", model.CategoryName);
result.Add("state", model.State);
result.Add("isdeleted", model.IsDeleted);
result.Add("sort", model.Sort);
}
示例11: CheckReadPermission
private void CheckReadPermission(CategoryInfo category)
{
if ((category != null) && (category.CategoryUserID != currentUser.UserID))
{
// Check read permission for Categories module
if (!currentUser.IsAuthorizedPerResource("CMS.Categories", "Read"))
{
RedirectToAccessDenied("CMS.Categories", "Read");
}
}
}
示例12: InsertCategory
public int InsertCategory(CategoryInfo category)
{
SqlConnection conn;
int count = 0;
using (conn = SqlHelper.CreateConntion())
{
conn.Open();
count = categoryDal.InsertCategory(category, conn);
conn.Close();
}
return count;
}
示例13: RenderLeftCategoryMenu
public ActionResult RenderLeftCategoryMenu(CategoryInfo currentCategoryInfo, CategoryInfo rootCategoryInfo,string linkFormat)
{
int rootId = rootCategoryInfo.Id;
StringBuilder sbHtml = new StringBuilder();
var allCatList = CategoryService.ListAllSubCatById(rootId).Where(p => p.IsDeleted == false && p.IsEnabled == true);
Action<IEnumerable<CategoryInfo>, int, int, StringBuilder> fb = null;
fb = (catList, parentId, level, sb) =>
{
var tempList = catList.Where(p => p.ParentId == parentId).OrderBy(p => p.Sort);
string className = parentId == rootId ? "category-menu" : "none";
sb.AppendFormat("<ul class=\"{0}\" {1}>", className, parentId == rootId ? "id=\"category_menu\"" : string.Empty);
if (tempList.Count() == 0)
{
//如果没有分类,则显示父分类名称
sbHtml.AppendFormat("<li class=\"on\"><a href=\"{1}\">{0}</a></li>", rootCategoryInfo.Name, Request.Url.AbsolutePath);
}
else
{
foreach (var item in tempList)
{
//判断是否子分类
var ishasChild = catList.Where(p => p.ParentId == item.Id).Count() > 0;
if (currentCategoryInfo != null && currentCategoryInfo.Id == item.Id)
{
sb.Append("<li class=\"on\">");
}
else
{
sb.Append("<li>");
}
sb.AppendFormat("<a href=\"{3}\" id=\"d_menu_{1}\" title=\"{0}\" class=\"{2}\">{0}</a>", item.Name, item.Id, ishasChild ? "sub-icon" : string.Empty,string.IsNullOrEmpty(linkFormat) ? item.Url : string.Format(linkFormat,item.Id));
if (ishasChild)
{
fb(catList, item.Id, level + 1, sb);
}
sb.Append("</li>");
}
}
sb.Append("</ul>");
};
fb(allCatList, rootId, 0, sbHtml);
return Content(sbHtml.ToString());
}
示例14: Create
/// <summary>
/// 添加或更新分类信息
/// </summary>
/// <param name="model"></param>
/// <returns>主键ID</returns>
public static int Create(CategoryInfo model)
{
if (model.Id == 0)
{
//Insert
int i = CategoryManage.Insert(model);
model.Id = i;
}
else
{
//Update
CategoryManage.Update(model);
}
return model.Id;
}
示例15: btnEdit_Click
/// <summary>
/// 编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnEdit_Click(object sender, EventArgs e)
{
CategoryInfo term = new CategoryInfo();
if (Operate == OperateType.Update)
{
term = CategoryManager.GetCategory(categoryId);
}
else
{
term.CreateDate = DateTime.Now;
term.Count = 0;
}
term.Name = StringHelper.HtmlEncode(txtName.Text);
term.Slug = txtSlug.Text.Trim();
if (string.IsNullOrEmpty(term.Slug))
{
term.Slug = term.Name;
}
term.Slug = StringHelper.HtmlEncode(PageUtils.FilterSlug(term.Slug, "cate"));
term.Description = StringHelper.HtmlEncode(txtDescription.Text);
term.Displayorder = StringHelper.StrToInt(txtDisplayOrder.Text, 1000);
if (term.Name == "")
{
ShowError("请输入名称!");
return;
}
if (Operate == OperateType.Update)
{
CategoryManager.UpdateCategory(term);
Response.Redirect("categorylist.aspx?result=2");
}
else
{
CategoryManager.InsertCategory(term);
Response.Redirect("categorylist.aspx?result=1");
}
}