public void btnSnooze_Click(object sender, EventArgs e) { int taskID = 0; int interval = 0; Task task = null; interval = Convert.ToInt32(ucReminderInterval.SelectedValue); foreach (GridViewRow row in gvReminder.Rows) { if (row.RowType == DataControlRowType.DataRow) { taskID = (int)gvReminder.DataKeys[row.RowIndex].Value; task = TasksManager.Get(taskID); if (task != null) { task.start_date = DateTime.Now.AddMinutes(interval); task.ReminderInterval = 0; TasksManager.Save(task); } } } closeWindow(); }
private void fillForm(int taskID) { Task task = TasksManager.Get(taskID); if (task != null) { txtDetails.Text = task.details; txtSubject.Text = task.text; startDate.Text = ((DateTime)task.start_date).ToShortDateString(); endDate.Text = ((DateTime)task.end_date).ToShortDateString(); startTime.Text = ((DateTime)task.start_date).ToString("hh:mm tt"); endTime.Text = ((DateTime)task.end_date).ToString("hh:mm tt"); if (task.PriorityID != null) { ddlPriority.SelectedValue = task.PriorityID.ToString(); } if (task.ReminderInterval != null) { ucReminderInterval.SelectedValue = task.ReminderInterval.ToString(); } } }
private void fillForm(int taskID) { Reminder reminder = null; Recurrence recurrence = null; Task task = null; if (taskID > 0) { // edit existing event task = TasksManager.Get(taskID); if (task != null) { txtSubject.Text = task.text; txtDescription.Text = task.details; txtEventDateTimeStart.Value = task.start_date; txtEventDateTimeEnd.Value = task.end_date; ddlOwner.SelectedValue = (task.owner_id ?? 0).ToString(); ddlReminderWhen.SelectedValue = (task.ReminderInterval ?? 0).ToString(); hf_taskID.Value = taskID.ToString(); if (task.Reminder != null && task.Reminder.Count > 0) { reminder = task.Reminder.FirstOrDefault(); if (reminder != null) { ViewState["ReminderID"] = reminder.ReminderID.ToString(); ddlReminderRepeat.SelectedValue = (reminder.ReminderWhen ?? 0).ToString(); ddlReminderAlert.SelectedValue = (reminder.AlertTypeID ?? 1).ToString(); // email } } if (task.Recurrence != null) { ViewState["RecurringID"] = recurrence.RecurringID.ToString(); txtRecurrenceStartDate.Value = recurrence.DateStart; txtRecurrenceEndDate.Value = recurrence.DateEnd; ddlRecurringRepeatFrequency.SelectedValue = (recurrence.RepeatFrequencyID ?? 0).ToString(); } // show invitees pnlInvitees.Visible = true; bindInvitees(taskID); } } }
private void dismissReminder(int taskID) { Task task = null; task = TasksManager.Get(taskID); if (task != null) { task.status_id = (int)Globals.Task_Status.Dismissed; TasksManager.Save(task); deleteReminderInMemory(taskID); bindData(); } }
protected void btnSave_Click(object sender, EventArgs e) { string end_date = null; int reminderInterval = 0; int leadID = 0; string start_date = null; Task task = null; int userID = 0; Page.Validate(); if (!Page.IsValid) { return; } if (TaskID == 0) { task = new Task(); } else { task = TasksManager.Get(TaskID); } leadID = SessionHelper.getLeadId(); // set reminder flag if (ucReminderInterval.SelectedIndex > 0) { reminderInterval = Convert.ToInt32(ucReminderInterval.SelectedValue); task.ReminderInterval = reminderInterval; } task.IsReminder = (reminderInterval > 0); task.creator_id = clientID; task.text = txtSubject.Text.Trim(); task.details = txtDetails.Text.Trim(); end_date = string.Format("{0} {1}", endDate.Text, endTime.Text); start_date = string.Format("{0} {1}", startDate.Text, startTime.Text); task.start_date = Convert.ToDateTime(start_date); task.end_date = Convert.ToDateTime(end_date); task.isAllDay = cbxAllDayEvent.Checked; task.status_id = (int)Globals.Task_Status.Active; // assign owner //if (roleID == (int)UserRole.Client || roleID == (int)UserRole.SiteAdministrator) { userID = Convert.ToInt32(ddlUsers.SelectedValue); if (userID > 0) { task.owner_id = userID; } //} //else //task.owner_id = userID; if (this.isLead && leadID > 0) { task.lead_id = leadID; } //task.policy_type = Convert.ToInt32(ucPolicyType.SelectedValue); if (ddlPriority.SelectedIndex > 0) { task.PriorityID = Convert.ToInt32(ddlPriority.SelectedValue); } TasksManager.Save(task); //string js = "<script>window.close();window.opener.location.reload();</script>"; closeWindow(); }
public void saveEvent() { Task task = null; Recurrence recurrence = null; Reminder reminder = null; string success = "Event saved successfully."; string error = "Event was not saved."; int taskID = Convert.ToInt32(hf_taskID.Value); int clientID = SessionHelper.getClientId(); if (taskID > 0) { // edit task = TasksManager.Get(taskID); } else { // new task = new Task(); task.creator_id = clientID; task.TaskType = 2; // save task as an event task.status_id = 1; } if (task != null) { try { task.text = txtSubject.Text.Trim(); task.details = txtDescription.Text.Trim(); task.start_date = txtEventDateTimeStart.Date; task.end_date = txtEventDateTimeEnd.Date; task.owner_id = Convert.ToInt32(ddlOwner.SelectedValue); task.ReminderInterval = Convert.ToInt32(ddlReminderWhen.SelectedValue); using (TransactionScope scope = new TransactionScope()) { taskID = TasksManager.Save(task); hf_taskID.Value = taskID.ToString(); // reminder if (ddlReminderWhen.SelectedIndex > 0 && task.Reminder != null && task.Reminder.Count == 0) { // new reminder reminder = new Reminder(); reminder.TaskID = taskID; saveReminder(reminder); } else if (ddlReminderWhen.SelectedIndex > 0 && task.Reminder != null && task.Reminder.Count == 1) { // edit existing reminder reminder = task.Reminder.FirstOrDefault(); saveReminder(reminder); } else if (ddlReminderWhen.SelectedIndex == 0 && task.Reminder != null && task.Reminder.Count == 1 && ViewState["ReminderID"] != null) { // delete reminder ReminderManager.Delete(Convert.ToInt32(ViewState["ReminderID"])); } // recurring if (!string.IsNullOrEmpty(txtRecurrenceStartDate.Text) && task.Recurrence == null) { // new recurrence recurrence = new Recurrence(); recurrence.TaskID = taskID; saveRecurrence(recurrence); } else if (!string.IsNullOrEmpty(txtRecurrenceStartDate.Text) && task.Recurrence != null) { // edit recurrence recurrence = (Recurrence)task.Recurrence; saveRecurrence(recurrence); } else if (string.IsNullOrEmpty(txtRecurrenceStartDate.Text) && task.Recurrence != null && ViewState["RecurringID"] != null) { // delete recurrence RecurrenceManager.Delete(Convert.ToInt32(ViewState["RecurringID"])); } // commit changes to DB scope.Complete(); } // allow user to add invitees pnlInvitees.Visible = true; if (this.Page is CRM.Web.Protected.EventEdit) { ((CRM.Web.Protected.EventEdit) this.Page).setErrorMessage(success, "ok"); } else if (this.Page is CRM.Web.Protected.EventEditPopUp) { ((CRM.Web.Protected.EventEditPopUp) this.Page).setErrorMessage(success, "ok"); } //lblMessage.Text = "Event saved successfully."; //lblMessage.CssClass = "ok"; } catch (Exception ex) { Core.EmailHelper.emailError(ex); if (this.Page is CRM.Web.Protected.EventEdit) { ((CRM.Web.Protected.EventEdit) this.Page).setErrorMessage(error, "error"); } else if (this.Page is CRM.Web.Protected.EventEditPopUp) { ((CRM.Web.Protected.EventEditPopUp) this.Page).setErrorMessage(error, "error"); } //lblMessage.Text = "Event was not saved."; //lblMessage.CssClass = "error"; } } }
protected void btnSave_Click(object sender, EventArgs e) { Page.Validate("appointment"); if (!Page.IsValid) { return; } int reminderInterval = 0; int taskID = Convert.ToInt32(ViewState["TaskID"]); Task task = null; if (taskID == 0) { task = new Task(); task.CarrierID = carrierID; task.owner_id = Core.SessionHelper.getUserId(); } else { task = TasksManager.Get(taskID); } if (task != null) { // set reminder flag reminderInterval = Convert.ToInt32(ucReminderInterval.SelectedValue); task.ReminderInterval = reminderInterval; task.IsReminder = (reminderInterval > 0); task.creator_id = Core.SessionHelper.getClientId(); task.text = txtSubject.Text.Trim(); task.details = txtDetails.Text.Trim(); string end_date = string.Format("{0} {1}", endDate.Text, endTime.Text); string start_date = string.Format("{0} {1}", startDate.Text, startTime.Text); task.start_date = Convert.ToDateTime(start_date); task.end_date = Convert.ToDateTime(end_date); task.isAllDay = cbxAllDayEvent.Checked; task.status_id = (int)Globals.Task_Status.Active; task.owner_id = Core.SessionHelper.getUserId(); if (ddlPriority.SelectedIndex > 0) { task.PriorityID = Convert.ToInt32(ddlPriority.SelectedValue); } TasksManager.Save(task); showGridPanel(); bindData(); } }
private void saveTask() { int? contactID = 0; Task task = null; Recurrence recurrence = null; int taskID = 0; clientID = SessionHelper.getClientId(); if (this.TaskID > 0) { // edit task = TasksManager.Get(this.TaskID); } else { // new task = new Task(); task.creator_id = this.clientID; task.TaskType = (int)Globals.TaskType.Task; } if (task != null) { try { contactID = Convert.ToInt32(hf_contactID.Value); task.text = txtSubject.Text.Trim(); task.details = txtDescription.Text.Trim(); task.start_date = txtDateDue.Date; task.status_id = Convert.ToInt32(ddlTaskStatus.SelectedValue); task.owner_id = Convert.ToInt32(ddlOwner.SelectedValue); task.PriorityID = Convert.ToInt32(ddlPriority.SelectedValue); // contact information task.ContactID = contactID > 0 ? contactID : null; using (TransactionScope scope = new TransactionScope()) { // recurring if (!string.IsNullOrEmpty(txtRecurrenceStartDate.Text) && task.Recurrence.Count <= 0) { // new recurrence recurrence = new Recurrence(); recurrence.TaskID = task.id; saveRecurrence(recurrence); generateRecurrenceSequence(task, recurrence); } else if (!string.IsNullOrEmpty(txtRecurrenceStartDate.Text) && task.Recurrence.Count > 0) { // edit recurrence //recurrence = (Recurrence)task.Recurrence; foreach (Recurrence recu in task.Recurrence) { editRecurrence(recu); RecurrenceManager.DeleteTasks(Convert.ToInt32(ViewState["RecurringID"])); generateRecurrenceSequence(task, recu); } } else if (string.IsNullOrEmpty(txtRecurrenceStartDate.Text) && string.IsNullOrEmpty(txtRecurrenceEndDate.Text) && task.Recurrence != null && ViewState["RecurringID"] != null) { // delete recurrence along with tasks RecurrenceManager.Delete(Convert.ToInt32(ViewState["RecurringID"])); } else { // save task with no recurrence taskID = TasksManager.Save(task); } // commit changes to DB scope.Complete(); } lblMessage.Text = "Task saved successfully."; lblMessage.CssClass = "ok"; } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblMessage.Text = "Task was not saved."; lblMessage.CssClass = "error"; } } }
private void fillForm() { Reminder reminder = null; //Recurrence recurrence = null; Task task = null; task = TasksManager.Get(this.TaskID); if (task != null) { txtDateDue.Value = task.start_date; txtDescription.Text = task.details; txtSubject.Text = task.text; ddlPriority.SelectedValue = (task.PriorityID ?? 1).ToString(); ddlOwner.SelectedValue = (task.owner_id ?? 0).ToString(); ddlTaskStatus.SelectedValue = (task.status_id ?? 0).ToString(); // contact if (task.ContactID != null) { hf_contactID.Value = task.ContactID.ToString(); txtContact.Text = ContactManager.GetName((int)task.ContactID); } if (task.Reminder != null && task.Reminder.Count > 0) { reminder = task.Reminder.FirstOrDefault(); if (reminder != null) { ViewState["ReminderID"] = reminder.ReminderID.ToString(); //ddlReminderWhen.SelectedValue = (reminder.ReminderWhen ?? 0).ToString(); //ddlReminderRepeatFrequency.SelectedValue = (reminder.RepeatFrequencyID ?? 0).ToString(); //ddlAlertType.SelectedValue = (reminder.AlertTypeID ?? 1).ToString(); // email } } if (task.Recurrence != null) { lbtnClearRecurrence.Visible = true; //foreach( Recurrence rec in task.Recurrence ) //{ //} foreach (Recurrence recurrence in task.Recurrence) { //recurrence = (Recurrence)task.Recurrence; ViewState["RecurringID"] = recurrence.RecurringID.ToString(); txtRecurrenceStartDate.Value = recurrence.DateStart; txtRecurrenceEndDate.Value = recurrence.DateEnd; ddlRecurringRepeatFrequency.SelectedValue = (recurrence.RepeatFrequencyID ?? 0).ToString(); //repeat daily cbxRecurringDailyEveryDay.Checked = recurrence.IsRepeatDailyEveryDay ?? false; cbxRecurringDailyEveryNDay.Checked = recurrence.IsRepeatDailyForEveryNDays ?? false; txtRecurringDailyEveryNDays.Value = recurrence.RepeatDailyForEveryNDays; // repeat weekly txtRepeatWeeklyEveryNWeeks.Value = recurrence.RepeatWeeklyEveryNWeeks; cbxEveryWeekSun.Checked = recurrence.IsRepeatWeeklyEveryNWeeksSun ?? false; cbxEveryWeekMon.Checked = recurrence.IsRepeatWeeklyEveryNWeeksMon ?? false; cbxEveryWeekTue.Checked = recurrence.IsRepeatWeeklyEveryNWeeksTue ?? false; cbxEveryWeekWed.Checked = recurrence.IsRepeatWeeklyEveryNWeeksWed ?? false; cbxEveryWeekThu.Checked = recurrence.IsRepeatWeeklyEveryNWeeksThur ?? false; cbxEveryWeekFri.Checked = recurrence.IsRepeatWeeklyEveryNWeeksFri ?? false; cbxEveryWeekSat.Checked = recurrence.IsRepeatWeeklyEveryNWeeksSat ?? false; // repeat monthly cbxRecurringMonthlyOnDay.Checked = recurrence.IsRepeatMonthlyOnDay ?? false; cbxRecurringMonthlyOn.Checked = recurrence.IsRepeatMonthlyOn ?? false; txtRecurringMonthlyOnDay.Value = recurrence.RepeatMonthlyOnDay; txtRecurringMonthlyOnDayEvery.Value = recurrence.RepeatMonthlyOnDayEvery; ddlRecurringMonthlyOn.SelectedValue = (recurrence.RepeatMonthlyOn ?? 1).ToString(); ddlRecurringMonthlyWeekDay.SelectedValue = (recurrence.RepeatMonthlyOnWeekDay ?? 1).ToString(); txtRecurringMonthlyWeekDayOfEveryMonth.Value = recurrence.RepeatMonthlyOnEvery; // repeat yearly cbxRecurringYearlyOnEvery.Checked = recurrence.IsRepeatYearlyOnEvery ?? false; ddlRepeatYearlyOnEveryMonth.SelectedValue = (recurrence.RepeatYearlyMonth ?? 1).ToString(); txtRecurringYearlyOnEveryMonthDay.Value = recurrence.RepeatYearlyMonthDay; cbxRecurringYearlyOn.Checked = recurrence.IsRepeatYearlyOn ?? false; ddlRecurringYearlyOn.SelectedValue = (recurrence.RepeatYearlyOn ?? 1).ToString(); ddlRecurringYearlyWeekDay.SelectedValue = (recurrence.RepeatYearlyOnWeekDay ?? 1).ToString(); ddlRecurringYearlyMonth.SelectedValue = (recurrence.RepeatYearlyOnMonth ?? 1).ToString(); showRepeatPanel(recurrence.RepeatFrequencyID ?? 0); } } } }