/// <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(); }
/// <summary> /// When an organization's event checkbox is checked, it will create a /// new event record using the row's event name /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void CreateOrganizationStageEventRecord(object sender, EventArgs e) { CheckBox eventCheckBox = sender as CheckBox; if (eventCheckBox != null && eventCheckBox.Checked) { int colIndex = (eventCheckBox.NamingContainer as RepeaterItem).ItemIndex; int rowIndex = (eventCheckBox.NamingContainer.NamingContainer.NamingContainer.NamingContainer.NamingContainer as RepeaterItem).ItemIndex; HiddenField projectStageEventIdField = eventCheckBox.NamingContainer.NamingContainer.NamingContainer.FindControl("StageEventIdField") as HiddenField; Repeater stagesRptr = eventCheckBox.NamingContainer.NamingContainer.NamingContainer.NamingContainer.NamingContainer.NamingContainer as Repeater; RepeaterItem stageItem = stagesRptr.Items[rowIndex]; Repeater orgStageRptr = stageItem.FindControl("OrgSingleStageRptr") as Repeater; string eventName = (eventCheckBox.NamingContainer.NamingContainer.NamingContainer.FindControl("StageEventLabel") as Label).Text; HiddenField parentStageId = orgStageRptr.Items[colIndex].FindControl("OrgStageIdField") as HiddenField; // Create a new BusinessObject ProjectStageEvent eventBiz = new ProjectStageEvent(); // Set required fields eventBiz[ProjectStageEvent.StageId] = int.Parse(parentStageId.Value); eventBiz[ProjectStageEvent.Name] = eventName; // Save New Event Record eventBiz.Save(); int projectStageEventId = int.Parse(projectStageEventIdField.Value); int stageEventId = int.Parse(eventBiz[ProjectStageEvent.StageEventId].ToString()); CreateChildEventAttributesFromEvent(stageEventId, projectStageEventId); } }
/// <summary> /// Creates child ProjectEventAttributes records /// based off of child/parent Lookup scheme. /// NOTE: Child records will not be created if any ProjectEventAttributes records exists. /// </summary> /// <param name="biz"></param> public static void CreateProjectStageEventAttributes(ProjectStageEvent biz) { BusinessObject parentBiz = biz; BusinessObject childBiz = new ProjectEventAttribute(); CreateChildRecordByBizLkpCodes(parentBiz, childBiz, ProjectStageEvent.Name, ProjectEventAttribute.AttributeName, PROJECT_STAGE_EVENT_TYPE_CODE, PROJECT_EVENT_ATTRIBUTE_TYPE_CODE, true, true); }
/// <summary> /// Creates child ProjectStageEvents and ProjectEventAttributes records /// based off of child/parent Lookup scheme. /// NOTE: Child records will not be created if any ProjectStageEvents records exists. /// </summary> /// <param name="biz"></param> public static void CreateProjectStageEvents(ProjectStage biz) { BusinessObject parentBiz = biz; BusinessObject childBiz = new ProjectStageEvent(); List <BusinessObject> stageEvents = CreateChildRecordByBizLkpCodes(parentBiz, childBiz, ProjectStage.Name, ProjectStageEvent.Name, PROJECT_STAGE_TYPE_CODE, PROJECT_STAGE_EVENT_TYPE_CODE, true, true); foreach (BusinessObject stageEvent in stageEvents) { CreateProjectStageEventAttributes(stageEvent as ProjectStageEvent); } }
// 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); } }
protected void BindEventsRptr() { ProjectStageEvent biz = new ProjectStageEvent(); }