private void BindValues() { DateTime dt = DateTime.Today.AddHours(DateTime.UtcNow.Hour + 1); dtcStartDate.SelectedDate = User.GetLocalDate(Security.CurrentUser.TimeZoneId, dt); if (Request["start"] != null) { try { dtcStartDate.SelectedDate = DateTime.Parse(Request["start"]); } catch { } } dtcEndDate.SelectedDate = dtcStartDate.SelectedDate.AddHours(1); if (Request["end"] != null) { try { dtcEndDate.SelectedDate = DateTime.Parse(Request["end"]); } catch { } } if (Request["end"] == null && Request["start"] != null && dtcStartDate.SelectedDate.Hour == 0 && dtcEndDate.SelectedDate.Minute == 0) { dtcStartDate.SelectedDate = dtcStartDate.SelectedDate.AddHours(8); dtcEndDate.SelectedDate = dtcStartDate.SelectedDate.AddHours(1); } if (AutoInvite) { btnSaveAssign.Visible = false; } BindCategories(); ddlPriority.DataSource = CalendarEntry.GetListPriorities(); ddlPriority.DataTextField = "PriorityName"; ddlPriority.DataValueField = "PriorityId"; ddlPriority.DataBind(); ddlType.DataSource = CalendarEntry.GetListEventTypes(); ddlType.DataTextField = "TypeName"; ddlType.DataValueField = "TypeId"; ddlType.DataBind(); CommonHelper.SafeSelect(ddlType, ((int)CalendarEntry.EventType.Meeting).ToString()); if (Configuration.ProjectManagementEnabled) { ucProject.ObjectTypeId = (int)ObjectTypes.Project; ucProject.ObjectId = -1; if (ProjID != 0) { ucProject.ObjectId = ProjID; } } else { trProject.Visible = false; } if (EventID != 0) { using (IDataReader reader = CalendarEntry.GetEvent(EventID)) { if (reader.Read()) { DateTime StartDate = (DateTime)reader["StartDate"]; DateTime EndDate = (DateTime)reader["FinishDate"]; dtcStartDate.SelectedDate = StartDate; dtcEndDate.SelectedDate = EndDate; txtTitle.Text = HttpUtility.HtmlDecode(reader["Title"].ToString()); txtLocation.Text = HttpUtility.HtmlDecode(reader["Location"].ToString()); if (reader["Description"] != DBNull.Value) { txtDescription.Text = HttpUtility.HtmlDecode(reader["Description"].ToString()); } if (reader["ProjectId"] != DBNull.Value) { ucProject.ObjectId = (int)reader["ProjectId"]; } if (reader["PriorityId"] != DBNull.Value) { CommonHelper.SafeSelect(ddlPriority, reader["PriorityId"].ToString()); //ListItem lItem = ddlPriority.Items.FindByValue(reader["PriorityId"].ToString()); //if (lItem != null) //{ // ddlPriority.ClearSelection(); // lItem.Selected = true; //} } if (reader["TypeId"] != DBNull.Value) { CommonHelper.SafeSelect(ddlType, reader["TypeId"].ToString()); //ListItem lItem = ddlType.Items.FindByValue(reader["TypeId"].ToString()); //if (lItem != null) //{ // ddlType.ClearSelection(); // lItem.Selected = true; //} } if ((int)reader["HasRecurrence"] == 1) { dtcStartDate.Enabled = false; dtcEndDate.Enabled = false; } if (reader["OrgUid"] != DBNull.Value) { ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = PrimaryKeyId.Parse(reader["OrgUid"].ToString()); } else if (reader["ContactUid"] != DBNull.Value) { ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = PrimaryKeyId.Parse(reader["ContactUid"].ToString()); } CommonHelper.SafeSelect(ManagerList, reader["ManagerId"].ToString()); } } using (IDataReader reader = CalendarEntry.GetListCategories(EventID)) { while (reader.Read()) { for (int i = 0; i < lbCategory.Items.Count; i++) { CommonHelper.SafeMultipleSelect(lbCategory, reader["CategoryId"].ToString()); //ListItem lItem = lbCategory.Items.FindByText(reader["CategoryName"].ToString()); //if (lItem != null) lItem.Selected = true; } } } EditControl.ObjectId = EventID; EditControl.BindData(); } else //CREATE { CommonHelper.SafeSelect(ddlPriority, PortalConfig.CEntryDefaultValuePriorityField); ArrayList list = Common.StringToArrayList(PortalConfig.CEntryDefaultValueGeneralCategoriesField); foreach (int i in list) { CommonHelper.SafeMultipleSelect(lbCategory, i.ToString()); } PrimaryKeyId org_id = PrimaryKeyId.Empty; PrimaryKeyId contact_id = PrimaryKeyId.Empty; Common.GetDefaultClient(PortalConfig.CEntryDefaultValueClientField, out contact_id, out org_id); if (contact_id != PrimaryKeyId.Empty) { ClientControl.ObjectType = ContactEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = contact_id; } else if (org_id != PrimaryKeyId.Empty) { ClientControl.ObjectType = OrganizationEntity.GetAssignedMetaClassName(); ClientControl.ObjectId = org_id; } CommonHelper.SafeSelect(ManagerList, Security.CurrentUser.UserID.ToString()); } }