当前位置: 首页>>代码示例>>C#>>正文


C# Category.Save方法代码示例

本文整理汇总了C#中Category.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Category.Save方法的具体用法?C# Category.Save怎么用?C# Category.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Category的用法示例。


在下文中一共展示了Category.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditCategory_Click

    protected void EditCategory_Click(object sender, EventArgs e)
    {
        try
            {
                Category c = new Category(Request.QueryString["id"]);
                c.Name = Server.HtmlEncode(txtExistingCategory.Text.Trim());
                c.FormattedName = txtExistingLinkName.Text.Trim();
                c.Body = Editor.Text;
                c.FeedUrlOverride = txtFeedBurner.Text;
                c.MetaDescription = Server.HtmlEncode(txtMetaScription.Text.Trim());
                c.MetaKeywords = Server.HtmlEncode(txtKeywords.Text.Trim());
                c.SortOrder = (SortOrderType)Enum.Parse(typeof(SortOrderType), SortOrder.SelectedValue, true);
                c.Save();

                Response.Redirect("~/graffiti-admin/categories/?upd=" + c.Name);
            }
            catch (Exception ex)
            {
                string exMessage = ex.Message;
                if (!string.IsNullOrEmpty(exMessage) && exMessage.IndexOf("UNIQUE") > -1)
                    exMessage = "This category already exists";

                Message.Text = "A category with the name of " + txtExistingCategory.Text + " could not be created <br />" +
                               exMessage;
                Message.Type = StatusType.Error;
            }
    }
开发者ID:chartek,项目名称:graffiticms,代码行数:27,代码来源:Default.aspx.cs

示例2: btnSave_Click

    protected void btnSave_Click(object sender, EventArgs e)
    {
        try
        {
            Category objCategory        = new Category();
            objCategory.CategoryId      = Int32.Parse(hdnCategory.Value.Trim());
            objCategory.CategoryType    = txtCatType.Text.Trim();
            objCategory.CategoryDesc    = txtDescription.Text.Trim();

            if (!(new CategoryDAO()).IsCategoryExists(txtCatType.Text.Trim()))
            {
                if (objCategory.Save())
                {
                    lblError.Visible    = true;
                    lblError.Text       = Constant.MSG_Save_SavedSeccessfully;
                }
            }
            else
            {
                lblError.Visible        = true;
                lblError.Text           = Constant.Error_Category_Exists;
            }
        }
        catch (Exception ex)
        {
            ex.Data.Add("UILayerException", this.GetType().ToString() + Constant.Error_Seperator + "protected void btnSave_Click(object sender, EventArgs e)");
            if (Master.LoggedUser != null && Master.LoggedUser.UserName != null && Master.LoggedUser.UserName != string.Empty)
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, Master.LoggedUser.UserName), false);
            else
                Response.Redirect("Error.aspx?LogId=" + LankaTilesExceptions.WriteEventLogs(ex, Constant.Database_Connection_Name, "Annonimous"), false);

        }
    }
开发者ID:nirshandileep,项目名称:WebZent,代码行数:33,代码来源:AddCategory.aspx.cs

示例3: btnAdd_Click

 /// <summary>
 /// Handles the Click event of the btnAdd control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         Category cat = new Category(txtNewCategory.Text, txtNewNewDescription.Text);
         cat.Save();
         Response.Redirect(Request.RawUrl, true);
     }
 }
开发者ID:chandru9279,项目名称:StarBase,代码行数:14,代码来源:Categories.aspx.cs

示例4: AddCategory

		public void AddCategory(Category category)
		{
			if (category == null)
			{
				throw new ArgumentNullException("category");
			}

			category.Save();
		}
开发者ID:agross,项目名称:graffiti-usergroups,代码行数:9,代码来源:CategoryRepository.cs

示例5: AddButton_Click

    protected void AddButton_Click(object obj, EventArgs args)
    {
        if (Page.IsValid == false)
            return;

        if (CurrentProject != null)
        {
            bool wasCategorySave = false;

            Category newCategory = new Category(Abbrev.Text, Convert.ToDecimal(CatDuration.Text), CategoryName.Text, CurrentProject.Id);
            wasCategorySave = newCategory.Save();
            ListAllCategories.DataBind();
        }
    }
开发者ID:MIS499,项目名称:TimeReporting,代码行数:14,代码来源:Project_Details.aspx.cs

