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


C# Calendar.Save方法代码示例

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


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

示例1: MoveCalendar

        /// <summary>
        /// Moves the calendar.
        /// </summary>
        /// <param name="calendar">The calendar.</param>
        /// <param name="newFolder">The new folder.</param>
        public static void MoveCalendar(Calendar calendar, CalendarFolder newFolder)
        {
            if (calendar == null)
                throw new ArgumentNullException("calendar");
            if (newFolder == null)
                throw new ArgumentNullException("newFolder");

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Raise Calendar Moving
                RaiseEvent(CalendarMoving, calendar, EventArgs.Empty);

                calendar.CalendarFolderId = newFolder.PrimaryKeyId.Value;
                calendar.Owner = newFolder.Owner;

                calendar.Save();

                RaiseEvent(CalendarMoved, calendar, EventArgs.Empty);

                tran.Commit();
            }
        }
开发者ID:0anion0,项目名称:IBN,代码行数:27,代码来源:CalendarFolderManager.cs

示例2: CreateCalendar

        /// <summary>
        /// Creates the calendar.
        /// </summary>
        /// <param name="folder">The folder.</param>
        /// <param name="name">The name.</param>
        /// <param name="ownerId">The owner id.</param>
        /// <returns></returns>
        public static CalendarInfo CreateCalendar(CalendarFolder folder, string name, int? ownerId)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (folder == null)
                throw new ArgumentNullException("folder");
            if (!folder.GetTreeService().CurrentNode.IsAttached)
                throw new ArgumentException("The folder is dettached from tree.", "folder");

            Calendar newItem = null;

            using (TransactionScope tran = DataContext.Current.BeginTransaction())
            {
                // Step 1. Create New Calendar
                newItem = new Calendar();
                newItem.CalendarFolderId = folder.PrimaryKeyId.Value;
                newItem.Title = name;
                newItem.Owner = ownerId;

                // Raise List Creating Event
                RaiseEvent(CalendarCreating, newItem, EventArgs.Empty);

                // Add additional parameters
                newItem.Save();

                // Raise List Created Event
                RaiseEvent(CalendarCreated, newItem, EventArgs.Empty);

                // Step. Commit Transaction Return new list info
                tran.Commit();
             }

             return new CalendarInfo(newItem, null);
        }
开发者ID:0anion0,项目名称:IBN,代码行数:41,代码来源:CalendarFolderManager.cs


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