Ejemplo n.º 1
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            DateTime dt = CHelper.GetRealWeekStartByDate(DateTime.Now);

            btnCurrentWeek.Enabled = (dt != dtcWeek.SelectedDate);
            this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), new Guid().ToString(), generateExcelScript(), true);
        }
Ejemplo n.º 2
0
        void btnCurrentWeek_Click(object sender, EventArgs e)
        {
            DateTime dt = CHelper.GetRealWeekStartByDate(DateTime.Now);

            dtcWeek.SelectedDate = dt;

            OnValueChange(sender, e);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handles the ValueChange event of the dtcWeek control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void dtcWeek_ValueChange(object sender, EventArgs e)
        {
            DateTime dt = CHelper.GetRealWeekStartByDate(dtcWeek.SelectedDate);

            dtcWeek.SelectedDate = dt;

            OnValueChange(sender, e);
        }
Ejemplo n.º 4
0
        void imgNext_Click(object sender, ImageClickEventArgs e)
        {
            UpdateCM();
            DateTime dt = CHelper.GetRealWeekStartByDate(dtcWeek.SelectedDate.AddDays(7));

            dtcWeek.SelectedDate = dt;

            OnValueChange(sender, e);
        }
Ejemplo n.º 5
0
        private void BindDD()
        {
            // Group
            GroupingList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.TimeTracking", "GroupingWeekUser").ToString(), GroupingWeekUser));
            GroupingList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.TimeTracking", "GroupingUserWeek").ToString(), GroupingUserWeek));

            // Projects
            string titledFieldName = TimeTrackingManager.GetBlockTypeInstanceMetaClass().TitleFieldName;

            foreach (TimeTrackingBlockTypeInstance bo in TimeTrackingManager.GetProjectBlockTypeInstances())
            {
                ListItem li = new ListItem(bo.Properties[titledFieldName].Value.ToString(), bo.PrimaryKeyId.ToString());
                ProjectList.Items.Add(li);
            }

            if (ProjectList.Items.Count <= 0)
            {
                NoProjectsDiv.Visible = true;
                PanelFilters.Visible  = false;
                return;
            }
            else
            {
                NoProjectsDiv.Visible = false;
            }

            // Users
            UserList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.Global:_mc_All}"), "0"));
            Principal[] mas = Principal.List(new FilterElementCollection(FilterElement.EqualElement("Card", "User"), FilterElement.EqualElement("Activity", 3)), new SortingElementCollection(new SortingElement("Name", SortingElementType.Asc)));
            foreach (Principal pl in mas)
            {
                UserList.Items.Add(new ListItem(pl.Name, pl.PrimaryKeyId.ToString()));
            }

            // 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"));

            Dtc1.SelectedDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
            Dtc2.SelectedDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
        }
Ejemplo n.º 6
0
        public bool IsEnable(object Sender, object Element)
        {
            bool   retval = false;
            object obj    = CHelper.GetFromContext("SelectedWeek");

            if (obj != null)
            {
                DateTime selectedWeek = (DateTime)obj;

                if (selectedWeek == CHelper.GetRealWeekStartByDate(DateTime.UtcNow))
                {
                    retval = true;
                }
            }
            return(retval);
        }
Ejemplo n.º 7
0
        void BindDates()
        {
            ddPeriod.Items.Clear();
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_Any}"), "[DateTimeThisAny]"));
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_ThisWeek}"), "[DateTimeThisWeek]"));
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_LastWeek}"), "[DateTimeLastWeek]"));
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_ThisMonth}"), "[DateTimeThisMonth]"));
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_LastMonth}"), "[DateTimeLastMonth]"));
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_ThisYear}"), "[DateTimeThisYear]"));
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_LastYear}"), "[DateTimeLastYear]"));
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_CustomWeek}"), "0"));
            ddPeriod.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_CustomPeriod}"), "-1"));

            Dtc1.SelectedDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
            Dtc2.SelectedDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
        }
