internal static void UpdateCategories(ListAction action, int eventId, ArrayList categories, bool checkAccess) { if (checkAccess) { VerifyCanUpdate(eventId); } ArrayList oldCategories = new ArrayList(); using (IDataReader reader = CalendarEntry.GetListCategories(eventId)) { Common.LoadCategories(reader, oldCategories); } Common.UpdateList(action, oldCategories, categories, OBJECT_TYPE, eventId, SystemEventTypes.CalendarEntry_Updated_GeneralCategories, new UpdateListDelegate(Common.ListUpdate), null); }
IDataReader GetCategoriesReader(int ObjectType, int ObjectID, Label lblTextHeader, ListBox lbCategories) { if (ObjectType == (int)ObjectTypes.Issue) { lblTextHeader.Text = LocRM.GetString("TextHeaderInc"); lbCategories.DataSource = Incident.GetListCategoriesAll(); return(Incident.GetListCategories(ObjectID)); } if (ObjectType == (int)ObjectTypes.ToDo) { lblTextHeader.Text = LocRM.GetString("TextHeaderToDo"); lbCategories.DataSource = ToDo.GetListCategoriesAll(); return(ToDo.GetListCategories(ObjectID)); } if (ObjectType == (int)ObjectTypes.CalendarEntry) { lblTextHeader.Text = LocRM.GetString("TextHeaderCalEntry"); lbCategories.DataSource = CalendarEntry.GetListCategoriesAll(); return(CalendarEntry.GetListCategories(ObjectID)); } return(null); }
private void BindData() { try { using (IDataReader rdr = CalendarEntry.GetEvent(EventID)) { /// EventId, ProjectId, ProjectTitle, CreatorId, ManagerId, /// Title, Description, Location, CreationDate, StartDate, /// FinishDate, PriorityId, PriorityName, TypeId, TypeName, ReminderInterval, HasRecurrence if (rdr.Read()) { lblTitle.Text = (string)rdr["Title"]; if (Configuration.ProjectManagementEnabled) { if (rdr["ProjectId"] != DBNull.Value) { if (Project.CanRead((int)rdr["ProjectId"])) { lblProject.Text = "<a href='../Projects/ProjectView.aspx?ProjectID=" + (int)rdr["ProjectId"] + "'>" + (string)rdr["ProjectTitle"] + "</a>"; } else { lblProject.Text = (string)rdr["ProjectTitle"]; } } else { lblProject.Text = LocRM.GetString("tNotSet"); } } else { tdPrjLabel.Visible = false; tdPrjName.Visible = false; } lblLocation.Text = (string)rdr["Location"]; lblPriority.Text = (string)rdr["PriorityName"]; lblType.Text = (string)rdr["TypeName"]; lblManager.Text = CommonHelper.GetUserStatus((int)rdr["ManagerId"]); lblCreated.Text = CommonHelper.GetUserStatus((int)rdr["CreatorId"]) + " " + ((DateTime)rdr["CreationDate"]).ToShortDateString() + " " + ((DateTime)rdr["CreationDate"]).ToShortTimeString(); TargetStartDate = (DateTime)rdr["StartDate"]; TargetFinishDate = (DateTime)rdr["FinishDate"]; lblStartDate.Text = TargetStartDate.ToShortDateString() + " " + TargetStartDate.ToShortTimeString(); lblEndDate.Text = TargetFinishDate.ToShortDateString() + " " + TargetFinishDate.ToShortTimeString(); lblDescription.Text = CommonHelper.parsetext((string)rdr["Description"], false); HasRecurrence = ((int)rdr["HasRecurrence"] == 1); lblClient.Text = Util.CommonHelper.GetClientLink(this.Page, rdr["OrgUid"], rdr["ContactUid"], rdr["ClientName"]); } else { Response.Redirect("../Common/NotExistingID.aspx?EventID=1"); } } } catch (AccessDeniedException) { Response.Redirect("~/Common/NotExistingID.aspx?AD=1"); } using (IDataReader rdr = CalendarEntry.GetListCategories(EventID)) { string categories = ""; while (rdr.Read()) { if (categories != "") { categories += ", "; } categories += (string)rdr["CategoryName"]; } lblCategory.Text = categories; } tdPriority.Visible = tdPriority2.Visible = PortalConfig.CommonCEntryAllowViewPriorityField; tdCategories.Visible = tdCategories2.Visible = PortalConfig.CommonCEntryAllowViewGeneralCategoriesField; tdClient.Visible = tdClient2.Visible = PortalConfig.CommonCEntryAllowViewClientField; trCategoriesClient.Visible = tdCategories.Visible || tdClient.Visible; }
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()); } }