コード例 #1
0
ファイル: MultipleAdd.ascx.cs プロジェクト: alex765022/IBN
        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"));
        }
コード例 #2
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            DateTime startDate     = DateTime.Parse(Request["uid"], CultureInfo.InvariantCulture);
            DateTime destStartDate = CHelper.GetWeekStartByDate(DTCWeek.SelectedDate);

            if (startDate.Date != destStartDate.Date)
            {
                TimeTrackingEntry[] mas      = TimeTrackingEntry.List(FilterElement.EqualElement("OwnerId", Mediachase.IBN.Business.Security.CurrentUser.UserID), FilterElement.EqualElement("StartDate", startDate));
                List <int>          entryIds = new List <int>();
                foreach (TimeTrackingEntry tte in mas)
                {
                    entryIds.Add((int)tte.PrimaryKeyId.Value);
                }
                if (entryIds.Count > 0)
                {
                    TimeTrackingManager.AddEntries(destStartDate, Mediachase.IBN.Business.Security.CurrentUser.UserID, entryIds);
                }
            }


            // Refresh parent window
            CommandParameters cp = new CommandParameters("MC_TT_CloneWeek");

            Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterCloseOpenedFrameScript(this.Page, cp.ToString());
        }
コード例 #3
0
        private void BindDD()
        {
            BindStates();
            BindDates();
            BindBlocks();
            BindUsers();
            DateTime dt = CHelper.GetWeekStartByDate(DateTime.Now);

            DTCBeg.SelectedDate  = dt;
            DTCEnd.SelectedDate  = dt;
            DTCWeek.SelectedDate = dt;
            if (Request["ProjectId"] != null)
            {
                lblProjTitle.Text = Mediachase.UI.Web.Util.CommonHelper.GetProjectStatus(int.Parse(Request["ProjectId"].ToString()));
            }
        }
コード例 #4
0
        private void BindSavedValues()
        {
            McMetaViewPreference pref = GetMetaViewPreference();

            if (tdProject.Visible)
            {
                CHelper.SafeSelect(ttBlock, pref.GetAttribute <string>(FilterBlockAttr, FilterBlockAttr, "0"));
            }
            if (tdUser.Visible)
            {
                CHelper.SafeSelect(ddUser, pref.GetAttribute <string>(FilterUserAttr, FilterUserAttr, Mediachase.IBN.Business.Security.CurrentUser.UserID.ToString()));
            }
            if (tdPeriod.Visible)
            {
                CHelper.SafeSelect(ddPeriod, pref.GetAttribute <string>("TTFilter_Period", "TTFilter_Period", "[DateTimeThisWeek]"));
                if (ddPeriod.SelectedValue == "0")                                      //week
                {
                    DateTime dt = CHelper.GetWeekStartByDate(pref.GetAttribute <DateTime>("TTFilter_DTCBeg", "TTFilter_DTCBeg", DateTime.Now));
                    DTCBeg.SelectedDate = dt;
                }
                else if (ddPeriod.SelectedValue == "-1")                        //period
                {
                    DateTime dt = CHelper.GetWeekStartByDate(pref.GetAttribute <DateTime>("TTFilter_DTCBeg", "TTFilter_DTCBeg", DateTime.Now));
                    DTCBeg.SelectedDate = dt;
                    dt = CHelper.GetWeekStartByDate(pref.GetAttribute <DateTime>("TTFilter_DTCEnd", "TTFilter_DTCEnd", DateTime.Now));
                    DTCEnd.SelectedDate = dt;
                }
            }
            else if (tdWeek.Visible)
            {
                DateTime dt = CHelper.GetWeekStartByDate(pref.GetAttribute <DateTime>(FilterWeekAttr, FilterWeekAttr, DateTime.Now));
                if (dt == DateTime.MinValue)
                {
                    dt = CHelper.GetWeekStartByDate(DateTime.Now);
                }
                DTCWeek.SelectedDate = dt;

                if (this.Visible)
                {
                    CHelper.AddToContext("SelectedWeek", dt);
                }
            }
            else if (WeekerDiv.Visible)
            {
                DateTime dt = CHelper.GetWeekStartByDate(pref.GetAttribute <DateTime>(FilterWeekAttr, FilterWeekAttr, DateTime.Now));
                if (dt == DateTime.MinValue)
                {
                    dt = CHelper.GetWeekStartByDate(DateTime.Now);
                }
                DTCWeeker.SelectedDate = dt;

                if (this.Visible)
                {
                    CHelper.AddToContext("SelectedWeek", dt);
                }
            }

            if (tdState.Visible)
            {
                CHelper.SafeSelect(ddState, pref.GetAttribute <string>(FilterStateAttr, FilterStateAttr, "0"));
            }
        }
