public static bool CanWork(int ObjectTypeId, int ObjectId) { if (ObjectTypeId == (int)ObjectTypes.Task) { return(Task.CanViewFinances(ObjectId)); } else if (ObjectTypeId == (int)ObjectTypes.CalendarEntry) { return(CalendarEntry.CanViewFinances(ObjectId)); } else if (ObjectTypeId == (int)ObjectTypes.Document) { return(Document.CanViewFinances(ObjectId)); } else if (ObjectTypeId == (int)ObjectTypes.Issue) { return(Incident.CanViewFinances(ObjectId)); } else if (ObjectTypeId == (int)ObjectTypes.ToDo) { return(ToDo.CanViewFinances(ObjectId)); } else if (ObjectTypeId == (int)ObjectTypes.Project) { return(Project.CanEditFinances(ObjectId)); } else { return(false); } }
public static DataTable GetListActualFinancesByEvent(int EventId) { if (!CalendarEntry.CanViewFinances(EventId)) { throw new AccessDeniedException(); } return(GetListActualFinancesByObject((int)ObjectTypes.CalendarEntry, EventId)); }
private void BindTabs() { if (Tab != null && (Tab == "General" || Tab == "FileLibrary" || Tab == "Finance" || Tab == "Discussions" || Tab == "Customization")) { pc["EventView_CurrentTab"] = Tab; } else if (ViewState["CurrentTab"] != null) { pc["EventView_CurrentTab"] = ViewState["CurrentTab"].ToString(); } else if (pc["EventView_CurrentTab"] == null) { pc["EventView_CurrentTab"] = "General"; } ctrlTopTab.AddTab(LocRM3.GetString("tabGeneral"), "General"); ctrlTopTab.AddTab(LocRM3.GetString("tabMetaData"), "Customization"); bool IsExternal = Security.CurrentUser.IsExternal; ctrlTopTab.AddTab(LocRM3.GetString("tabLibrary"), "FileLibrary"); if (CalendarEntry.CanViewFinances(EventId) && !IsExternal) { ctrlTopTab.AddTab(LocRM3.GetString("tabFinance"), "Finance"); } else { if (pc["EventView_CurrentTab"] == "Finance") { pc["EventView_CurrentTab"] = "General"; } } ctrlTopTab.AddTab(LocRM3.GetString("tabDiscussions"), "Discussions"); ctrlTopTab.SelectItem(pc["EventView_CurrentTab"]); string controlName = "EventGeneral.ascx"; switch (pc["EventView_CurrentTab"]) { case "General": controlName = "EventGeneral.ascx"; break; case "FileLibrary": controlName = "FileLibrary.ascx"; break; case "Finance": controlName = "Finance.ascx"; break; case "Discussions": controlName = "Discussions.ascx"; break; case "Customization": controlName = "MetaDataView.ascx"; break; } System.Web.UI.UserControl control = (System.Web.UI.UserControl)LoadControl(controlName); phItems.Controls.Add(control); }
private void BindToolbar() { if (this.Parent.Parent is IToolbarLight) { BlockHeaderLightWithMenu secHeaderLight = (BlockHeaderLightWithMenu)((IToolbarLight)this.Parent.Parent).GetToolBar(); if (ProjectId > 0 && Project.CanEditFinances(ProjectId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../projects/AddActualItem.aspx?ProjectId=" + ProjectId.ToString() + "',520,270,false);"); } if (TaskId > 0 && Task.CanViewFinances(TaskId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?TaskID=" + TaskId + "',520,270,false);"); } if (IncidentId > 0 && Incident.CanViewFinances(IncidentId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?IncidentId=" + IncidentId + "',520,270,false);"); } if (DocumentId > 0 && Document.CanViewFinances(DocumentId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?DocumentId=" + DocumentId + "',520,270,false);"); } if (EventId > 0 && CalendarEntry.CanViewFinances(EventId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?EventId=" + EventId + "',520,270,false);"); } if (ToDoId > 0 && Mediachase.IBN.Business.ToDo.CanViewFinances(ToDoId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?ToDoId=" + ToDoId + "',520,270,false);"); } } else if (this.Parent is IToolbarLight) { BlockHeaderLightWithMenu secHeaderLight = (BlockHeaderLightWithMenu)((IToolbarLight)this.Parent).GetToolBar(); secHeaderLight.AddText(LocRM.GetString("tActFinances")); if (ProjectId > 0 && Project.CanEditFinances(ProjectId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../projects/AddActualItem.aspx?ProjectId=" + ProjectId.ToString() + "',520,270,false);"); } if (TaskId > 0 && Task.CanViewFinances(TaskId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?TaskID=" + TaskId + "',520,270,false);"); } if (IncidentId > 0 && Incident.CanViewFinances(IncidentId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?IncidentId=" + IncidentId + "',520,270,false);"); } if (DocumentId > 0 && Document.CanViewFinances(DocumentId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?DocumentId=" + DocumentId + "',520,270,false);"); } if (EventId > 0 && CalendarEntry.CanViewFinances(EventId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?EventId=" + EventId + "',520,270,false);"); } if (ToDoId > 0 && Mediachase.IBN.Business.ToDo.CanViewFinances(ToDoId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddActualItem.aspx?ToDoId=" + ToDoId + "',520,270,false);"); } } }
private void BindDG(DataGrid dg) { DataTable dt = new DataTable(); dt.Columns.Add(new DataColumn("ActualId", typeof(int))); dt.Columns.Add(new DataColumn("OutlineLevel", typeof(int))); dt.Columns.Add(new DataColumn("Description", typeof(string))); dt.Columns.Add(new DataColumn("ActualDate", typeof(DateTime))); dt.Columns.Add(new DataColumn("AValue", typeof(double))); dt.Columns.Add(new DataColumn("LastEditorId", typeof(int))); dt.Columns.Add(new DataColumn("LastEditorName", typeof(string))); dt.Columns.Add(new DataColumn("ObjectTypeId", typeof(int))); dt.Columns.Add(new DataColumn("ObjectId", typeof(int))); dt.Columns.Add(new DataColumn("RowId", typeof(string))); dt.Columns.Add(new DataColumn("BlockId", typeof(int))); dt.Columns.Add(new DataColumn("TotalApproved", typeof(string))); dt.Columns.Add(new DataColumn("OwnerDisplayName", typeof(string))); dt.Columns.Add(new DataColumn("OwnerName", typeof(string))); if (ObjectId > 0) { int projectId = Util.CommonHelper.GetProjectIdByObjectIdObjectType(ObjectId, ObjectTypeId); bool projectSpreadSheetIsActive = ProjectSpreadSheet.IsActive(projectId); Hashtable rowNameHashtable = ProjectSpreadSheet.GetRowNameByIdHash(projectId); #region dates DateTime?dt1 = null; DateTime?dt2 = null; switch (PeriodList.SelectedValue) { case "[DateTimeThisAny]": break; case "[DateTimeThisWeek]": dt1 = CHelper.GetRealWeekStartByDate(DateTime.Today); dt2 = CHelper.GetRealWeekEndByDate(DateTime.Today); break; case "[DateTimeLastWeek]": dt1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(-7)); dt2 = CHelper.GetRealWeekEndByDate(DateTime.Today.AddDays(-7)); break; case "[DateTimeThisMonth]": dt1 = DateTime.Today.AddDays(1 - DateTime.Today.Day); dt2 = DateTime.Today; break; case "[DateTimeLastMonth]": dt1 = DateTime.Today.AddDays(1 - DateTime.Today.Day).AddMonths(-1); dt2 = DateTime.Today.AddDays(-DateTime.Today.Day); break; case "[DateTimeThisYear]": dt1 = DateTime.Today.AddDays(1 - DateTime.Today.DayOfYear); dt2 = DateTime.Today; break; case "[DateTimeLastYear]": dt1 = DateTime.Today.AddDays(1 - DateTime.Now.DayOfYear).AddYears(-1); dt2 = DateTime.Today.AddDays(-DateTime.Now.DayOfYear); break; case "0": dt1 = Dtc0.SelectedDate; dt2 = CHelper.GetRealWeekEndByDate(Dtc0.SelectedDate); break; case "-1": dt1 = Dtc1.SelectedDate; dt2 = Dtc2.SelectedDate; break; default: break; } #endregion foreach (ActualFinances af in ActualFinances.List(ObjectId, (ObjectTypes)ObjectTypeId, dt1, dt2)) { DataRow row = dt.NewRow(); row["ActualId"] = af.ActualFinancesId; row["Description"] = af.Comment; row["ActualDate"] = af.Date; row["AValue"] = af.Value; row["LastEditorId"] = af.CreatorId; row["LastEditorName"] = Util.CommonHelper.GetUserStatusPureName(af.CreatorId); row["OutlineLevel"] = 1; row["ObjectTypeId"] = af.ObjectTypeId; row["ObjectId"] = af.ObjectId; if (projectSpreadSheetIsActive && rowNameHashtable.ContainsKey(af.RowId)) { row["RowId"] = rowNameHashtable[af.RowId].ToString(); } else { row["RowId"] = string.Empty; } if (af.BlockId.HasValue) { row["BlockId"] = af.BlockId.Value; } if (af.TotalApproved.HasValue) { if (dg == dgExport) { row["TotalApproved"] = (int)af.TotalApproved.Value; } else { row["TotalApproved"] = CommonHelper.GetHours((int)af.TotalApproved.Value); } } if (af.OwnerId.HasValue) { row["OwnerDisplayName"] = Util.CommonHelper.GetUserStatus(af.OwnerId.Value); if (dgExport.Visible) { row["OwnerName"] = Util.CommonHelper.GetUserStatusAndPositionPureName(af.OwnerId.Value); } else { row["OwnerName"] = Util.CommonHelper.GetUserStatusPureName(af.OwnerId.Value); } } dt.Rows.Add(row); } } /*else if(TaskId>0) * dt = Finance.GetListActualFinancesByTask(TaskId); * else if(IncidentId>0) * dt = Finance.GetListActualFinancesByIncident(IncidentId); * else if(DocumentId>0) * dt = Finance.GetListActualFinancesByDocument(DocumentId); * else if(EventId>0) * dt = Finance.GetListActualFinancesByEvent(EventId); * else if(ToDoId>0) * dt = Finance.GetListActualFinancesByToDo(ToDoId);*/ DataView dv = dt.DefaultView; dv.Sort = pc["FinAct_Sort"].ToString(); if (pc["FinAct_PageSize"] != null) { dg.PageSize = int.Parse(pc["FinAct_PageSize"]); } if (pc["FinAct_Page"] != null) { dg.CurrentPageIndex = int.Parse(pc["FinAct_Page"]); } int pageindex = dg.CurrentPageIndex; int ppi = dv.Count / dg.PageSize; if (dv.Count % dg.PageSize == 0) { ppi = ppi - 1; } if (pageindex <= ppi) { dg.CurrentPageIndex = pageindex; } else { dg.CurrentPageIndex = 0; pc["FinAct_Page"] = "0"; } dg.DataSource = dv; dg.DataBind(); bool haveRights = false; if (ProjectId > 0) { haveRights = Project.CanEditFinances(ProjectId); } if (TaskId > 0) { haveRights = Task.CanViewFinances(TaskId); } if (IncidentId > 0) { haveRights = Incident.CanViewFinances(IncidentId); } if (DocumentId > 0) { haveRights = Document.CanViewFinances(DocumentId); } if (EventId > 0) { haveRights = CalendarEntry.CanViewFinances(EventId); } if (ToDoId > 0) { haveRights = Mediachase.IBN.Business.ToDo.CanViewFinances(ToDoId); } foreach (DataGridItem dgi in dg.Items) { if (dgi.FindControl("ibDelete") != null) { ImageButton ibDelete = (ImageButton)dgi.FindControl("ibDelete"); ibDelete.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("Warning") + "')"); } if (dgi.FindControl("ibEdit") != null) { ImageButton ibEdit = (ImageButton)dgi.FindControl("ibEdit"); string link = string.Empty; if (ObjectId > 0 && haveRights) { link = String.Format(CultureInfo.InvariantCulture, "javascript:OpenWindow(\"{0}?ObjectId={1}&ObjectTypeId={2}&ActualFinancesId={3}&btn={4}\",520,270,false);return false;", ResolveClientUrl("~/projects/AddFinanceActual.aspx"), ObjectId, ObjectTypeId, dgi.Cells[0].Text, Page.ClientScript.GetPostBackEventReference(RefreshButton, "")); } ibEdit.Attributes.Add("onclick", link); } } // if(!Project.CanEditFinances(ProjectId)) // dg.Columns[10].Visible = false; }
private void BindToolbar() { //DV: Esli netu userskih row v spreadshhete proekta to dobavit actual finansy nevozmozhno if (ProjectSpreadSheet.GetFactAvailableRows(Util.CommonHelper.GetProjectIdByObjectIdObjectType(ObjectId, ObjectTypeId)).Length == 0) { return; } if (this.Parent.Parent is IToolbarLight) { BlockHeaderLightWithMenu secHeaderLight = (BlockHeaderLightWithMenu)((IToolbarLight)this.Parent.Parent).GetToolBar(); secHeaderLight.ActionsMenu.Items.Clear(); secHeaderLight.ClearRightItems(); if (ProjectId < 0) { secHeaderLight.AddText(LocRM.GetString("tActFinances")); } ComponentArt.Web.UI.MenuItem subItem; #region New Item string command = String.Empty; if (ProjectId > 0 && Project.CanEditFinances(ProjectId)) { command = String.Format(CultureInfo.InvariantCulture, "OpenWindow(\"{0}?ObjectId={1}&ObjectTypeId={2}&btn={3}\",520,220,false);", ResolveClientUrl("~/projects/AddFinanceActual.aspx"), ProjectId, (int)ObjectTypes.Project, Page.ClientScript.GetPostBackEventReference(RefreshButton, "")); } if (TaskId > 0 && Task.CanViewFinances(TaskId)) { command = String.Format(CultureInfo.InvariantCulture, "OpenWindow(\"{0}?ObjectId={1}&ObjectTypeId={2}&btn={3}\",520,220,false);", ResolveClientUrl("~/projects/AddFinanceActual.aspx"), TaskId, (int)ObjectTypes.Task, Page.ClientScript.GetPostBackEventReference(RefreshButton, "")); } if (IncidentId > 0 && Incident.CanViewFinances(IncidentId)) { command = String.Format(CultureInfo.InvariantCulture, "OpenWindow(\"{0}?ObjectId={1}&ObjectTypeId={2}&btn={3}\",520,220,false);", ResolveClientUrl("~/projects/AddFinanceActual.aspx"), IncidentId, (int)ObjectTypes.Issue, Page.ClientScript.GetPostBackEventReference(RefreshButton, "")); } if (DocumentId > 0 && Document.CanViewFinances(DocumentId)) { command = String.Format(CultureInfo.InvariantCulture, "OpenWindow(\"{0}?ObjectId={1}&ObjectTypeId={2}&btn={3}\",520,220,false);", ResolveClientUrl("~/projects/AddFinanceActual.aspx"), DocumentId, (int)ObjectTypes.Document, Page.ClientScript.GetPostBackEventReference(RefreshButton, "")); } if (EventId > 0 && CalendarEntry.CanViewFinances(EventId)) { command = String.Format(CultureInfo.InvariantCulture, "OpenWindow(\"{0}?ObjectId={1}&ObjectTypeId={2}&btn={3}\",520,220,false);", ResolveClientUrl("~/projects/AddFinanceActual.aspx"), EventId, (int)ObjectTypes.CalendarEntry, Page.ClientScript.GetPostBackEventReference(RefreshButton, "")); } if (ToDoId > 0 && Mediachase.IBN.Business.ToDo.CanViewFinances(ToDoId)) { command = String.Format(CultureInfo.InvariantCulture, "OpenWindow(\"{0}?ObjectId={1}&ObjectTypeId={2}&btn={3}\",520,220,false);", ResolveClientUrl("~/projects/AddFinanceActual.aspx"), ToDoId, (int)ObjectTypes.ToDo, Page.ClientScript.GetPostBackEventReference(RefreshButton, "")); } if (command != String.Empty) { subItem = new ComponentArt.Web.UI.MenuItem(); subItem.LookId = "TopItemLook"; subItem.Look.LeftIconUrl = "~/Layouts/Images/newitem.gif"; subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.ClientSideCommand = command; subItem.Text = LocRM.GetString("tbAdd"); secHeaderLight.ActionsMenu.Items.Add(subItem); } #endregion #region Export subItem = new ComponentArt.Web.UI.MenuItem(); subItem.LookId = "TopItemLook"; subItem.Look.LeftIconUrl = "~/Layouts/Images/Icons/xlsexport.gif"; subItem.Look.LeftIconHeight = Unit.Pixel(16); subItem.Look.LeftIconWidth = Unit.Pixel(16); subItem.ClientSideCommand = Page.ClientScript.GetPostBackEventReference(ExportButton, ""); subItem.Text = LocRM2.GetString("ExcelExport"); secHeaderLight.ActionsMenu.Items.Add(subItem); #endregion } else if (this.Parent is IToolbarLight) { BlockHeaderLightWithMenu secHeaderLight = (BlockHeaderLightWithMenu)((IToolbarLight)this.Parent).GetToolBar(); secHeaderLight.AddText(LocRM.GetString("tActFinances")); if (Project.CanEditFinances(ProjectId) && ProjectId > 0) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../projects/AddFinanceActual.aspx?ObjectId=" + ProjectId.ToString() + "&ObjectTypeId=" + (int)ObjectTypes.Project + "',520,270,false);"); } if (TaskId > 0 && Task.CanViewFinances(TaskId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddFinanceActual.aspx?ObjectId=" + TaskId + "&ObjectTypeId=" + (int)ObjectTypes.Task + "',520,270,false);"); } if (IncidentId > 0 && Incident.CanViewFinances(IncidentId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddFinanceActual.aspx?ObjectId=" + IncidentId + "&ObjectTypeId=" + (int)ObjectTypes.Issue + "',520,270,false);"); } if (DocumentId > 0 && Document.CanViewFinances(DocumentId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddFinanceActual.aspx?ObjectId=" + DocumentId + "&ObjectTypeId=" + (int)ObjectTypes.Document + "',520,270,false);"); } if (EventId > 0 && CalendarEntry.CanViewFinances(EventId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddFinanceActual.aspx?ObjectId=" + EventId + "&ObjectTypeId=" + (int)ObjectTypes.CalendarEntry + "',520,270,false);"); } if (ToDoId > 0 && Mediachase.IBN.Business.ToDo.CanViewFinances(ToDoId)) { secHeaderLight.AddRightLink("<img alt='' src='../Layouts/Images/newitem.gif'/> " + LocRM.GetString("tbAdd"), "javascript:OpenWindow('../Projects/AddFinanceActual.aspx?ObjectId=" + ToDoId + "&ObjectTypeId=" + (int)ObjectTypes.ToDo + "',520,270,false);"); } } }