예제 #1
0
        /// <summary>
        /// Deletes a stage record and reloads Organization's summary page.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void DeleteStage(object sender, EventArgs e)
        {
            // Delete assocaited events
            //ProjectStageEvent events = new ProjectStageEvent();
            //events.GetByParent(stageId);
            //int[] deleteKeys = new int[events.DataSourceView.Table.Rows.Count];

            DataTable table = BusinessObject.GetByParentAsDataView <ProjectStageEvent>(stageId).Table;

            int[] deleteKeys = new int[table.Rows.Count];
            //for (int i = 0; i < events.DataSourceView.Table.Rows.Count; i++)
            for (int i = 0; i < table.Rows.Count; i++)
            {
                //DataRow row = events.DataSourceView.Table.Rows[i];
                DataRow row     = table.Rows[i];
                int     eventId = int.Parse(row[ProjectStageEvent.StageEventId].ToString());
                deleteKeys[i] = eventId;
            }
            foreach (int eventId in deleteKeys)
            {
                //events.Delete(eventId);
                ProjectStageEvent ev = new ProjectStageEvent();
                ev.Delete(eventId);
            }

            // Finally delete Stage.
            ProjectStage biz = new ProjectStage();

            biz.Delete(stageId);

            // Call client script which loads summary section and hilights summary in navigation
            RegisterPageReload();
        }
예제 #2
0
        // TODO: refactor into controller
        private void Delete(bool preview)
        {
            // only module admin can delete projects
            if (!preview && UserType == ProjectMgmtUsers.ModuleAdmin)
            {
                // biz objects for deleting
                Project               projectBiz   = new Project();
                ProjectStage          stageBiz     = new ProjectStage();
                ProjectStageEvent     eventBiz     = new ProjectStageEvent();
                ProjectEventAttribute attributeBiz = new ProjectEventAttribute();

                // delete bottom -> up
                foreach (ProjectStage stage in BOL.BusinessObject.GetByParent <ProjectStage>(projectId))
                {
                    int stageId = (int)stage[stage.PrimaryKeyName];
                    foreach (ProjectStageEvent evt in BOL.BusinessObject.GetByParent <ProjectStageEvent>(stageId))
                    {
                        int eventId = (int)evt[evt.PrimaryKeyName];
                        foreach (ProjectEventAttribute attribute in BOL.BusinessObject.GetByParent <ProjectEventAttribute>(eventId))
                        {
                            int attributeId = (int)attribute[attribute.PrimaryKeyName];
                            // delete attribute
                            attributeBiz.Delete(attributeId);
                        }
                        // delete event
                        eventBiz.Delete(eventId);
                    }
                    // delete stage
                    stageBiz.Delete(stageId);
                }
                // delete project
                projectBiz.Delete(projectId);

                // reload browser
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "refreshBrowser", "window.top.location = window.top.location;", true);
            }
        }