示例6: btnSaveSEO_Click

 protected void btnSaveSEO_Click(object sender, EventArgs e)
 {
     Category cat = new Category();
     if (cat.LoadByPrimaryKey(CategoryID))
     {
         cat.s_Keywords = tbKeywords.Text;
         cat.s_Keywords_pl = tbKeywords_pl.Text;
         cat.s_Keywords_en = tbKeywords_en.Text;
         cat.s_Description = tbDescription.Text;
         cat.s_Description_pl = tbDescription_pl.Text;
         cat.s_Description_en = tbDescription_en.Text;
         cat.Save();
     }
     RedirectBackToList();
 }
开发者ID:ivladyka,项目名称:Ekran,代码行数:15,代码来源:CategoryEdit.ascx.cs

示例7: btnAdd_Click

        /// <summary>
        /// Handles the Click event of the btnAdd control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void btnAdd_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string description = txtNewNewDescription.Text;
                if (description.Length > 255)
                    description = description.Substring(0, 255);

                Category cat = new Category(txtNewCategory.Text, description);
                if (ddlNewParent.SelectedValue != "0")
                    cat.Parent = new Guid(ddlNewParent.SelectedValue);

                cat.Save();
                Response.Redirect(Request.RawUrl, true);
            }
        }
开发者ID:aldrinmg,项目名称:SadPanda-1,代码行数:21,代码来源:Categories.aspx.cs

示例8: CopyButton_Click

    protected void CopyButton_Click(object obj, EventArgs args)
    {
        if (CurrentProject != null)
        {
            int selectedProjectId = Convert.ToInt32(ProjectList.SelectedValue);

            List<Category> newCategories = Category.GetCategoriesByProjectId(selectedProjectId);

            foreach (Category cat in newCategories)
            {
                Category newCat = new Category(cat.Abbreviation, cat.EstimateDuration, cat.Name, CurrentProject.Id);
                newCat.Save();
            }
            CategoryData.DataBind();
            ListAllCategories.DataBind();
        }
    }
开发者ID:MIS499,项目名称:TimeReporting,代码行数:17,代码来源:Project_Details.aspx.cs

示例9: HomeModule

 public HomeModule()
 {
     Get["/"] = _ => {
     List<Category> AllCategories = Category.GetAll();
     return View["index.cshtml", AllCategories];
       };
       Get["/tasks"] = _ => {
     List<Task> AllTasks = Task.GetAll();
     return View["tasks.cshtml", AllTasks];
       };
       Get["/categories"] = _ => {
     List<Category> AllCategories = Category.GetAll();
     return View["categories.cshtml", AllCategories];
       };
       Get["/categories/new"] = _ => {
     return View["categories_form.cshtml"];
       };
       Post["/categories/new"] = _ => {
     Category newCategory = new Category(Request.Form["category-name"]);
     newCategory.Save();
     return View["success.cshtml"];
       };
       Get["/tasks/new"] = _ => {
     List<Category> AllCategories = Category.GetAll();
     return View["tasks_form.cshtml", AllCategories];
       };
       Post["/tasks/new"] = _ => {
     Task newTask = new Task(Request.Form["task-description"], Request.Form["task-due-date"], Request.Form["category-id"]);
     newTask.Save();
     return View["success.cshtml"];
       };
       Post["/tasks/delete"] = _ => {
     Task.DeleteAll();
     return View["cleared.cshtml"];
       };
       Get["/categories/{id}"] = parameters => {
     Dictionary<string, object> model = new Dictionary<string, object>();
     var SelectedCategory = Category.Find(parameters.id);
     var CategoryTasks = SelectedCategory.GetTasks();
     model.Add("category", SelectedCategory);
     model.Add("tasks", CategoryTasks);
     return View["category.cshtml", model];
       };
 }
开发者ID:CharlesEwel,项目名称:csharpweektwoweekthreeweekendhw,代码行数:44,代码来源:HomeModule.cs

示例10: uiButtonUpdate_Click

        protected void uiButtonUpdate_Click(object sender, EventArgs e)
        {
            Category cat = new Category();
            if (CurrentCategory != null)
            {
                cat = CurrentCategory;
            }
            else
            {
                cat.AddNew();
            }

            cat.Name = uiTextBoxName.Text;
            cat.Save();
            uiPanelEdit.Visible = false;
            uiPanelViewCats.Visible = true;
            Clearfields();
            BindData();
            CurrentCategory = null;
        }