Ejemplo n.º 8
0
        private bool Process()
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return(false);
            }

            int blockTypeInstanceId = int.Parse(ProjectList.SelectedValue);

            if (blockTypeInstanceId < 0)
            {
                lblError2.Style.Add("display", "");
                return(false);
            }

            McMetaViewPreference pref      = CHelper.GetMetaViewPreference(CurrentView);
            DateTime             startDate = CHelper.GetRealWeekStartByDate(pref.GetAttribute <DateTime>(TTFilterPopupEdit.FilterWeekAttr, TTFilterPopupEdit.FilterWeekAttr, DateTime.Today));

            if (startDate == DateTime.MinValue)
            {
                startDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
            }

            double maxMinutes = (double)(24 * 60);

            TimeTrackingManager.AddEntryWithData(blockTypeInstanceId,
                                                 startDate,
                                                 Mediachase.IBN.Business.Security.CurrentUser.UserID,
                                                 txtEntry.Text,
                                                 Math.Min((new TimeSpan(Day1Time.Value.Ticks)).TotalMinutes, maxMinutes),
                                                 Math.Min((new TimeSpan(Day2Time.Value.Ticks)).TotalMinutes, maxMinutes),
                                                 Math.Min((new TimeSpan(Day3Time.Value.Ticks)).TotalMinutes, maxMinutes),
                                                 Math.Min((new TimeSpan(Day4Time.Value.Ticks)).TotalMinutes, maxMinutes),
                                                 Math.Min((new TimeSpan(Day5Time.Value.Ticks)).TotalMinutes, maxMinutes),
                                                 Math.Min((new TimeSpan(Day6Time.Value.Ticks)).TotalMinutes, maxMinutes),
                                                 Math.Min((new TimeSpan(Day7Time.Value.Ticks)).TotalMinutes, maxMinutes));

            BindNullValues();

            return(true);
        }
Ejemplo n.º 9
0
        public void Invoke(object Sender, object Element)
        {
            if (Element is CommandParameters)
            {
                CommandParameters cp    = (CommandParameters)Element;
                string[]          elems = MetaGridServer.GetCheckedCollection(((CommandManager)Sender).Page, cp.CommandArguments["GridId"]);

                DateTime   weekStart = CHelper.GetRealWeekStartByDate(DateTime.Now).Date;
                List <int> entryIds  = new List <int>();

                foreach (string elem in elems)
                {
                    //int id = Convert.ToInt32(elem, CultureInfo.InvariantCulture);
                    string type = elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[1];
                    if (type == MetaViewGroupUtil.keyValueNotDefined)
                    {
                        continue;
                    }

                    int id = Convert.ToInt32(elem.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries)[0], CultureInfo.InvariantCulture);


                    if (type == TimeTrackingEntry.GetAssignedMetaClass().Name)
                    {
                        //if clone current week then abort
                        TimeTrackingEntry tte = MetaObjectActivator.CreateInstance <TimeTrackingEntry>(TimeTrackingEntry.GetAssignedMetaClass(), id);
                        if (weekStart == tte.StartDate)
                        {
                            throw new ArgumentException(CHelper.GetResFileString("{IbnFramework.TimeTracking:_mc_UnableToCloneMsg}"));
                        }

                        entryIds.Add(id);
                    }
                }

                if (entryIds.Count > 0)
                {
                    TimeTrackingManager.AddEntries(weekStart, Mediachase.IBN.Business.Security.CurrentUser.UserID, entryIds);
                }
            }
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
        void grdMain_ChangingMCGridColumnHeader(object sender, ChangingMCGridColumnHeaderEventArgs e)
        {
            string fieldName = e.FieldName;

            if (fieldName == "Day1" || fieldName == "Day2" || fieldName == "Day3" || fieldName == "Day4" || fieldName == "Day5" || fieldName == "Day6" || fieldName == "Day7")
            {
                DateTime dt = CHelper.GetRealWeekStartByDate(DateTime.UtcNow);

                if (fieldName == "Day2")
                {
                    dt = dt.AddDays(1);
                }
                else if (fieldName == "Day3")
                {
                    dt = dt.AddDays(2);
                }
                else if (fieldName == "Day4")
                {
                    dt = dt.AddDays(3);
                }
                else if (fieldName == "Day5")
                {
                    dt = dt.AddDays(4);
                }
                else if (fieldName == "Day6")
                {
                    dt = dt.AddDays(5);
                }
                else if (fieldName == "Day7")
                {
                    dt = dt.AddDays(6);
                }

                e.ControlField.HeaderText = GetGlobalResourceObject("IbnFramework.TimeTracking", dt.DayOfWeek.ToString()).ToString();
            }
        }
