Exemplo n.º 1
0
        /// <summary>
        /// Handles the OnClick event of the lbtnSaveNonGrid 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 lbtnSaveNonGrid_OnClick(object sender, EventArgs e)
        {
            if (SaveClicked != null)
            {
                var taskDuration = new TaskDurationMap
                {
                    ID = Guid.NewGuid(),
                    SectionDateStart      = rdpStartDate.SelectedDate,
                    SectionDateEnd        = rdpEndDate.SelectedDate,
                    ActualDurationHours   = (int?)rntxtActualDurationHours.Value,
                    ActualDurationMinutes = (int?)rntxtActualDurationMinutes.Value,
                    ResponsibleID         = ucResponsible.SelectedValue
                };
                var eventArgs = new SaveClickEventArgs {
                    TaskDuration = taskDuration
                };
                SaveClicked(this, eventArgs);
            }

            BindData();

            if (!Page.ClientScript.IsStartupScriptRegistered("CloseRadWindow"))
            {
                ScriptManager.RegisterStartupScript(Page, typeof(Page), "CloseRadWindow", "CloseRadWindow();", true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handles the OnAppointmentInsert event of the rScheduler control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.AppointmentInsertEventArgs"/> instance containing the event data.</param>
        protected void rScheduler_OnAppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            var actualTime = ((List <TaskDurationMap>)ViewState["TaskDurations"]).Sum(tdp => tdp.ActualDurationHours * 60 + tdp.ActualDurationMinutes);

            actualTime = actualTime + (e.Appointment.End - e.Appointment.Start).Hours + (e.Appointment.End - e.Appointment.Start).Minutes;

            if (actualTime <= (Task.PlanDurationHours * 60 + Task.PlanDurationMinutes))
            {
                var taskDurationMap = new TaskDurationMap
                {
                    ID = Guid.NewGuid(),
                    SectionDateStart      = e.Appointment.Start,
                    SectionDateEnd        = e.Appointment.End,
                    ActualDurationHours   = (e.Appointment.End - e.Appointment.Start).Hours,
                    ActualDurationMinutes = (e.Appointment.End - e.Appointment.Start).Minutes,
                    Comment       = e.Appointment.Subject,
                    ResponsibleID = CurrentUser.Instance.ContactID
                };

                ((List <TaskDurationMap>)ViewState["TaskDurations"]).Add(taskDurationMap);
            }
            else
            {
                if (!Page.ClientScript.IsStartupScriptRegistered("InsertAlert"))
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "InsertAlert", "alert('Указан не правильный промежуток');", true);
                }
            }

            BindData();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the OnAppointmentInsert event of the rScheduler control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.AppointmentInsertEventArgs"/> instance containing the event data.</param>
        protected void rScheduler_OnAppointmentInsert(object sender, AppointmentInsertEventArgs e)
        {
            if (e.Appointment.Start >= Task.StartDate && e.Appointment.End <= Task.EndDate)
            {
                var taskDurationMap = new TaskDurationMap
                {
                    ID = Guid.NewGuid(),
                    SectionDateStart      = e.Appointment.Start,
                    SectionDateEnd        = e.Appointment.End,
                    ActualDurationHours   = (e.Appointment.End - e.Appointment.Start).Hours,
                    ActualDurationMinutes = (e.Appointment.End - e.Appointment.Start).Minutes,
                    Comment = e.Appointment.Subject
                };
                if (!string.IsNullOrEmpty(e.Appointment.Attributes["ResponsibleID"]))
                {
                    taskDurationMap.ResponsibleID = Guid.Parse(e.Appointment.Attributes["ResponsibleID"]);
                }

                ((List <TaskDurationMap>)ViewState["TaskDurations"]).Add(taskDurationMap);
            }
            else
            {
                if (!Page.ClientScript.IsStartupScriptRegistered("InsertAlert"))
                {
                    ScriptManager.RegisterStartupScript(Page, typeof(Page), "InsertAlert", "alert('Указан не правильный промежуток');", true);
                }
            }

            BindData();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the duration of the task.
        /// </summary>
        /// <param name="taskDuration">Duration of the task.</param>
        public void AddTaskDuration(TaskDurationMap taskDuration)
        {
            ((List <TaskDurationMap>)ViewState["TaskDurations"]).Add(taskDuration);
            rgTaskDurations.Rebind();

            if (TaskDurationsChanged != null)
            {
                TaskDurationsChanged(this, EventArgs.Empty);
            }
        }