コード例 #5
0
        private void BindFilters()
        {
            if (!this.Visible)
            {
                return;
            }

            McMetaViewPreference mvPref = GetMetaViewPreference();

            // O.R.: It's expected that the TTFilterPopupEdit is the only filter control on the page, which uses MetaViewPrefrences filters
            mvPref.Filters.Clear();

            FilterElement filter = null;

            if (tdPeriod.Visible)
            {
                switch (ddPeriod.SelectedValue)
                {
                case "[DateTimeThisWeek]":
                    filter = new FilterElement("StartDate", FilterElementType.Equal, CHelper.GetWeekStartByDate(DateTime.Today));
                    break;

                case "[DateTimeLastWeek]":
                    filter = new FilterElement("StartDate", FilterElementType.Equal, CHelper.GetWeekStartByDate(DateTime.Today.AddDays(-7)));
                    break;

                case "[DateTimeThisMonth]":
                    filter = new IntervalFilterElement("StartDate", CHelper.GetWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.Day)), CHelper.GetWeekStartByDate(DateTime.Today));
                    break;

                case "[DateTimeLastMonth]":
                    filter = new IntervalFilterElement("StartDate", CHelper.GetWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.Day).AddMonths(-1)), CHelper.GetWeekStartByDate(DateTime.Today.AddDays(-DateTime.Now.Day)));
                    break;

                case "[DateTimeThisYear]":
                    filter = new IntervalFilterElement("StartDate", CHelper.GetWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.DayOfYear)), CHelper.GetWeekStartByDate(DateTime.Today));
                    break;

                case "[DateTimeLastYear]":
                    filter = new IntervalFilterElement("StartDate", CHelper.GetWeekStartByDate(DateTime.Today.AddDays(1 - DateTime.Now.DayOfYear).AddYears(-1)), CHelper.GetWeekStartByDate(DateTime.Today.AddDays(-DateTime.Now.DayOfYear)));
                    break;

                case "0":
                    DateTime dt = DTCBeg.SelectedDate;
                    filter = new FilterElement("StartDate", FilterElementType.Equal, CHelper.GetWeekStartByDate(dt));
                    break;

                case "-1":
                    DateTime dt1 = DTCBeg.SelectedDate;
                    DateTime dt2 = DTCEnd.SelectedDate;
                    filter = new IntervalFilterElement("StartDate", CHelper.GetWeekStartByDate(dt1), CHelper.GetWeekStartByDate(dt2));
                    break;

                default:
                    break;
                }
            }
            else if (tdWeek.Visible)
            {
                DateTime dt = DTCWeek.SelectedDate;
                filter = new FilterElement("StartDate", FilterElementType.Equal, CHelper.GetWeekStartByDate(dt));
            }
            else if (WeekerDiv.Visible)
            {
                DateTime dt = DTCWeeker.SelectedDate;
                filter = new FilterElement("StartDate", FilterElementType.Equal, CHelper.GetWeekStartByDate(dt));
            }

            if (filter != null)
            {
                mvPref.Filters.Add(filter);
            }

            if (tdUser.Visible && ddUser.SelectedItem != null && ddUser.SelectedValue != "0")
            {
                filter = new FilterElement("OwnerId", FilterElementType.Equal, int.Parse(ddUser.SelectedValue));
                mvPref.Filters.Add(filter);
            }

            if (ttBlock.Visible && ttBlock.SelectedItem != null && ttBlock.SelectedValue != "0")
            {
                filter = new FilterElement("BlockTypeInstanceId", FilterElementType.Equal, int.Parse(ttBlock.SelectedValue));
                mvPref.Filters.Add(filter);
            }

            if (tdState.Visible && ddState.SelectedValue != "0")
            {
                filter = new FilterElement("StateFriendlyName", FilterElementType.Equal, ddState.SelectedValue);
                mvPref.Filters.Add(filter);
            }

            //Mediachase.Ibn.Core.UserMetaViewPreference.Save(Mediachase.IBN.Business.Security.CurrentUser.UserID, mvPref);
        }