Ejemplo n.º 12
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();
        }
Ejemplo n.º 13
0
        private void BindDD()
        {
            // Group
            GroupingList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.TimeTracking", "GroupingWeekUser").ToString(), GroupingWeekUser));
            GroupingList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.TimeTracking", "GroupingUserWeek").ToString(), GroupingUserWeek));

            // Projects
            bool   isPpmExec       = Mediachase.IBN.Business.Security.IsUserInGroup(InternalSecureGroups.PowerProjectManager) || Mediachase.IBN.Business.Security.IsUserInGroup(InternalSecureGroups.ExecutiveManager);
            string titledFieldName = TimeTrackingManager.GetBlockTypeInstanceMetaClass().TitleFieldName;

            foreach (TimeTrackingBlockTypeInstance bo in TimeTrackingManager.GetProjectBlockTypeInstances())
            {
                // Условия для того, чтобы BlockTypeInstances попал в список:
                //	- он должен быть связан с проектом
                //	- у него должны быть активны финансы
                //	- текущий пользователь - либо PPM/Exec, либо менеджер/исп.менеджер проекта

                if (bo.ProjectId.HasValue)
                {
                    int projectId = bo.ProjectId.Value;

                    if (ProjectSpreadSheet.IsActive(projectId))
                    {
                        bool add = false;
                        if (isPpmExec)
                        {
                            add = true;
                        }
                        else
                        {
                            Project.ProjectSecurity ps = Project.GetSecurity(projectId);
                            if (ps.IsManager || ps.IsExecutiveManager)
                            {
                                add = true;
                            }
                        }

                        if (add)
                        {
                            ListItem li = new ListItem(bo.Properties[titledFieldName].Value.ToString(), bo.PrimaryKeyId.ToString());
                            ProjectList.Items.Add(li);
                        }
                    }
                }
            }

            if (ProjectList.Items.Count <= 0)
            {
                NoProjectsDiv.Visible = true;
                PanelFilters.Visible  = false;
                return;
            }
            else
            {
                NoProjectsDiv.Visible = false;
            }

            // Users
            UserList.Items.Add(new ListItem(CHelper.GetResFileString("{IbnFramework.Global:_mc_All}"), "0"));
            Principal[] mas = Principal.List(new FilterElementCollection(FilterElement.EqualElement("Card", "User"), FilterElement.EqualElement("Activity", 3)), new SortingElementCollection(new SortingElement("Name", SortingElementType.Asc)));
            foreach (Principal pl in mas)
            {
                UserList.Items.Add(new ListItem(pl.Name, pl.PrimaryKeyId.ToString()));
            }

            // 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"));

            Dtc1.SelectedDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
            Dtc2.SelectedDate = CHelper.GetRealWeekStartByDate(DateTime.Today);
        }
