Example #1
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (IsPostBack && Request["__EVENTTARGET"] == DTCWeek.UniqueID)
            {
                if (ownerId > 0)
                {
                    if (blockInstanceId < 0)
                    {
                        BindBlockTypeInstancesByUser(ownerId);
                    }
                }
                else if (blockInstanceId > 0)
                {
                    BindUsersByBlockTypeInstance(blockInstanceId);
                }

                BindGrid();
            }

            if (BlockInstanceList.Items.Count == 0)
            {
                NoItemsLabel.Visible      = true;
                BlockInstanceList.Visible = false;
            }
            else
            {
                NoItemsLabel.Visible      = false;
                BlockInstanceList.Visible = true;
            }
            lblWeek.Text = String.Format("{1} - {2} (#{0})",
                                         Iso8601WeekNumber.GetWeekNumber(startDate),
                                         CHelper.GetWeekStartByDate(startDate).ToString("d MMM yyyy"),
                                         CHelper.GetWeekEndByDate(startDate).ToString("d MMM yyyy"));
        }
Example #2
0
        public static string GetColumnByDate(SpreadSheetDocumentType DocumentType, DateTime Date)
        {
            switch (DocumentType)
            {
            case SpreadSheetDocumentType.WeekYear:
                int YW = Iso8601WeekNumber.GetYearWeekNumber(Date);
                return(string.Format("{0:0000}-W{1:00}", YW / 100, YW % 100));

            case SpreadSheetDocumentType.MonthQuarterYear:
                if (Date.Month >= 1 && Date.Month < 4)
                {
                    return(string.Format("{0:0000}-Q1-{1:00}", Date.Year, Date.Month));
                }
                else if (Date.Month >= 4 && Date.Month < 7)
                {
                    return(string.Format("{0:0000}-Q2-{1:00}", Date.Year, Date.Month));
                }
                else if (Date.Month >= 7 && Date.Month < 10)
                {
                    return(string.Format("{0:0000}-Q3-{1:00}", Date.Year, Date.Month));
                }
                else
                {
                    return(string.Format("{0:0000}-Q4-{1:00}", Date.Year, Date.Month));
                }

            case SpreadSheetDocumentType.QuarterYear:
                if (Date.Month >= 1 && Date.Month < 4)
                {
                    return(string.Format("{0:0000}-Q1", Date.Year));
                }
                else if (Date.Month >= 4 && Date.Month < 7)
                {
                    return(string.Format("{0:0000}-Q2", Date.Year));
                }
                else if (Date.Month >= 7 && Date.Month < 10)
                {
                    return(string.Format("{0:0000}-Q3", Date.Year));
                }
                else
                {
                    return(string.Format("{0:0000}-Q4", Date.Year));
                }

            case SpreadSheetDocumentType.Year:
                return(string.Format("{0:0000}-T", Date.Year));

            case SpreadSheetDocumentType.Total:
                return("TT");
            }

            throw new NotSupportedException("Not supported document type.");
        }
