コード例 #1
0
        private void BindValues()
        {
            // Dates
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_Any}"), "[DateTimeThisAny]"));
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_ThisWeek}"), "[DateTimeThisWeek]"));
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_LastWeek}"), "[DateTimeLastWeek]"));
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_ThisMonth}"), "[DateTimeThisMonth]"));
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_LastMonth}"), "[DateTimeLastMonth]"));
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_ThisYear}"), "[DateTimeThisYear]"));
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_LastYear}"), "[DateTimeLastYear]"));
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_CustomWeek}"), "0"));
            PeriodList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_CustomPeriod}"), "-1"));

            Dtc0.SelectedDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
            Dtc1.SelectedDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
            Dtc2.SelectedDate = CHelper.GetRealWeekEndByDate(DateTime.Today);

            Dtc0.Visible      = false;
            Dtc1.Visible      = false;
            Dtc2.Visible      = false;
            DashLabel.Visible = false;
        }
コード例 #2
0
        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;
        }