Ejemplo n.º 14
0
        private FilterElementCollection GetFilters()
        {
            FilterElementCollection filters = new FilterElementCollection();

            filters.Add(FilterElement.EqualElement("BlockTypeInstanceId", int.Parse(ProjectList.SelectedValue)));

            if (UserList.SelectedValue != "0")
            {
                filters.Add(FilterElement.EqualElement("OwnerId", int.Parse(UserList.SelectedValue)));
            }

            DateTime dt1, dt2;

            switch (PeriodList.SelectedValue)
            {
            case "[DateTimeThisAny]":
                break;

            case "[DateTimeThisWeek]":
                dt1 = CHelper.GetRealWeekStartByDate(DateTime.Today);
                filters.Add(FilterElement.EqualElement("StartDate", dt1));
                break;

            case "[DateTimeLastWeek]":
                dt1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(-7));
                filters.Add(FilterElement.EqualElement("StartDate", dt1));
                break;

            case "[DateTimeThisMonth]":
                dt1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.Day));
                dt2 = CHelper.GetRealWeekStartByDate(DateTime.Today);
                filters.Add(new IntervalFilterElement("StartDate", dt1, dt2));
                break;

            case "[DateTimeLastMonth]":
                dt1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.Day).AddMonths(-1));
                dt2 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(-DateTime.Now.Day));
                filters.Add(new IntervalFilterElement("StartDate", dt1, dt2));
                break;

            case "[DateTimeThisYear]":
                dt1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.DayOfYear));
                dt2 = CHelper.GetRealWeekStartByDate(DateTime.Today);
                filters.Add(new IntervalFilterElement("StartDate", dt1, dt2));
                break;

            case "[DateTimeLastYear]":
                dt1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.DayOfYear).AddYears(-1));
                dt2 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(-DateTime.Now.DayOfYear));
                filters.Add(new IntervalFilterElement("StartDate", dt1, dt2));
                break;

            case "0":
                filters.Add(FilterElement.EqualElement("StartDate", Dtc1.SelectedDate));
                break;

            case "-1":
                filters.Add(new IntervalFilterElement("StartDate", Dtc1.SelectedDate, Dtc2.SelectedDate));
                break;

            default:
                break;
            }
            filters.Add(FilterElement.EqualElement("AreFinancesRegistered", true));

            // exclude zero values
            filters.Add(new FilterElement("Cost", FilterElementType.Greater, 0));

            return(filters);
        }
Ejemplo n.º 15
0
        void ddPeriod_SelectedIndexChanged(object sender, EventArgs e)
        {
            tdDate1.Style.Add("visibility", "hidden");
            tdDate2.Style.Add("visibility", "hidden");

            switch (ddPeriod.SelectedValue)
            {
            case "[DateTimeThisAny]":
                this.FilterData1 = DateTime.MinValue;
                this.FilterData2 = DateTime.MinValue;
                break;

            case "[DateTimeThisWeek]":
                this.FilterData1 = CHelper.GetRealWeekStartByDate(DateTime.Today);
                this.FilterData2 = DateTime.MinValue;
                break;

            case "[DateTimeLastWeek]":
                this.FilterData1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(-7));
                this.FilterData2 = DateTime.MinValue;
                break;

            case "[DateTimeThisMonth]":
                this.FilterData1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.Day));
                this.FilterData2 = CHelper.GetRealWeekStartByDate(DateTime.Today);
                break;

            case "[DateTimeLastMonth]":
                this.FilterData1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.Day).AddMonths(-1));
                this.FilterData2 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(-DateTime.Now.Day));
                break;

            case "[DateTimeThisYear]":
                this.FilterData1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.DayOfYear));
                // OR: why should we lose the current week?
                //this.FilterData2 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(-DateTime.Now.Day));
                this.FilterData2 = CHelper.GetRealWeekStartByDate(DateTime.Today);
                break;

            case "[DateTimeLastYear]":
                this.FilterData1 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.DayOfYear).AddYears(-1));
                this.FilterData2 = CHelper.GetRealWeekStartByDate(DateTime.Today.AddDays(-DateTime.Now.DayOfYear));
                break;

            case "0":
                tdDate1.Style.Add("visibility", "visible");

                this.FilterData1 = Dtc1.SelectedDate;
                this.FilterData2 = DateTime.MinValue;
                break;

            case "-1":
                tdDate1.Style.Add("visibility", "visible");
                tdDate2.Style.Add("visibility", "visible");

                this.FilterData1 = Dtc1.SelectedDate;
                this.FilterData2 = Dtc2.SelectedDate;
                break;

            default:
                break;
            }
        }
