Esempio n. 1
0
        /// <summary>
        /// Adds to event grid.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void AddToEventGrid(object sender, EventArgs e)
        {
            if (!PageBase.StopProcessing)
            {
                if (Page.IsValid)
                {
                    ProjectEvent projectEvent = new ProjectEvent();
                    projectEvent.EventName = txtEvent.Text.Trim();

                    if (EventDate.SelectedDate.HasValue)
                    {
                        projectEvent.EventDate = EventDate.SelectedDate;
                    }

                    projectEvent.CreatedByUserId     = UserID;
                    projectEvent.CreatedDate         = Now;
                    projectEvent.LastUpdatedByUserId = UserID;
                    projectEvent.LastUpdatedDate     = Now;

                    if (ProjectID != 0)
                    {
                        #region Project Notification

                        DataContext.Notifications.AddObject(CreateNotification(Support.GetCodeIdByCodeValue("OperationType", "ADD"), string.Format("{0} added a Project Schedule.", Support.UserFullName)));

                        #endregion Project Notification

                        projectEvent.ProjectId = ProjectID;
                        DataContext.ProjectEvents.AddObject(projectEvent);
                        DataContext.SaveChanges();
                    }
                    else
                    {
                        //Will be used from AddNewProject screen.So Saving will not be done.Instead add to the viewState
                        EventList.Add(projectEvent);
                    }
                    LoadData();
                    btnAddKeyDate.Attributes["disabled"] = "disabled";
                    txtEvent.Text = string.Empty;
                    EventDate.Clear();
                    EventDate.DateInput.Clear();
                    gvEvents.DataBind();
                    upnl.Update();
                }

                txtEvent.Focus();
            }
        }