开发者ID:menasbeshay,项目名称:ivalley-svn,代码行数:20,代码来源:EditCategories.aspx.cs

示例11: btnAdd_Click

 /// <summary>
 /// Add a new category into the database
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (txtName.Text.Length > 0 && txtURLRewrite.Text.Length > 0)
     {
         Category newCat = new Category();
         newCat.CatName = txtName.Text;
         newCat.URLRewrite = txtURLRewrite.Text;
         newCat.Lang = 1;
         if (ddlParentCat.SelectedItem.Value == "NULL")
         {
             newCat.Parent = null;
         }
         else
         {
             newCat.Parent = ubConvert.ToInt(ddlParentCat.SelectedItem.Value);
         }
         newCat.Save();
         txtName.Text = "";
         txtURLRewrite.Text = "";
         GenerateCatList();
     }
 }
开发者ID:hieuuk,项目名称:pingpoong,代码行数:27,代码来源:CatManagement.aspx.cs

示例12: CreateCategory_Click

    protected void CreateCategory_Click(object sender, EventArgs e)
    {
        try
            {
                Category c = new Category();
                c.Name = Server.HtmlEncode(txtCategory.Text.Trim());
                c.ParentId = Int32.Parse(Parent_Categories.SelectedValue);

                c.Save();
                Response.Redirect("~/graffiti-admin/categories/?id=" + c.Id + "&new=true");

            }
            catch (Exception ex)
            {
                string exMessage = ex.Message;
                if (!string.IsNullOrEmpty(exMessage) && exMessage.IndexOf("UNIQUE") > -1)
                    exMessage = "This category already exists";

                Message.Text = "A category with the name of " + txtCategory.Text + " could not be created <br />" +
                               exMessage;
                Message.Type = StatusType.Error;
            }
    }
开发者ID:chartek,项目名称:graffiticms,代码行数:23,代码来源:Default.aspx.cs

示例13: Main

        static void Main()
        {
            ConvertUtilities.SetCurrentThreadCulture("en-US");
            Category category = new Category();
            category.Name = "EN: High-Tech";
            category.Save();
            Category.SaveLocalizedValues(category, 1036, false, "FR: High-Tech");

            Product product = new Product();
            product.Name = "Phone";
            product.Category = category;
            product.Save();

            Console.WriteLine(Product.LoadById(product.Id).Name);
            Console.WriteLine(Product.LoadById(product.Id).Name);

            ConvertUtilities.SetCurrentThreadCulture(1036);
            Console.WriteLine(Category.Load(category.Id).Name);
            Console.WriteLine(Category.Load(category.Id).Name);
            ConvertUtilities.SetCurrentThreadCulture(1033);
            Console.WriteLine(Category.Load(category.Id).Name);
            Console.WriteLine(Category.Load(category.Id).Name);
        }
开发者ID:modulexcite,项目名称:CodeFluent-Entities,代码行数:23,代码来源:Program.cs

示例14: EditPost

        /// <summary>
        /// metaWeblog.editPost method
        /// </summary>
        /// <param name="postId">
        /// post guid in string format
        /// </param>
        /// <param name="userName">
        /// login username
        /// </param>
        /// <param name="password">
        /// login password
        /// </param>
        /// <param name="sentPost">
        /// struct with post details
        /// </param>
        /// <param name="publish">
        /// mark as published?
        /// </param>
        /// <returns>
        /// 1 if successful
        /// </returns>
        internal bool EditPost(string postId, string userName, string password, MWAPost sentPost, bool publish)
        {
            var post = Post.GetPost(new Guid(postId));

            if (!post.CanUserEdit)
            {
                throw new MetaWeblogException("11", "User authentication failed");
            }

            string author = String.IsNullOrEmpty(sentPost.author) ? userName : sentPost.author;

            if (!post.IsPublished && publish)
            {
                if (!post.CanPublish(author))
                {
                    throw new MetaWeblogException("11", "Not authorized to publish this Post.");
                }
            }

            post.Author = author;
            post.Title = sentPost.title;
            post.Content = sentPost.description;
            post.IsPublished = publish;
            post.Slug = sentPost.slug;
            post.Description = sentPost.excerpt;

            if (sentPost.commentPolicy != string.Empty)
            {
                post.HasCommentsEnabled = sentPost.commentPolicy == "1";
            }

            post.Categories.Clear();
            foreach (var item in sentPost.categories.Where(c => c != null && c.Trim() != string.Empty))
            {
                Category cat;
                if (LookupCategoryGuidByName(item, out cat))
                {
                    post.Categories.Add(cat);
                }
                else
                {
                    // Allowing new categories to be added.  (This breaks spec, but is supported via WLW)
                    using (var newcat = new Category(item, string.Empty))
                    {
                        newcat.Save();
                        post.Categories.Add(newcat);
                    }
                }
            }

            post.Tags.Clear();
            foreach (var item in sentPost.tags.Where(item => item != null && item.Trim() != string.Empty))
            {
                post.Tags.Add(item);
            }

            if (sentPost.postDate != new DateTime())
            {
                post.DateCreated = sentPost.postDate.AddHours(-BlogSettings.Instance.Timezone);
            }

            post.Save();

            return true;
        }