Ejemplo n.º 16
0
        private void BindBlocks()
        {
            ProjectList.Items.Clear();

            string titledFieldName = TimeTrackingManager.GetBlockTypeInstanceMetaClass().TitleFieldName;

            McMetaViewPreference pref      = CHelper.GetMetaViewPreference(CurrentView);
            DateTime             startDate = CHelper.GetRealWeekStartByDate(pref.GetAttribute <DateTime>(TTFilterPopupEdit.FilterWeekAttr, TTFilterPopupEdit.FilterWeekAttr, DateTime.MinValue));

            if (startDate == DateTime.MinValue)
            {
                startDate = CHelper.GetRealWeekStartByDate(DateTime.Now);
            }
            int ownerId = Mediachase.IBN.Business.Security.CurrentUser.UserID;

            BindDayHeaders(startDate);

            // Non-project
            #region 1. Make the list of all BlockTypeInstances
            List <int> idList = new List <int>();
            Dictionary <int, string> allList = new Dictionary <int, string>();
            foreach (TimeTrackingBlockTypeInstance item in TimeTrackingManager.GetNonProjectBlockTypeInstances())
            {
                idList.Add(item.PrimaryKeyId.Value);
                allList.Add(item.PrimaryKeyId.Value, item.Title);
            }
            #endregion

            #region 2. Check the rights AddMyTTBlock and AddAnyTTBlock and remove from the allList the forbidden items
            SerializableDictionary <int, Collection <string> > objectRights = Mediachase.Ibn.Data.Services.Security.GetAllowedRights(TimeTrackingBlockTypeInstance.GetAssignedMetaClass(), idList.ToArray());
            foreach (KeyValuePair <int, Collection <string> > item in objectRights)
            {
                int id = item.Key;
                Collection <string> allowedRights = item.Value;

                if (!((allowedRights.Contains(TimeTrackingManager.Right_AddMyTTBlock) && ownerId == Mediachase.Ibn.Data.Services.Security.CurrentUserId) || allowedRights.Contains(TimeTrackingManager.Right_AddAnyTTBlock)))
                {
                    allList.Remove(id);
                }
            }
            #endregion

            #region 3. Make the list of the TimeTrackingBlocks by OwnerId, StartDate and BlockTypeInstanceId[]
            List <string> blockTypeInstanceIdList = new List <string>();
            foreach (int id in allList.Keys)
            {
                blockTypeInstanceIdList.Add(id.ToString(CultureInfo.InvariantCulture));
            }

            List <int>            blockIdList       = new List <int>();
            Dictionary <int, int> blockInstanceList = new Dictionary <int, int>();

            TimeTrackingBlock[] blocks = TimeTrackingBlock.List(
                FilterElement.EqualElement("OwnerId", ownerId),
                FilterElement.EqualElement("StartDate", startDate),
                new FilterElement("BlockTypeInstanceId", FilterElementType.In, blockTypeInstanceIdList.ToArray())
                );
            foreach (TimeTrackingBlock block in blocks)
            {
                blockIdList.Add(block.PrimaryKeyId.Value);
                blockInstanceList.Add(block.PrimaryKeyId.Value, block.BlockTypeInstanceId);
            }
            #endregion

            #region 4. Check the right Write and remove from the allList the forbidden items
            objectRights = Mediachase.Ibn.Data.Services.Security.GetAllowedRights(TimeTrackingBlock.GetAssignedMetaClass(), blockIdList.ToArray());
            foreach (KeyValuePair <int, Collection <string> > item in objectRights)
            {
                int id = item.Key;
                Collection <string> allowedRights = item.Value;

                if (!allowedRights.Contains(Mediachase.Ibn.Data.Services.Security.RightWrite))
                {
                    allList.Remove(blockInstanceList[id]);
                }
            }
            #endregion

            #region 5. Fill in the dropdown
            if (allList.Count > 0)
            {
                ProjectList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.TimeTracking", "ByActivity").ToString(), "-1"));

                foreach (KeyValuePair <int, string> item in allList)
                {
                    ListItem li = new ListItem("   " + item.Value, item.Key.ToString());
                    ProjectList.Items.Add(li);
                }
            }
            #endregion


            // Projects
            #region 1. Make the list of all BlockTypeInstances
            idList  = new List <int>();
            allList = new Dictionary <int, string>();
            foreach (TimeTrackingBlockTypeInstance item in TimeTrackingManager.GetProjectBlockTypeInstances())
            {
                idList.Add(item.PrimaryKeyId.Value);
                allList.Add(item.PrimaryKeyId.Value, item.Title);
            }
            #endregion

            #region 2. Check the rights AddMyTTBlock and AddAnyTTBlock and remove from the allList the forbidden items
            objectRights = Mediachase.Ibn.Data.Services.Security.GetAllowedRights(TimeTrackingBlockTypeInstance.GetAssignedMetaClass(), idList.ToArray());
            foreach (KeyValuePair <int, Collection <string> > item in objectRights)
            {
                int id = item.Key;
                Collection <string> allowedRights = item.Value;

                if (!((allowedRights.Contains(TimeTrackingManager.Right_AddMyTTBlock) && ownerId == Mediachase.Ibn.Data.Services.Security.CurrentUserId) || allowedRights.Contains(TimeTrackingManager.Right_AddAnyTTBlock)))
                {
                    allList.Remove(id);
                }
            }
            #endregion

            #region 3. Make the list of the TimeTrackingBlocks by OwnerId, StartDate and BlockTypeInstanceId[]
            blockTypeInstanceIdList = new List <string>();
            foreach (int id in allList.Keys)
            {
                blockTypeInstanceIdList.Add(id.ToString(CultureInfo.InvariantCulture));
            }

            blockIdList       = new List <int>();
            blockInstanceList = new Dictionary <int, int>();

            blocks = TimeTrackingBlock.List(
                FilterElement.EqualElement("OwnerId", ownerId),
                FilterElement.EqualElement("StartDate", startDate),
                new FilterElement("BlockTypeInstanceId", FilterElementType.In, blockTypeInstanceIdList.ToArray())
                );
            foreach (TimeTrackingBlock block in blocks)
            {
                blockIdList.Add(block.PrimaryKeyId.Value);
                blockInstanceList.Add(block.PrimaryKeyId.Value, block.BlockTypeInstanceId);
            }
            #endregion

            #region 4. Check the right Write and remove from the allList the forbidden items
            objectRights = Mediachase.Ibn.Data.Services.Security.GetAllowedRights(TimeTrackingBlock.GetAssignedMetaClass(), blockIdList.ToArray());
            foreach (KeyValuePair <int, Collection <string> > item in objectRights)
            {
                int id = item.Key;
                Collection <string> allowedRights = item.Value;

                if (!allowedRights.Contains(Mediachase.Ibn.Data.Services.Security.RightWrite))
                {
                    allList.Remove(blockInstanceList[id]);
                }
            }
            #endregion

            #region 5. Fill in the dropdown
            if (allList.Count > 0)
            {
                ProjectList.Items.Add(new ListItem(GetGlobalResourceObject("IbnFramework.TimeTracking", "ByProject").ToString(), "-2"));

                foreach (KeyValuePair <int, string> item in allList)
                {
                    ListItem li = new ListItem("   " + item.Value, item.Key.ToString());
                    ProjectList.Items.Add(li);
                }
            }
            #endregion

            if (blockInstanceId > 0)
            {
                CHelper.SafeSelect(ProjectList, blockInstanceId.ToString());
            }

            EnsureSelectInstance();
        }
Ejemplo n.º 17
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;
        }
Ejemplo n.º 18
0
        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();
        }