Example #1
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            DateTime localDate     = IBN45Business.User.GetLocalDate(DateTime.UtcNow);
            DateTime destStartDate = IBN45Business.TimeTracking.GetWeekStart(localDate);

            List <int> entryIdList = new List <int>();

            foreach (DataGridItem dgi in MainGrid.Items)
            {
                CheckBox cb = (CheckBox)dgi.FindControl("chkElement");
                if (cb != null && cb.Checked && dgi.Cells[1].Text != ProjectObjectType.ToString(CultureInfo.InvariantCulture))
                {
                    entryIdList.Add(int.Parse(dgi.Cells[0].Text, CultureInfo.InvariantCulture));
                }
            }
            TimeTrackingManager.AddEntries(destStartDate, Mediachase.Ibn.Data.Services.Security.CurrentUserId, entryIdList);

            // After rebind the selected items will be disappeared.
            BindGrid();

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

            Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterRefreshParentFromFrameScript(this.Page, cp.ToString());
        }
Example #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());
        }
Example #3
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            List <int>    objects            = new List <int>();
            List <int>    objectTypes        = new List <int>();
            List <string> titles             = new List <string>();
            List <int>    blockTypeInstances = new List <int>();

            foreach (DataGridItem dgi in MainGrid.Items)
            {
                CheckBox cb = (CheckBox)dgi.FindControl("chkElement");
                if (cb != null && cb.Checked && dgi.Cells[1].Text != ProjectObjectType.ToString(CultureInfo.InvariantCulture))
                {
                    objects.Add(int.Parse(dgi.Cells[0].Text, CultureInfo.InvariantCulture));
                    objectTypes.Add(int.Parse(dgi.Cells[1].Text, CultureInfo.InvariantCulture));
                    titles.Add(cb.Text);
                    blockTypeInstances.Add(int.Parse(dgi.Cells[2].Text, CultureInfo.InvariantCulture));
                }
            }

            if (objects.Count > 0)
            {
                DateTime startDate = DTCWeek.SelectedDate;
                //if (startDate == DateTime.MinValue)
                //    startDate = CHelper.GetWeekStartByDate(DTCWeek.Value);

                if (BlockInstanceList.SelectedValue != "0")
                {
                    TimeTrackingManager.AddEntries(
                        int.Parse(BlockInstanceList.SelectedValue, CultureInfo.InvariantCulture),
                        startDate,
                        int.Parse(UserList.SelectedValue, CultureInfo.InvariantCulture),
                        objects, objectTypes, titles);
                }
                else                  // Multiple projects
                {
                    TimeTrackingManager.AddEntries(
                        startDate,
                        int.Parse(UserList.SelectedValue, CultureInfo.InvariantCulture),
                        objects, objectTypes, titles, blockTypeInstances);
                }
            }

            // After rebind the selected items will be disappeared.
            BindGrid();

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

            Mediachase.Ibn.Web.UI.WebControls.CommandHandler.RegisterRefreshParentFromFrameScript(this.Page, cp.ToString());
        }
Example #4
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);
                }
            }
        }