Ejemplo n.º 1
0
        /// <summary>
        /// Builds a stage level Gant Chart where each item represents an event of the stage.
        /// </summary>
        /// <param name="chart"></param>
        /// <param name="stageId"></param>
        public static void BuildStageLevelGantChart(GantChart chart, int stageId)
        {
            chart.Controls.Clear();

            ProjectStage stageBiz = new ProjectStage();

            stageBiz.Get(stageId);

            string gantTitle = stageBiz[ProjectStage.Name].ToString() + " [Events]";

            chart.GantTitle = gantTitle;


            string stageColor = stageBiz[ProjectStage.ColorCode].ToString();

            //ProjectStageEvent biz = new ProjectStageEvent();
            //biz.GetByParent(stageId);
            //foreach (DataRow stageEventRecord in biz.DataSourceView.Table.Rows)

            DataView view = BusinessObject.GetByParentAsDataView <ProjectStageEvent>(stageId);

            foreach (DataRow stageEventRecord in view.Table.Rows)
            {
                string   stageEventName = stageEventRecord[ProjectStageEvent.Name].ToString();
                DateTime startDate      = DateTime.MinValue;
                DateTime endDate        = DateTime.MaxValue;
                if (stageEventRecord[ProjectStageEvent.EventStartDate] != null)
                {
                    string dateString = stageEventRecord[ProjectStageEvent.EventStartDate].ToString();
                    if (!string.IsNullOrEmpty(dateString))
                    {
                        startDate = DateTime.Parse(dateString);
                    }
                }
                if (stageEventRecord[ProjectStageEvent.EventEndDate] != null)
                {
                    string dateString = stageEventRecord[ProjectStageEvent.EventEndDate].ToString();
                    if (!string.IsNullOrEmpty(dateString))
                    {
                        endDate = DateTime.Parse(dateString);
                    }
                }
                if (!(startDate == DateTime.MinValue && endDate == DateTime.MaxValue))
                {
                    GantItem item = new GantItem(startDate, endDate);
                    item.Description = stageEventName;
                    string startText = startDate.ToShortDateString();
                    string endText   = endDate.ToShortDateString();
                    item.ToolTip = "Start Date: " + startText + " - End Date: " + endText;

                    // Color item based on it's parent stage.
                    if (!string.IsNullOrEmpty(stageColor))
                    {
                        item.Color = stageColor;
                    }
                    chart.Controls.Add(item);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the Stage record as well as child events and their atttibutes
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void UpdateStageRecord(object sender, EventArgs e)
        {
            // Register script must be called here, as no stage id has been assinged,i.e., new record
            RegisterUpdateScript(sender, e);

            // Determine if an insert/update
            ProjectStage stageBiz = new ProjectStage();

            // Only do update/insert on Stage record if dirty
            if (recordIsDirty)
            {
                if (recordIsDirty && !string.IsNullOrEmpty(StageId.Value))
                {
                    stageBiz.Get(int.Parse(StageId.Value));
                }
                // Set stage fields
                stageBiz[ProjectStage.ProjectId] = projectId;
                if (!string.IsNullOrEmpty(OrganizationId))
                {
                    stageBiz[ProjectStage.OrganizationId] = OrganizationId;
                }
                stageBiz[ProjectStage.Name]      = StageName.Value;
                stageBiz[ProjectStage.ColorCode] = ColorCode.Value;
                stageBiz.Save();

                string bizStageId = stageBiz[ProjectStage.StageId].ToString();
                StageId.Value = bizStageId;
            }
            // Run save on Events and Details grid only if a parent stage record exits
            if (!string.IsNullOrEmpty(StageId.Value))
            {
                int stageId = int.Parse(StageId.Value);
                EventsGrid.Save(stageId);
                BindStageRecord();
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Binds the field to Stage record and grid to child events and attributes
        /// </summary>
        private void BindStageRecord()
        {
            int stageId = int.Parse(StageId.Value);

            ProjectStage biz = new ProjectStage();

            biz.Get(stageId);
            StageName.Value = biz[ProjectStage.Name].ToString();
            string color = biz[ProjectStage.ColorCode].ToString();

            ColorCode.Value = color;
            if (!string.IsNullOrEmpty(color))
            {
                ColorCodeBox.Style[HtmlTextWriterStyle.BackgroundColor] = color;
                ColorCodeBox.ToolTip = "Color: " + color;
            }

            //ProjectStageEvent projectEventsBiz = new ProjectStageEvent();
            //projectEventsBiz.GetByParent(stageId);

            //EventsGrid.DataSource = projectEventsBiz.DataSourceView;
            EventsGrid.DataSource = BusinessObject.GetByParentAsDataView <ProjectStageEvent>(stageId);
            EventsGrid.DataBind();
        }