开发者ID:doct15,项目名称:blogengine,代码行数:86,代码来源:MetaWeblogHandler.cs

示例15: publish_return_click

    protected void publish_return_click(object sender, EventArgs e)
    {
        try
        {
            if (!IsValid)
                return;

            IGraffitiUser user = GraffitiUsers.Current;

            ListItem catItem = CategoryList.SelectedItem;
            if (catItem.Value == "-1" && String.IsNullOrEmpty(newCategory.Text))
            {
                SetMessage("Please enter a name for the new Category.", StatusType.Error);
                return;
            }

            string extenedBody = txtContent_extend.Text;
            string postBody = txtContent.Text;

            if (string.IsNullOrEmpty(postBody))
            {
                SetMessage("Please enter a post body.", StatusType.Warning);
                return;
            }

            Category c = new Category();

            if (catItem.Value == "-1")
            {
                try
                {
                    Category temp = new Category();
                    temp.Name = newCategory.Text;
                    temp.Save();

                    c = temp;

                    CategoryController.Reset();
                }
                catch (Exception ex)
                {
                    SetMessage("The category could not be created. Reason: " + ex.Message, StatusType.Error);
                }
            }
            else
            {
                c = new CategoryController().GetCachedCategory(Int32.Parse(catItem.Value), false);
            }

            string pid = Request.QueryString["id"];
            Post p = pid == null ? new Post() : new Post(pid);

            if (p.IsNew)
            {
                p["where"] = "web";

                p.UserName = user.Name;

                if (Request.Form["dateChangeFlag"] == "true")
                    p.Published = PublishDate.DateTime;
                else
                    p.Published = DateTime.Now.AddHours(SiteSettings.Get().TimeZoneOffSet);
            }
            else
            {
                p.Published = PublishDate.DateTime;
            }

            p.ModifiedOn = DateTime.Now.AddHours(SiteSettings.Get().TimeZoneOffSet);

            p.PostBody = postBody;
            if (string.IsNullOrEmpty(extenedBody) || extenedBody == "<p></p>" || extenedBody == "<p>&nbsp;</p>" || extenedBody == "<br />\r\n")
            {
                p.ExtendedBody = null;
            }
            else
            {
                p.ExtendedBody = extenedBody;
            }

            p.Title = Server.HtmlEncode(txtTitle.Text);
            p.EnableComments = EnableComments.Checked;
            p.Name = txtName.Text;
            p.TagList = txtTags.Text.Trim();
            p.ContentType = "text/html";
            p.CategoryId = c.Id;
            p.Notes = txtNotes.Text;
            p.ImageUrl = postImage.Text;
            p.MetaKeywords = Server.HtmlEncode(txtKeywords.Text.Trim());
            p.MetaDescription = Server.HtmlEncode(txtMetaScription.Text.Trim());
            p.IsHome = HomeSortOverride.Checked;
            p.PostStatus = (PostStatus)Enum.Parse(typeof(PostStatus), Request.Form[PublishStatus.UniqueID]);

            CustomFormSettings cfs = CustomFormSettings.Get(c);
            if (cfs.HasFields)
            {
                foreach (CustomField cf in cfs.Fields)
                {
                    if (cf.FieldType == FieldType.CheckBox && Request.Form[cf.Id.ToString()] == null)
                        p[cf.Name] = null; // false.ToString();
//.........这里部分代码省略.........
开发者ID:chartek,项目名称:graffiticms,代码行数:101,代码来源:Default.aspx.cs


注:本文中的Category.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。