Example #3
0
        /// <summary>
        /// Inits this instance.
        /// </summary>
        protected virtual void Init()
        {
            _minColumnId = "9999";
            _maxColumnId = "0000";

            #region Calculate Data Boundary
            // Calculate Data Boundary
            foreach (Cell cell in this.Document.Cells)
            {
                if (cell.Position.ColumnId != "TT")
                {
                    if (string.Compare(cell.Position.ColumnId, _minColumnId) < 0)
                    {
                        _minColumnId = cell.Position.ColumnId;
                    }
                    if (string.Compare(cell.Position.ColumnId, _maxColumnId) > 0)
                    {
                        _maxColumnId = cell.Position.ColumnId;
                    }
                }
            }

            _minYear = int.Parse(_minColumnId.Substring(0, 4));
            _maxYear = int.Parse(_maxColumnId.Substring(0, 4));

            if (_minYear == 9999)
            {
                _minYear = _fromYear;
            }
            if (_maxYear == 0)
            {
                _maxYear = _toYear;
            }

            if (_fromYear == int.MinValue)
            {
                _fromYear = _minYear;
            }

            if (_toYear == int.MaxValue)
            {
                _toYear = _maxYear;
            }

            _minYear = Math.Min(_fromYear, _minYear);
            _maxYear = Math.Max(_toYear, _maxYear);
            #endregion

            // Fill Colimns
            switch (this.Document.DocumentType)
            {
            case SpreadSheetDocumentType.MonthQuarterYear:
            {
                #region SpreadSheetDocumentType.MonthQuarterYear
                for (int curYear = _minYear; curYear <= _maxYear; curYear++)
                {
                    //Fill View boundary
                    if (curYear == _fromYear)
                    {
                        _viewColumnIndex = _columns.Count;
                    }

                    if (curYear > _toYear && _viewColumnLength == 0)
                    {
                        StringBuilder totalParams = new StringBuilder();

                        for (int curTYear = _minYear; curTYear <= _maxYear; curTYear++)
                        {
                            if (totalParams.Length > 0)
                            {
                                totalParams.Append('+');
                            }
                            totalParams.AppendFormat("[{0:0000}-T]", curTYear);
                        }

                        Column total = CreateColumn("TT", "Total");
                        total.Expression = totalParams.ToString();

                        _viewColumnLength = _columns.Count - _viewColumnIndex;
                    }

                    // Create Column
                    StringBuilder yearTotalParams = new StringBuilder();

                    for (int curQuarter = 1; curQuarter <= 4; curQuarter++)
                    {
                        StringBuilder quarterTotalParams = new StringBuilder();

                        for (int curMonth = (curQuarter - 1) * 3 + 1; curMonth <= curQuarter * 3; curMonth++)
                        {
                            DateTime time = new DateTime(curYear, curMonth, 1);

                            Column newColumn = CreateColumn(string.Format("{0:0000}-Q{1:0}-{2:00}", curYear, curQuarter, curMonth),
                                                            time.ToString("MMMM"));

                            if (quarterTotalParams.Length > 0)
                            {
                                quarterTotalParams.Append('+');
                            }
                            quarterTotalParams.AppendFormat("[{0}]", newColumn.Id);
                        }

                        // Quarter Total
                        Column quarterTotal = CreateColumn(string.Format("{0:0000}-Q{1:0}-T", curYear, curQuarter),
                                                           string.Format("Total", curYear, curQuarter));
                        quarterTotal.Expression = quarterTotalParams.ToString();

                        if (yearTotalParams.Length > 0)
                        {
                            yearTotalParams.Append('+');
                        }
                        yearTotalParams.AppendFormat("[{0}]", quarterTotal.Id);
                    }

                    // Year Total
                    Column yearTotal = CreateColumn(string.Format("{0:0000}-T", curYear),
                                                    string.Format("Total", curYear));
                    yearTotal.Expression = yearTotalParams.ToString();
                }

                // Final Total
                if (_viewColumnLength == 0)
                {
                    StringBuilder totalParams = new StringBuilder();

                    for (int curTYear = _minYear; curTYear <= _maxYear; curTYear++)
                    {
                        if (totalParams.Length > 0)
                        {
                            totalParams.Append('+');
                        }
                        totalParams.AppendFormat("[{0:0000}-T]", curTYear);
                    }

                    Column total = CreateColumn("TT", "Total");
                    total.Expression = totalParams.ToString();

                    _viewColumnLength = _columns.Count - _viewColumnIndex;
                }

                #endregion
            }
            break;

            case SpreadSheetDocumentType.WeekYear:
            {
                #region SpreadSheetDocumentType.WeekYear
                for (int curYear = _minYear; curYear <= _maxYear; curYear++)
                {
                    //Fill View boundary
                    if (curYear == _fromYear)
                    {
                        _viewColumnIndex = _columns.Count;
                    }

                    if (curYear > _toYear && _viewColumnLength == 0)
                    {
                        StringBuilder totalParams = new StringBuilder();

                        for (int curTYear = _minYear; curTYear <= _maxYear; curTYear++)
                        {
                            if (totalParams.Length > 0)
                            {
                                totalParams.Append('+');
                            }
                            totalParams.AppendFormat("[{0:0000}-T]", curTYear);
                        }

                        Column total = CreateColumn("TT", "Total");
                        total.Expression = totalParams.ToString();

                        _viewColumnLength = _columns.Count - _viewColumnIndex;
                    }

                    // Create Columns
                    StringBuilder yearTotalParams = new StringBuilder();

                    DateTime yearStart = Iso8601WeekNumber.GetFirstWeekOfYear(curYear);

                    for (int curWeek = 1; curWeek <= 52; curWeek++)
                    {
                        DateTime weekFrom = yearStart.AddDays(7 * (curWeek - 1));
                        DateTime weekTo   = weekFrom.AddDays(6);

                        Column newColumn = CreateColumn(string.Format("{0:0000}-W{1:00}", curYear, curWeek),
                                                        string.Format("{1:dd MMM}", curWeek, weekFrom, weekTo));

                        if (yearTotalParams.Length > 0)
                        {
                            yearTotalParams.Append('+');
                        }
                        yearTotalParams.AppendFormat("[{0}]", newColumn.Id);
                    }

                    // Year Total
                    Column yearTotal = CreateColumn(string.Format("{0:0000}-T", curYear),
                                                    string.Format("Total", curYear));
                    yearTotal.Expression = yearTotalParams.ToString();
                }

                // Final Total
                if (_viewColumnLength == 0)
                {
                    StringBuilder totalParams = new StringBuilder();

                    for (int curTYear = _minYear; curTYear <= _maxYear; curTYear++)
                    {
                        if (totalParams.Length > 0)
                        {
                            totalParams.Append('+');
                        }
                        totalParams.AppendFormat("[{0:0000}-T]", curTYear);
                    }

                    Column total = CreateColumn("TT", "Total");
                    total.Expression = totalParams.ToString();

                    _viewColumnLength = _columns.Count - _viewColumnIndex;
                }
                #endregion
            }
            break;

            case SpreadSheetDocumentType.QuarterYear:
            {
                #region SpreadSheetDocumentType.QuarterYear
                for (int curYear = _minYear; curYear <= _maxYear; curYear++)
                {
                    //Fill View boundary
                    if (curYear == _fromYear)
                    {
                        _viewColumnIndex = _columns.Count;
                    }

                    if (curYear > _toYear && _viewColumnLength == 0)
                    {
                        StringBuilder totalParams = new StringBuilder();

                        for (int curTYear = _minYear; curTYear <= _maxYear; curTYear++)
                        {
                            if (totalParams.Length > 0)
                            {
                                totalParams.Append('+');
                            }
                            totalParams.AppendFormat("[{0:0000}-T]", curTYear);
                        }

                        Column total = CreateColumn("TT", "Total");
                        total.Expression = totalParams.ToString();

                        _viewColumnLength = _columns.Count - _viewColumnIndex;
                    }

                    // Create Column
                    StringBuilder yearTotalParams = new StringBuilder();

                    for (int curQuarter = 1; curQuarter <= 4; curQuarter++)
                    {
                        StringBuilder quarterTotalParams = new StringBuilder();

                        // Quarter Total
                        Column quarterTotal = CreateColumn(string.Format("{0:0000}-Q{1:0}", curYear, curQuarter),
                                                           string.Format("{2}{1:0}", curYear, curQuarter, LocRM.GetString("Quartal")));

                        if (yearTotalParams.Length > 0)
                        {
                            yearTotalParams.Append('+');
                        }
                        yearTotalParams.AppendFormat("[{0}]", quarterTotal.Id);
                    }

                    // Year Total
                    Column yearTotal = CreateColumn(string.Format("{0:0000}-T", curYear),
                                                    string.Format("Total", curYear));
                    yearTotal.Expression = yearTotalParams.ToString();
                }

                // Final Total
                if (_viewColumnLength == 0)
                {
                    StringBuilder totalParams = new StringBuilder();

                    for (int curTYear = _minYear; curTYear <= _maxYear; curTYear++)
                    {
                        if (totalParams.Length > 0)
                        {
                            totalParams.Append('+');
                        }
                        totalParams.AppendFormat("[{0:0000}-T]", curTYear);
                    }

                    Column total = CreateColumn("TT", LocRM.GetString("ProjectTotal"));
                    total.Expression = totalParams.ToString();

                    _viewColumnLength = _columns.Count - _viewColumnIndex;
                }

                #endregion
            }
            break;

            case SpreadSheetDocumentType.Year:
            {
                #region SpreadSheetDocumentType.QuarterYear
                for (int curYear = _minYear; curYear <= _maxYear; curYear++)
                {
                    //Fill View boundary
                    if (curYear == _fromYear)
                    {
                        _viewColumnIndex = _columns.Count;
                    }

                    if (curYear > _toYear && _viewColumnLength == 0)
                    {
                        StringBuilder totalParams = new StringBuilder();

                        for (int curTYear = _minYear; curTYear <= _maxYear; curTYear++)
                        {
                            if (totalParams.Length > 0)
                            {
                                totalParams.Append('+');
                            }
                            totalParams.AppendFormat("[{0:0000}-T]", curTYear);
                        }

                        Column total = CreateColumn("TT", "Total");
                        total.Expression = totalParams.ToString();

                        _viewColumnLength = _columns.Count - _viewColumnIndex;
                    }

                    // Year Total
                    Column yearTotal = CreateColumn(string.Format("{0:0000}-T", curYear),
                                                    string.Format("{0:0000}", curYear));
                }

                // Final Total
                if (_viewColumnLength == 0)
                {
                    StringBuilder totalParams = new StringBuilder();

                    for (int curTYear = _minYear; curTYear <= _maxYear; curTYear++)
                    {
                        if (totalParams.Length > 0)
                        {
                            totalParams.Append('+');
                        }
                        totalParams.AppendFormat("[{0:0000}-T]", curTYear);
                    }

                    Column total = CreateColumn("TT", LocRM.GetString("ProjectTotal"));
                    total.Expression = totalParams.ToString();

                    _viewColumnLength = _columns.Count - _viewColumnIndex;
                }

                #endregion
            }
            break;

            case SpreadSheetDocumentType.Total:
            {
                _viewColumnIndex  = 0;
                _viewColumnLength = 1;
                Column total = CreateColumn("TT", LocRM.GetString("ProjectTotal"));
            }
            break;
            }
        }
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Total", typeof(string)));
            dt.Columns.Add(new DataColumn("TotalApproved", typeof(string)));
            dt.Columns.Add(new DataColumn("Rate", typeof(string)));
            dt.Columns.Add(new DataColumn("Cost", typeof(string)));

            MetaView currentView = GetMetaView();

            currentView.Filters = GetFilters();

            McMetaViewPreference currentPreferences = CreateDefaultReportPreferenceTimeTracking(currentView);

            MetaObject[] list = currentView.List(currentPreferences);

            foreach (MetaObject mo in list)
            {
                DataRow row             = dt.NewRow();
                string  additionalTitle = string.Empty;

                string prefix  = "";
                string postfix = "";

                if (cbShowWeekNumber.Checked && mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() != MetaViewGroupByType.Total.ToString())
                {
                    DateTime dtNew = DateTime.MinValue;

                    try
                    {
                        dtNew = (DateTime)mo.Properties["Title"].Value;
                    }
                    catch
                    {
                    }

                    if (dtNew != DateTime.MinValue)
                    {
                        additionalTitle = string.Format("(#{0})", Iso8601WeekNumber.GetWeekNumber((DateTime)mo.Properties["Title"].Value));
                    }
                }

                // Primary Grouping
                if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Primary.ToString())
                {
                    prefix  = "<b>";
                    postfix = "</b>";
                    if (GroupingList.SelectedValue == GroupingWeekUser)
                    {
                        row["Title"] = String.Format("{0}{1} - {2}{3} {4}", prefix, ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), prefix, additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("{0}{1}{2} {3}", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                    }
                }
                // Secondary Grouping
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Secondary.ToString())
                {
                    prefix  = "<b>";
                    postfix = "</b>";
                    if (GroupingList.SelectedValue == GroupingUserWeek)
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0}{1} - {2}{3} {4}</div>", prefix, ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), prefix, additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0}{1}{2} {3}</div>", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                    }
                }
                // Total
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Total.ToString())
                {
                    prefix       = "<b>";
                    postfix      = "</b>";
                    row["Title"] = String.Format("{0}{1}{2} {3}", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                }
                // Other
                else
                {
                    row["Title"] = String.Format("<div style='padding-left: 50px;'>{0} {1}</div>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                    row["Rate"]  = String.Format("{0}{1:F2}{2}", prefix, Convert.ToDecimal(mo.Properties["Rate"].Value), postfix);
                }

                row["Total"]         = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["DayT"].Value) / 60, Convert.ToInt32(mo.Properties["DayT"].Value) % 60, postfix);
                row["TotalApproved"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["TotalApproved"].Value) / 60, Convert.ToInt32(mo.Properties["TotalApproved"].Value) % 60, postfix);
                row["Cost"]          = String.Format("{0}{1:F2}{2}", prefix, Convert.ToDecimal(mo.Properties["Cost"].Value), postfix);

                dt.Rows.Add(row);
            }

            // Header Text
            for (int i = 0; i < MainGrid.Columns.Count; i++)
            {
                MetaField field = currentPreferences.GetVisibleMetaField()[i];

                MainGrid.Columns[i].HeaderText = CHelper.GetResFileString(field.FriendlyName);
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();
        }
        void BindGrid()
        {
            MetaObject[] list = this.CurrentView.List(CurrentPreferences);

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Day1", typeof(float)));
            dt.Columns.Add(new DataColumn("Day2", typeof(float)));
            dt.Columns.Add(new DataColumn("Day3", typeof(float)));
            dt.Columns.Add(new DataColumn("Day4", typeof(float)));
            dt.Columns.Add(new DataColumn("Day5", typeof(float)));
            dt.Columns.Add(new DataColumn("Day6", typeof(float)));
            dt.Columns.Add(new DataColumn("Day7", typeof(float)));
            dt.Columns.Add(new DataColumn("DayT", typeof(float)));
            dt.Columns.Add(new DataColumn("StateFriendlyName", typeof(string)));

            foreach (MetaObject mo in list)
            {
                DataRow row             = dt.NewRow();
                string  additionalTitle = string.Empty;

                if (cbShowWeekNumber.Checked && mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() != MetaViewGroupByType.Total.ToString())
                {
                    DateTime dtNew = DateTime.MinValue;

                    try
                    {
                        dtNew = (DateTime)mo.Properties["Title"].Value;
                    }
                    catch
                    {
                    }

                    if (dtNew != DateTime.MinValue)
                    {
                        additionalTitle = string.Format("(#{0})", Iso8601WeekNumber.GetWeekNumber((DateTime)mo.Properties["Title"].Value));
                    }
                }

                if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Primary.ToString())
                {
                    if (Convert.ToInt32(ddPrimary.SelectedValue, CultureInfo.InvariantCulture) != 0)
                    {
                        row["Title"] = String.Format("<b>{0} {1}</b>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("<b>{0} - {1} {2}</b>", ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), additionalTitle);
                    }
                }
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Secondary.ToString())
                {
                    if (Convert.ToInt32(ddSecondary.SelectedValue, CultureInfo.InvariantCulture) != 0)
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0} {1}</div>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0} - {1} {2}</div>", ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), additionalTitle);
                    }
                }
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Total.ToString())
                {
                    row["Title"] = String.Format("<div style='padding-left: 25px;'>{0} {1}</div>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                }
                else
                {
                    //TO DO: switch
                    switch (this.ThirdGroupById)
                    {
                    case 0:
                    {
                        row["Title"] = String.Format("<div style='padding-left: 45px;'>{0}-{1} {2}</div>", ((DateTime)mo.Properties["StartDate"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["StartDate"].Value).AddDays(6).ToString("d MMM yyyy"), additionalTitle);
                        break;
                    }

                    case 1:
                    {
                        row["Title"] = String.Format("<div style='padding-left: 45px;'>{0} {1}</div>", mo.Properties["Owner"].Value.ToString(), additionalTitle);
                        break;
                    }

                    case 2:
                    {
                        string sTitle = (mo.Properties["Project"].Value != null) ? mo.Properties["Project"].Value.ToString() : mo.Properties["Title"].Value.ToString();
                        row["Title"] = String.Format("<div style='padding-left: 45px;'>{0} {1}</div>", sTitle, additionalTitle);
                        break;
                    }
                    }
                }

                row["Day1"] = Convert.ToDouble(mo.Properties["Day1"].Value);
                row["Day2"] = Convert.ToDouble(mo.Properties["Day2"].Value);
                row["Day3"] = Convert.ToDouble(mo.Properties["Day3"].Value);
                row["Day4"] = Convert.ToDouble(mo.Properties["Day4"].Value);
                row["Day5"] = Convert.ToDouble(mo.Properties["Day5"].Value);
                row["Day6"] = Convert.ToDouble(mo.Properties["Day6"].Value);
                row["Day7"] = Convert.ToDouble(mo.Properties["Day7"].Value);
                row["DayT"] = Convert.ToDouble(mo.Properties["DayT"].Value);

                if (mo.Properties["StateFriendlyName"].Value != null)
                {
                    row["StateFriendlyName"] = CHelper.GetResFileString(mo.Properties["StateFriendlyName"].Value.ToString());
                }
                else
                {
                    row["StateFriendlyName"] = "";
                }

                dt.Rows.Add(row);
            }

            // Header Text
            for (int i = 0; i < MainGrid.Columns.Count; i++)
            {
                MetaField field     = CurrentPreferences.GetVisibleMetaField()[i];
                string    fieldName = field.Name;

                // First day of week can be different, so we should specify it.
                if (fieldName == "Day1" || fieldName == "Day2" || fieldName == "Day3" || fieldName == "Day4" || fieldName == "Day5" || fieldName == "Day6" || fieldName == "Day7")
                {
                    DateTime curDate = CHelper.GetRealWeekStartByDate(DateTime.UtcNow);
                    if (fieldName == "Day2")
                    {
                        curDate = curDate.AddDays(1);
                    }
                    else if (fieldName == "Day3")
                    {
                        curDate = curDate.AddDays(2);
                    }
                    else if (fieldName == "Day4")
                    {
                        curDate = curDate.AddDays(3);
                    }
                    else if (fieldName == "Day5")
                    {
                        curDate = curDate.AddDays(4);
                    }
                    else if (fieldName == "Day6")
                    {
                        curDate = curDate.AddDays(5);
                    }
                    else if (fieldName == "Day7")
                    {
                        curDate = curDate.AddDays(6);
                    }

                    MainGrid.Columns[i].HeaderText = GetGlobalResourceObject("IbnFramework.TimeTracking", curDate.DayOfWeek.ToString()).ToString();
                }
                else
                {
                    MainGrid.Columns[i].HeaderText = CHelper.GetResFileString(field.FriendlyName);
                }
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();
        }
Example #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DTCWeek.SelectedDate = UserDateTime.UserNow;

            DateTime startDate = DateTime.Parse(Request["uid"], CultureInfo.InvariantCulture);

            lblComment.Text = String.Format(GetGlobalResourceObject("IbnFramework.TimeTracking", "CloneComments").ToString(),
                                            String.Format("<b>#{0}&nbsp;&nbsp;{1} - {2}</b>", Iso8601WeekNumber.GetWeekNumber(startDate).ToString(),
                                                          startDate.ToShortDateString(),
                                                          startDate.AddDays(6).ToShortDateString()));
            if (Request["closeFramePopup"] != null)
            {
                CloseButton.OnClientClick = String.Format(CultureInfo.InvariantCulture, "javascript:try{{window.parent.{0}();}}catch(ex){{}}", Request["closeFramePopup"]);
            }
        }
Example #7
0
        private void BindGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Day1", typeof(string)));
            dt.Columns.Add(new DataColumn("Day2", typeof(string)));
            dt.Columns.Add(new DataColumn("Day3", typeof(string)));
            dt.Columns.Add(new DataColumn("Day4", typeof(string)));
            dt.Columns.Add(new DataColumn("Day5", typeof(string)));
            dt.Columns.Add(new DataColumn("Day6", typeof(string)));
            dt.Columns.Add(new DataColumn("Day7", typeof(string)));
            dt.Columns.Add(new DataColumn("DayT", typeof(string)));
            dt.Columns.Add(new DataColumn("StateFriendlyName", typeof(string)));

            MetaView currentView = GetMetaView();

            currentView.Filters = GetFilters();

            McMetaViewPreference currentPreferences = Mediachase.UI.Web.Util.CommonHelper.CreateDefaultReportPreferenceTimeTracking(currentView);

            MetaObject[] list = null;
            if (String.Compare(Mediachase.IBN.Business.Configuration.Domain, "ibn47.mediachase.net", true) == 0)
            {
                list = currentView.List(currentPreferences, McRoundValues);

                // For Excel
                for (int i = 1; i <= 8; i++)
                {
                    MainGrid.Columns[i].ItemStyle.CssClass = "TdTextClass";
                }
            }
            else
            {
                list = currentView.List(currentPreferences);
            }

            foreach (MetaObject mo in list)
            {
                DataRow row = dt.NewRow();

                string additionalTitle = string.Empty;
                string prefix          = "";
                string postfix         = "";

                if (cbShowWeekNumber.Checked && mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() != MetaViewGroupByType.Total.ToString())
                {
                    DateTime dtNew = DateTime.MinValue;

                    try
                    {
                        dtNew = (DateTime)mo.Properties["Title"].Value;
                    }
                    catch
                    {
                    }

                    if (dtNew != DateTime.MinValue)
                    {
                        additionalTitle = string.Format("(#{0})", Iso8601WeekNumber.GetWeekNumber((DateTime)mo.Properties["Title"].Value));
                    }
                }

                if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Primary.ToString())
                {
                    prefix  = "<b>";
                    postfix = "</b>";
                    if (GroupingList.SelectedValue == GroupingWeekUser)
                    {
                        row["Title"] = String.Format("{0}{1} - {2}{3} {4}", prefix, ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), prefix, additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("{0}{1}{2} {3}", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                    }
                }
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Secondary.ToString())
                {
                    prefix  = "<b>";
                    postfix = "</b>";
                    if (GroupingList.SelectedValue == GroupingUserWeek)
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0}{1} - {2}{3} {4}</div>", prefix, ((DateTime)mo.Properties["Title"].Value).ToString("d MMM yyyy"), ((DateTime)mo.Properties["Title"].Value).AddDays(6).ToString("d MMM yyyy"), prefix, additionalTitle);
                    }
                    else
                    {
                        row["Title"] = String.Format("<div style='padding-left: 25px;'>{0}{1}{2} {3}</div>", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                    }
                }
                else if (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Total.ToString())
                {
                    prefix       = "<b>";
                    postfix      = "</b>";
                    row["Title"] = String.Format("{0}{1}{2} {3}", prefix, mo.Properties["Title"].Value.ToString(), postfix, additionalTitle);
                }
                else
                {
                    row["Title"] = String.Format("<div style='padding-left: 50px;'>{0} {1}</div>", mo.Properties["Title"].Value.ToString(), additionalTitle);
                }

                if (String.Compare(Mediachase.IBN.Business.Configuration.Domain, "ibn47.mediachase.net", true) == 0)
                {
                    if (mo.Properties["MetaViewGroupByType"] == null || (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Total.ToString()) || (mo.Properties["MetaViewGroupByType"] != null && mo.Properties["MetaViewGroupByType"].OriginalValue.ToString() == MetaViewGroupByType.Secondary.ToString()))
                    {
                        row["Day1"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day1"].Value) / 60.0, postfix);
                        row["Day2"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day2"].Value) / 60.0, postfix);
                        row["Day3"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day3"].Value) / 60.0, postfix);
                        row["Day4"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day4"].Value) / 60.0, postfix);
                        row["Day5"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day5"].Value) / 60.0, postfix);
                        row["Day6"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day6"].Value) / 60.0, postfix);
                        row["Day7"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["Day7"].Value) / 60.0, postfix);
                        row["DayT"] = String.Format("{0}{1:F2}{2}", prefix, Convert.ToInt32(mo.Properties["DayT"].Value) / 60.0, postfix);
                    }
                }
                else
                {
                    row["Day1"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day1"].Value) / 60, Convert.ToInt32(mo.Properties["Day1"].Value) % 60, postfix);
                    row["Day2"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day2"].Value) / 60, Convert.ToInt32(mo.Properties["Day2"].Value) % 60, postfix);
                    row["Day3"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day3"].Value) / 60, Convert.ToInt32(mo.Properties["Day3"].Value) % 60, postfix);
                    row["Day4"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day4"].Value) / 60, Convert.ToInt32(mo.Properties["Day4"].Value) % 60, postfix);
                    row["Day5"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day5"].Value) / 60, Convert.ToInt32(mo.Properties["Day5"].Value) % 60, postfix);
                    row["Day6"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day6"].Value) / 60, Convert.ToInt32(mo.Properties["Day6"].Value) % 60, postfix);
                    row["Day7"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["Day7"].Value) / 60, Convert.ToInt32(mo.Properties["Day7"].Value) % 60, postfix);
                    row["DayT"] = String.Format("{0}{1:D2}:{2:D2}{3}", prefix, Convert.ToInt32(mo.Properties["DayT"].Value) / 60, Convert.ToInt32(mo.Properties["DayT"].Value) % 60, postfix);
                }

                if (mo.Properties["StateFriendlyName"].Value != null)
                {
                    row["StateFriendlyName"] = CHelper.GetResFileString(mo.Properties["StateFriendlyName"].Value.ToString());
                }
                else
                {
                    row["StateFriendlyName"] = "";
                }

                dt.Rows.Add(row);
            }

            // Header Text
            for (int i = 0; i < MainGrid.Columns.Count; i++)
            {
                MetaField field     = currentPreferences.GetVisibleMetaField()[i];
                string    fieldName = field.Name;

                // First day of week can be different, so we should specify it.
                if (fieldName == "Day1" || fieldName == "Day2" || fieldName == "Day3" || fieldName == "Day4" || fieldName == "Day5" || fieldName == "Day6" || fieldName == "Day7")
                {
                    DateTime curDate = CHelper.GetRealWeekStartByDate(DateTime.UtcNow);
                    if (fieldName == "Day2")
                    {
                        curDate = curDate.AddDays(1);
                    }
                    else if (fieldName == "Day3")
                    {
                        curDate = curDate.AddDays(2);
                    }
                    else if (fieldName == "Day4")
                    {
                        curDate = curDate.AddDays(3);
                    }
                    else if (fieldName == "Day5")
                    {
                        curDate = curDate.AddDays(4);
                    }
                    else if (fieldName == "Day6")
                    {
                        curDate = curDate.AddDays(5);
                    }
                    else if (fieldName == "Day7")
                    {
                        curDate = curDate.AddDays(6);
                    }

                    MainGrid.Columns[i].HeaderText = GetGlobalResourceObject("IbnFramework.TimeTracking", curDate.DayOfWeek.ToString()).ToString();
                }
                else
                {
                    MainGrid.Columns[i].HeaderText = CHelper.GetResFileString(field.FriendlyName);
                }
            }

            MainGrid.DataSource = dt;
            MainGrid.DataBind();
        }