Exemplo n.º 1
0
        /// <summary>
        /// The	DeleteBtn_Click	event handler on this Page is used to delete an
        /// an event.  It  uses	the	Appleseed.EventsDB() data	component to
        /// encapsulate	all	data functionality.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected override void OnDelete(EventArgs e)
        {
            base.OnDelete(e);

            // Only	attempt	to delete the item if it is	an existing	item
            // (new	items will have	"ItemID" of	0)

            if (ItemID != 0)
            {
                EventsDB events = new EventsDB();
                events.DeleteEvent(ItemID);
            }

            // Redirect	back to	the	portal home	page
            RedirectBackToReferringPage();
        }
Exemplo n.º 2
0
        /// <summary>
        /// The	UpdateBtn_Click	event handler on this Page is used to either
        /// create or update an	event.	It uses	the	Appleseed.EventsDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="e">Standard EventArgs</param>
        protected override void OnUpdate(EventArgs e)
        {
            base.OnUpdate(e);

            // Only	Update if the Entered Data is Valid
            if (Page.IsValid == true)
            {
                // Create an instance of the Event DB component
                EventsDB events = new EventsDB();

                // devsolution 2003/6/17: Added items for calendar control
                string StartTime = string.Empty;
                bool IsAllDay = (AllDay.SelectedItem.Value == "1");

                if (IsAllDay)
                {
                    int hour = int.Parse(StartHour.SelectedItem.Text);
                    int minute = int.Parse(StartMinute.SelectedItem.Text);

                    if (StartAMPM.SelectedItem.Value == "PM")
                    {
                        if (hour < 12) hour += 12;
                    }
                    else
                    {
                        if (hour == 12) hour -= 12;
                    }
                    StartTime = string.Format("{0:00}:{1:00}:00", hour, minute);
                }
                // devsolution 2003/6/17: Finished - Added items for calendar control

                if (ItemID == 0)
                {
                    // Add the event within	the	Events table
                    events.AddEvent(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.UserName, TitleField.Text,
                                    DateTime.Parse(ExpireField.Text), DescriptionField.Text, WhereWhenField.Text,
                                    IsAllDay, StartDate.Text, StartTime);
                }
                else
                {
                    // Update the event	within the Events table
                    events.UpdateEvent(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.UserName, TitleField.Text,
                                       DateTime.Parse(ExpireField.Text), DescriptionField.Text, WhereWhenField.Text,
                                       IsAllDay, StartDate.Text, StartTime);
                }

                // Redirect	back to	the	portal home	page
                RedirectBackToReferringPage();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// The	Page_Load event	on this	Page is	used to	obtain the ModuleID
        /// and	ItemID of the event	to edit.
        /// It then	uses the Appleseed.EventsDB()	data component
        /// to populate	the	page's edit	controls with the event	details.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        private void Page_Load(object sender, EventArgs e)
        {
            // Added EsperantusKeys for Localization
            // Mario Endara [email protected] 11/05/2004

            foreach (ListItem item in AllDay.Items)
            {
                switch (AllDay.Items.IndexOf(item))
                {
                    case 0:
                        item.Text = General.GetString("EVENTS_ALLDAY");
                        break;
                    case 1:
                        item.Text = General.GetString("EVENTS_STARTAT");
                        break;
                }
            }

            //Change Indah Fuldner [email protected]
            HtmlEditorDataType h = new HtmlEditorDataType();
            h.Value = this.ModuleSettings["Editor"].ToString();
            DescriptionField =
                h.GetEditor(PlaceHolderHTMLEditor, ModuleID, bool.Parse(this.ModuleSettings["ShowUpload"].ToString()),
                            this.PortalSettings);

            DescriptionField.Width = new Unit(this.ModuleSettings["Width"].ToString());
            DescriptionField.Height = new Unit(this.ModuleSettings["Height"].ToString());
            //End Change Indah Fuldner [email protected]

            // If the page is being	requested the first	time, determine	if an
            // event itemID	value is specified,	and	if so populate page
            // contents	with the event details

            if (Page.IsPostBack == false)
            {
                if (ItemID != 0)
                {
                    // Obtain a	single row of event	information
                    EventsDB events = new EventsDB();
                    SqlDataReader dr = events.GetSingleEvent(ItemID, WorkFlowVersion.Staging);

                    try
                    {
                        // Read	first row from database
                        if (dr.Read())
                        {
                            TitleField.Text = (string) dr["Title"];
                            DescriptionField.Text = (string) dr["Description"];

                            // devsolution 2003/6/17: Added items for calendar control
                            if ((bool) dr["AllDay"])
                            {
                                AllDay.SelectedIndex = 0;
                            }
                            else
                            {
                                int hour = 0;
                                int minute = 0;

                                AllDay.SelectedIndex = 1;
                                StartHour.Enabled = StartMinute.Enabled = StartAMPM.Enabled = true;

                                string[] TimeParts = dr["StartTime"].ToString().Split(new Char[] {':'});

                                try
                                {
                                    if (TimeParts[0].Length > 0) hour = int.Parse(TimeParts[0]);
                                    if (TimeParts.Length > 1) minute = int.Parse(TimeParts[1]);
                                }
                                catch
                                {
                                }

                                if (hour > 11)
                                {
                                    StartAMPM.SelectedIndex = 1;
                                    if (hour > 12) hour -= 12;
                                }
                                else
                                {
                                    if (hour == 0) hour = 12;
                                    StartAMPM.SelectedIndex = 0;
                                }

                                StartHour.SelectedIndex = hour - 1;
                                StartMinute.SelectedIndex = minute/5;
                            }
                            if (dr["StartDate"] != DBNull.Value)
                                StartDate.Text = ((DateTime) dr["StartDate"]).ToShortDateString();
                            else
                                StartDate.Text = string.Empty;
                            // devsolution 2003/6/17: Finished - Added items for calendar control

                            ExpireField.Text = ((DateTime) dr["ExpireDate"]).ToShortDateString();
                            CreatedBy.Text = (string) dr["CreatedByUser"];
                            WhereWhenField.Text = (string) dr["WhereWhen"];
                            CreatedDate.Text = ((DateTime) dr["CreatedDate"]).ToShortDateString();
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (CreatedBy.Text == "unknown")
                            {
                                CreatedBy.Text = General.GetString("UNKNOWN", "unknown");
                            }
                        }
                    }
                    finally
                    {
                        dr.Close();
                    }
                }
                else
                {
                    ExpireField.Text =
                        DateTime.Now.AddDays(Int32.Parse(this.ModuleSettings["DelayExpire"].ToString())).ToShortDateString();
                    this.DeleteButton.Visible = false; // Cannot	delete an unexsistent item
                }
            }
        }
Exemplo n.º 4
0
        // devsolution 2003/6/17: Finished - Added items for calendar control
        /// <summary>
        /// devsolution 2003/6/17:
        /// Change to make a RenderEvents for modularity
        /// Routine to add show calendar logic
        /// And Clean up code as now the calendar next and previous
        /// controls must re-render the display and get the data again
        /// e.g. modularize the code
        /// </summary>
        /// <param name="DisplayMonth">Month to display 1=Jan, 2=Feb, etc</param>
        /// <param name="DisplayYear">Year to display YYYY, 2003 for 2003</param>
        private void RenderEvents(int DisplayMonth, int DisplayYear)
        {
            EventsDB events = new EventsDB();

            myDataList.RepeatDirection = (Settings["RepeatDirectionSetting"].ToString() == "Horizontal"
                                              ? RepeatDirection.Horizontal
                                              : RepeatDirection.Vertical);
            myDataList.RepeatColumns = Int32.Parse(Settings["RepeatColumns"].ToString());

            if (bool.Parse(Settings["ShowBorder"].ToString()))
            {
                //myDataList.BorderWidth=Unit.Pixel(1);
                myDataList.ItemStyle.BorderWidth = Unit.Pixel(1);
            }
            dsEventData = events.GetEvents(ModuleID, Version);
            myDataList.DataSource = dsEventData;
            myDataList.DataBind();

            // devsolution 2003/6/17: Added items for calendar control
            if (bool.Parse(Settings["ShowCalendar"].ToString()))
            {
                CalendarPanel.Visible = true;
                string DisplayDate = string.Empty;
                // devsolution 2003/6/17: Must have Devsolution.Portal.dll in \bin for calendar display functionality
                EventCalendar eventcalendar = new EventCalendar();
                lblCalendar.Text =
                    eventcalendar.GenerateCalendar(ModuleID, DisplayMonth, DisplayYear, out DisplayDate, dsEventData);
                lblDisplayDate.Text = DisplayDate;
            }
            // devsolution 2003/6/17: Finished - Added items for calendar control

            myDataList.DataSource = dsEventData;
            myDataList.DataBind();
        }