/// <summary> /// This method fires when the user clicks the Save button in the /// submitOtherSEScreen user control /// </summary> /// <param name="sender">The submitOtherSEScreen control</param> /// <param name="e">The Click event</param> protected void submitOtherSEScreen_Click(object sender, EventArgs e) { if (currentProgramRole.AllowedToEdit.Value) { //To hold the success message type string successMessageType = null; //Fill the OtherSEScreen fields from the form currentOtherSEScreen.ScreenDate = deScreenDate.Date; currentOtherSEScreen.ScreenTypeCodeFK = Convert.ToInt32(ddScreenType.Value); currentOtherSEScreen.ChildFK = Convert.ToInt32(ddChild.Value); currentOtherSEScreen.Score = Convert.ToInt32(txtScore.Value); currentOtherSEScreen.ScoreTypeCodeFK = Convert.ToInt32(ddScoreType.Value); if (currentOtherSEScreenPK > 0) { //This is an edit using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "OtherSEScreenEdited"; //Set the edit-only fields currentOtherSEScreen.Editor = User.Identity.Name; currentOtherSEScreen.EditDate = DateTime.Now; //Get the existing OtherSEScreen record Models.OtherSEScreen existingASQ = context.OtherSEScreen.Find(currentOtherSEScreen.OtherSEScreenPK); //Overwrite the existing OtherSEScreen record with the values from the form context.Entry(existingASQ).CurrentValues.SetValues(currentOtherSEScreen); context.SaveChanges(); } //Redirect the user to the OtherSEScreen dashboard Response.Redirect(string.Format("/Pages/OtherSEScreenDashboard.aspx?messageType={0}", successMessageType)); } else { //This is an add using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "OtherSEScreenAdded"; //Set the create-only fields currentOtherSEScreen.Creator = User.Identity.Name; currentOtherSEScreen.CreateDate = DateTime.Now; currentOtherSEScreen.ProgramFK = currentProgramRole.CurrentProgramFK.Value; //Add the OtherSEScreen to the database context.OtherSEScreen.Add(currentOtherSEScreen); context.SaveChanges(); } //Redirect the user to the OtherSEScreen dashboard Response.Redirect(string.Format("/Pages/OtherSEScreenDashboard.aspx?messageType={0}", successMessageType)); } } }
/// <summary> /// This method executes when the user clicks the save button for the report catalog item /// and it saves the information to the database /// </summary> /// <param name="sender">The submitReportCatalogItem submit user control</param> /// <param name="e">The Click event</param> protected void submitReportCatalogItem_Click(object sender, EventArgs e) { //To hold the success message type, file path, and file name string successMessageType = null; //Ensure user is allowed to edit if (currentProgramRole.AllowedToEdit.Value) { //Get the relative file path string relativePath = "~/Reports/Documentation/" + txtDocumentationFileName.Value.ToString(); //Set the field values currentReportCatalog.CriteriaOptions = tbCriteriaOptions.Text + ","; currentReportCatalog.CriteriaDefaults = tbCriteriaDefaults.Text + ","; currentReportCatalog.DocumentationLink = relativePath; currentReportCatalog.Keywords = tbKeywords.Text + ","; currentReportCatalog.OptionalCriteriaOptions = tbOptionalCriteriaOptions.Text + ","; currentReportCatalog.ReportCategory = (ddReportCategory.Value.ToString().ToLower().Contains("other") ? txtReportCategorySpecify.Value.ToString() : ddReportCategory.Value.ToString()); currentReportCatalog.ReportClass = txtReportClass.Value.ToString(); currentReportCatalog.ReportDescription = txtReportDescription.Value.ToString(); currentReportCatalog.ReportName = txtReportName.Value.ToString(); currentReportCatalog.RolesAuthorizedToRun = tbRolesAuthorizedToRun.Value.ToString() + ","; //Check to see if this is an edit or add if (currentReportCatalog.ReportCatalogPK > 0) { //This is an edit using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "ReportCatalogItemEdited"; //Get the existing ReportCatalog record Models.ReportCatalog existingReportCatalog = context.ReportCatalog.Find(currentReportCatalog.ReportCatalogPK); //Overwrite the existing ReportCatalog record with the values from the form context.Entry(existingReportCatalog).CurrentValues.SetValues(currentReportCatalog); context.SaveChanges(); } //Redirect the user to the report catalog maintenance page Response.Redirect(string.Format("/Admin/ReportCatalogMaintenance.aspx?messageType={0}", successMessageType)); } else { //This is an add using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "ReportCatalogItemAdded"; //Set the edit-only fields currentReportCatalog.Creator = User.Identity.Name; currentReportCatalog.CreateDate = DateTime.Now; //Add the ReportCatalog record to the database context.ReportCatalog.Add(currentReportCatalog); context.SaveChanges(); } //Redirect the user to the report catalog maintenance page Response.Redirect(string.Format("/Admin/ReportCatalogMaintenance.aspx?messageType={0}", successMessageType)); } } else { msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000); } }
/// <summary> /// This method fires when the user clicks the Save button in the /// submitNewsEntry user control /// </summary> /// <param name="sender">The submitNewsEntry control</param> /// <param name="e">The Click event</param> protected void submitNewsEntry_Click(object sender, EventArgs e) { if (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER) { //To hold the success message type string successMessageType = null; //Fill the NewsEntry fields from the form currentNewsEntry.EntryDate = Convert.ToDateTime(deEntryDate.Value); currentNewsEntry.NewsEntryTypeCodeFK = Convert.ToInt32(ddEntryType.Value); //Set the proper FKs if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.APPLICATION) { currentNewsEntry.ProgramFK = null; currentNewsEntry.HubFK = null; currentNewsEntry.StateFK = null; currentNewsEntry.CohortFK = null; } else if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.PROGRAM_WIDE) { currentNewsEntry.ProgramFK = Convert.ToInt32(ddProgram.Value); currentNewsEntry.HubFK = null; currentNewsEntry.StateFK = null; currentNewsEntry.CohortFK = null; } else if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.HUB_WIDE) { currentNewsEntry.ProgramFK = null; currentNewsEntry.HubFK = Convert.ToInt32(ddHub.Value); currentNewsEntry.StateFK = null; currentNewsEntry.CohortFK = null; } else if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.STATE_WIDE) { currentNewsEntry.ProgramFK = null; currentNewsEntry.HubFK = null; currentNewsEntry.StateFK = Convert.ToInt32(ddState.Value); currentNewsEntry.CohortFK = null; } else if (currentNewsEntry.NewsEntryTypeCodeFK == (int)Utilities.NewsTypeFKs.COHORT_WIDE) { currentNewsEntry.ProgramFK = null; currentNewsEntry.HubFK = null; currentNewsEntry.StateFK = null; currentNewsEntry.CohortFK = Convert.ToInt32(ddCohort.Value); } if (currentNewsEntryPK > 0) { //This is an edit using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "NewsEntryEdited"; //Set the edit-only fields currentNewsEntry.Editor = User.Identity.Name; currentNewsEntry.EditDate = DateTime.Now; //Get the existing NewsEntry record Models.NewsEntry existingNewsEntry = context.NewsEntry.Find(currentNewsEntry.NewsEntryPK); //Overwrite the existing NewsEntry record with the values from the form context.Entry(existingNewsEntry).CurrentValues.SetValues(currentNewsEntry); context.SaveChanges(); } //Redirect the user to the news page Response.Redirect(string.Format("/Pages/News.aspx?messageType={0}", successMessageType)); } else { //This is an add using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "NewsEntryAdded"; //Set the create-only fields currentNewsEntry.Creator = User.Identity.Name; currentNewsEntry.CreateDate = DateTime.Now; //Add the NewsEntry to the database context.NewsEntry.Add(currentNewsEntry); context.SaveChanges(); } //Redirect the user to the this page Response.Redirect(string.Format("/Pages/NewsManagement.aspx?NewsEntryPK={0}&Action=Edit&messageType={1}", currentNewsEntry.NewsEntryPK.ToString(), successMessageType)); } } }
/// <summary> /// This method fires when the user clicks the Save button in the /// submitNewsItem user control /// </summary> /// <param name="sender">The submitNewsItem control</param> /// <param name="e">The Click event</param> protected void submitNewsItem_Click(object sender, EventArgs e) { if (currentProgramRole.AllowedToEdit.Value || currentProgramRole.RoleFK.Value == (int)Utilities.ProgramRoleFKs.HUB_DATA_VIEWER) { //Get the item pk int itemPK = Convert.ToInt32(hfAddEditNewsItemPK.Value); if (itemPK > 0) { //This is an edit using (PyramidContext context = new PyramidContext()) { //The current news item NewsItem currentNewsItem = context.NewsItem.Find(itemPK); //Fill the NewsItem fields from the form currentNewsItem.ItemNum = Convert.ToInt32(txtItemNum.Value); currentNewsItem.Contents = txtNewsItemContents.Value.ToString(); currentNewsItem.NewsEntryFK = currentNewsEntryPK; //Set the edit-only fields currentNewsItem.Editor = User.Identity.Name; currentNewsItem.EditDate = DateTime.Now; //Get the existing NewsItem record Models.NewsItem existingNewsItem = context.NewsItem.Find(currentNewsItem.NewsItemPK); //Overwrite the existing NewsItem record with the values from the form context.Entry(existingNewsItem).CurrentValues.SetValues(currentNewsItem); context.SaveChanges(); } //Show the user a success message msgSys.ShowMessageToUser("success", "News Item Added", "News Item successfully edited!", 5000); } else { //This is an add using (PyramidContext context = new PyramidContext()) { //The current news item NewsItem currentNewsItem = new NewsItem(); //Fill the NewsItem fields from the form currentNewsItem.ItemNum = Convert.ToInt32(txtItemNum.Value); currentNewsItem.Contents = txtNewsItemContents.Value.ToString(); currentNewsItem.NewsEntryFK = currentNewsEntryPK; //Set the create-only fields currentNewsItem.Creator = User.Identity.Name; currentNewsItem.CreateDate = DateTime.Now; //Add the NewsItem to the database context.NewsItem.Add(currentNewsItem); context.SaveChanges(); } //Show the user a success message msgSys.ShowMessageToUser("success", "News Item Added", "News Item successfully added!", 5000); } //Reset the values in the hidden field and hide the div hfAddEditNewsItemPK.Value = "0"; divAddEditNewsItem.Visible = false; //Bind the news items BindNewsItems(); } }
/// <summary> /// This method fires when the user clicks the Save button in the /// submitBOQFCC user control /// </summary> /// <param name="sender">The submitBOQFCC control</param> /// <param name="e">The Click event</param> protected void submitBOQFCC_Click(object sender, EventArgs e) { if (currentProgramRole.AllowedToEdit.Value) { //To hold the success message string successMessageType = null; //Fill the fields of the object from the form currentBOQFCC.FormDate = deFormDate.Date; currentBOQFCC.Indicator1 = Convert.ToInt32(ddIndicator1.Value); currentBOQFCC.Indicator2 = Convert.ToInt32(ddIndicator2.Value); currentBOQFCC.Indicator3 = Convert.ToInt32(ddIndicator3.Value); currentBOQFCC.Indicator4 = Convert.ToInt32(ddIndicator4.Value); currentBOQFCC.Indicator5 = Convert.ToInt32(ddIndicator5.Value); currentBOQFCC.Indicator6 = Convert.ToInt32(ddIndicator6.Value); currentBOQFCC.Indicator7 = Convert.ToInt32(ddIndicator7.Value); currentBOQFCC.Indicator8 = Convert.ToInt32(ddIndicator8.Value); currentBOQFCC.Indicator9 = Convert.ToInt32(ddIndicator9.Value); currentBOQFCC.Indicator10 = Convert.ToInt32(ddIndicator10.Value); currentBOQFCC.Indicator11 = Convert.ToInt32(ddIndicator11.Value); currentBOQFCC.Indicator12 = Convert.ToInt32(ddIndicator12.Value); currentBOQFCC.Indicator13 = Convert.ToInt32(ddIndicator13.Value); currentBOQFCC.Indicator14 = Convert.ToInt32(ddIndicator14.Value); currentBOQFCC.Indicator15 = Convert.ToInt32(ddIndicator15.Value); currentBOQFCC.Indicator16 = Convert.ToInt32(ddIndicator16.Value); currentBOQFCC.Indicator17 = Convert.ToInt32(ddIndicator17.Value); currentBOQFCC.Indicator18 = Convert.ToInt32(ddIndicator18.Value); currentBOQFCC.Indicator19 = Convert.ToInt32(ddIndicator19.Value); currentBOQFCC.Indicator20 = Convert.ToInt32(ddIndicator20.Value); currentBOQFCC.Indicator21 = Convert.ToInt32(ddIndicator21.Value); currentBOQFCC.Indicator22 = Convert.ToInt32(ddIndicator22.Value); currentBOQFCC.Indicator23 = Convert.ToInt32(ddIndicator23.Value); currentBOQFCC.Indicator24 = Convert.ToInt32(ddIndicator24.Value); currentBOQFCC.Indicator25 = Convert.ToInt32(ddIndicator25.Value); currentBOQFCC.Indicator26 = Convert.ToInt32(ddIndicator26.Value); currentBOQFCC.Indicator27 = Convert.ToInt32(ddIndicator27.Value); currentBOQFCC.Indicator28 = Convert.ToInt32(ddIndicator28.Value); currentBOQFCC.Indicator29 = Convert.ToInt32(ddIndicator29.Value); currentBOQFCC.Indicator30 = Convert.ToInt32(ddIndicator30.Value); currentBOQFCC.Indicator31 = Convert.ToInt32(ddIndicator31.Value); currentBOQFCC.Indicator32 = Convert.ToInt32(ddIndicator32.Value); currentBOQFCC.Indicator33 = Convert.ToInt32(ddIndicator33.Value); currentBOQFCC.Indicator34 = Convert.ToInt32(ddIndicator34.Value); currentBOQFCC.Indicator35 = Convert.ToInt32(ddIndicator35.Value); currentBOQFCC.Indicator36 = Convert.ToInt32(ddIndicator36.Value); currentBOQFCC.Indicator37 = Convert.ToInt32(ddIndicator37.Value); currentBOQFCC.Indicator38 = Convert.ToInt32(ddIndicator38.Value); currentBOQFCC.Indicator39 = Convert.ToInt32(ddIndicator39.Value); currentBOQFCC.Indicator40 = Convert.ToInt32(ddIndicator40.Value); currentBOQFCC.Indicator41 = Convert.ToInt32(ddIndicator41.Value); currentBOQFCC.Indicator42 = Convert.ToInt32(ddIndicator42.Value); currentBOQFCC.Indicator43 = Convert.ToInt32(ddIndicator43.Value); currentBOQFCC.Indicator44 = Convert.ToInt32(ddIndicator44.Value); currentBOQFCC.Indicator45 = Convert.ToInt32(ddIndicator45.Value); currentBOQFCC.Indicator46 = Convert.ToInt32(ddIndicator46.Value); currentBOQFCC.Indicator47 = Convert.ToInt32(ddIndicator47.Value); currentBOQFCC.TeamMembers = txtTeamMembers.Text; //Check to see if this is an add or edit if (BOQFCCPK > 0) { using (PyramidContext context = new PyramidContext()) { //This is an edit successMessageType = "BOQFCCEdited"; //Fill the edit-specific fields currentBOQFCC.EditDate = DateTime.Now; currentBOQFCC.Editor = User.Identity.Name; //Get the existing database values BenchmarkOfQualityFCC existingBOQFCC = context.BenchmarkOfQualityFCC.Find(currentBOQFCC.BenchmarkOfQualityFCCPK); //Set the BOQ object to the new values context.Entry(existingBOQFCC).CurrentValues.SetValues(currentBOQFCC); //Save the changes context.SaveChanges(); } //Redirect the user to the dashboard with the success message Response.Redirect(string.Format("/Pages/BOQFCCDashboard.aspx?messageType={0}", successMessageType)); } else { using (PyramidContext context = new PyramidContext()) { //This is an add successMessageType = "BOQFCCAdded"; //Set the create-specific fields currentBOQFCC.CreateDate = DateTime.Now; currentBOQFCC.Creator = User.Identity.Name; currentBOQFCC.ProgramFK = currentProgramRole.CurrentProgramFK.Value; //Add the Benchmark to the database and save context.BenchmarkOfQualityFCC.Add(currentBOQFCC); context.SaveChanges(); } //Redirect the user to the dashboard with the success message Response.Redirect(string.Format("/Pages/BOQFCCDashboard.aspx?messageType={0}", successMessageType)); } } else { msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000); } }
/// <summary> /// This method fires when the user clicks the Save button in the /// submitCoachingLog user control /// </summary> /// <param name="sender">The submitCoachingLog control</param> /// <param name="e">The Click event</param> protected void submitCoachingLog_Click(object sender, EventArgs e) { if (currentProgramRole.AllowedToEdit.Value) { //To hold the success message type string successMessageType = null; //Fill the CoachingLog fields from the form //Basic info currentCoachingLog.LogDate = Convert.ToDateTime(deLogDate.Value); currentCoachingLog.CoachFK = Convert.ToInt32(ddCoach.Value); currentCoachingLog.TeacherFK = Convert.ToInt32(ddTeacher.Value); currentCoachingLog.DurationMinutes = Convert.ToInt32(txtDurationMinutes.Value); //Observations currentCoachingLog.OBSObserving = Convert.ToBoolean(ddOBSObserving.Value); currentCoachingLog.OBSModeling = Convert.ToBoolean(ddOBSModeling.Value); currentCoachingLog.OBSVerbalSupport = Convert.ToBoolean(ddOBSVerbalSupport.Value); currentCoachingLog.OBSSideBySide = Convert.ToBoolean(ddOBSSideBySide.Value); currentCoachingLog.OBSProblemSolving = Convert.ToBoolean(ddOBSProblemSolving.Value); currentCoachingLog.OBSReflectiveConversation = Convert.ToBoolean(ddOBSReflectiveConversation.Value); currentCoachingLog.OBSEnvironment = Convert.ToBoolean(ddOBSEnvironment.Value); currentCoachingLog.OBSOtherHelp = Convert.ToBoolean(ddOBSOtherHelp.Value); currentCoachingLog.OBSConductTPOT = Convert.ToBoolean(ddOBSConductTPOT.Value); currentCoachingLog.OBSConductTPITOS = Convert.ToBoolean(ddOBSConductTPITOS.Value); currentCoachingLog.OBSOther = Convert.ToBoolean(ddOBSOther.Value); currentCoachingLog.OBSOtherSpecify = (txtOBSOtherSpecify.Value == null ? null : txtOBSOtherSpecify.Value.ToString()); //Meetings currentCoachingLog.MEETProblemSolving = Convert.ToBoolean(ddMEETProblemSolving.Value); currentCoachingLog.MEETReflectiveConversation = Convert.ToBoolean(ddMEETReflectiveConversation.Value); currentCoachingLog.MEETEnvironment = Convert.ToBoolean(ddMEETEnvironment.Value); currentCoachingLog.MEETRoleplay = Convert.ToBoolean(ddMEETRoleplay.Value); currentCoachingLog.MEETVideo = Convert.ToBoolean(ddMEETVideo.Value); currentCoachingLog.MEETGraphic = Convert.ToBoolean(ddMEETGraphic.Value); currentCoachingLog.MEETGoalSetting = Convert.ToBoolean(ddMEETGoalSetting.Value); currentCoachingLog.MEETPerformance = Convert.ToBoolean(ddMEETPerformance.Value); currentCoachingLog.MEETMaterial = Convert.ToBoolean(ddMEETMaterial.Value); currentCoachingLog.MEETDemonstration = Convert.ToBoolean(ddMEETDemonstration.Value); currentCoachingLog.MEETOther = Convert.ToBoolean(ddMEETOther.Value); currentCoachingLog.MEETOtherSpecify = (txtMEETOtherSpecify.Value == null ? null : txtMEETOtherSpecify.Value.ToString()); //Follow-up currentCoachingLog.FUEmail = Convert.ToBoolean(ddFUEmail.Value); currentCoachingLog.FUPhone = Convert.ToBoolean(ddFUPhone.Value); currentCoachingLog.FUInPerson = Convert.ToBoolean(ddFUInPerson.Value); if (currentCoachingLog.FUEmail || currentCoachingLog.FUPhone || currentCoachingLog.FUInPerson) { currentCoachingLog.FUNone = false; } else { currentCoachingLog.FUNone = true; } if (currentCoachingLogPK > 0) { //This is an edit using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "CoachingLogEdited"; //Set the edit-only fields currentCoachingLog.Editor = User.Identity.Name; currentCoachingLog.EditDate = DateTime.Now; //Get the existing CoachingLog record Models.CoachingLog existingCoachingLog = context.CoachingLog.Find(currentCoachingLog.CoachingLogPK); //Overwrite the existing CoachingLog record with the values from the form context.Entry(existingCoachingLog).CurrentValues.SetValues(currentCoachingLog); context.SaveChanges(); } //Redirect the user to the CoachingLog dashboard Response.Redirect(string.Format("/Pages/CoachingLogDashboard.aspx?messageType={0}", successMessageType)); } else { //This is an add using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "CoachingLogAdded"; //Set the create-only fields currentCoachingLog.Creator = User.Identity.Name; currentCoachingLog.CreateDate = DateTime.Now; currentCoachingLog.ProgramFK = currentProgramRole.CurrentProgramFK.Value; //Add the CoachingLog to the database context.CoachingLog.Add(currentCoachingLog); context.SaveChanges(); } //Redirect the user to the CoachingLog dashboard Response.Redirect(string.Format("/Pages/CoachingLogDashboard.aspx?messageType={0}", successMessageType)); } } }
/// <summary> /// This method fires when the user clicks the Save button in the /// submitBehaviorIncident user control /// </summary> /// <param name="sender">The submitBehaviorIncident control</param> /// <param name="e">The Click event</param> protected void submitBehaviorIncident_Click(object sender, EventArgs e) { if (currentProgramRole.AllowedToEdit.Value) { //To hold the success message string successMessageType = null; //Fill the fields of the object from the form currentBehaviorIncident.IncidentDatetime = Convert.ToDateTime(deIncidentDatetime.Value); currentBehaviorIncident.BehaviorDescription = txtBehaviorDescription.Value.ToString(); currentBehaviorIncident.ProblemBehaviorCodeFK = Convert.ToInt32(ddProblemBehavior.Value); currentBehaviorIncident.ProblemBehaviorSpecify = (txtProblemBehaviorSpecify.Value == null ? null : txtProblemBehaviorSpecify.Value.ToString()); currentBehaviorIncident.ActivityCodeFK = Convert.ToInt32(ddActivity.Value); currentBehaviorIncident.ActivitySpecify = (txtActivitySpecify.Value == null ? null : txtActivitySpecify.Value.ToString()); currentBehaviorIncident.OthersInvolvedCodeFK = Convert.ToInt32(ddOthersInvolved.Value); currentBehaviorIncident.OthersInvolvedSpecify = (txtOthersInvolvedSpecify.Value == null ? null : txtOthersInvolvedSpecify.Value.ToString()); currentBehaviorIncident.PossibleMotivationCodeFK = Convert.ToInt32(ddPossibleMotivation.Value); currentBehaviorIncident.PossibleMotivationSpecify = (txtPossibleMotivationSpecify.Value == null ? null : txtPossibleMotivationSpecify.Value.ToString()); currentBehaviorIncident.StrategyResponseCodeFK = Convert.ToInt32(ddStrategyResponse.Value); currentBehaviorIncident.StrategyResponseSpecify = (txtStrategyResponseSpecify.Value == null ? null : txtStrategyResponseSpecify.Value.ToString()); currentBehaviorIncident.AdminFollowUpCodeFK = Convert.ToInt32(ddAdminFollowUp.Value); currentBehaviorIncident.AdminFollowUpSpecify = (txtAdminFollowUpSpecify.Value == null ? null : txtAdminFollowUpSpecify.Value.ToString()); currentBehaviorIncident.Notes = (txtNotes.Value == null ? null : txtNotes.Value.ToString()); currentBehaviorIncident.ChildFK = Convert.ToInt32(ddChild.Value); currentBehaviorIncident.ClassroomFK = Convert.ToInt32(ddClassroom.Value); //Check to see if this is an add or edit if (behaviorIncidentPK > 0) { using (PyramidContext context = new PyramidContext()) { //This is an edit successMessageType = "BehaviorIncidentEdited"; //Fill the edit-specific fields currentBehaviorIncident.EditDate = DateTime.Now; currentBehaviorIncident.Editor = User.Identity.Name; //Get the existing database values Models.BehaviorIncident existingBehaviorIncident = context.BehaviorIncident.Find(currentBehaviorIncident.BehaviorIncidentPK); //Set the behavior incident object to the new values context.Entry(existingBehaviorIncident).CurrentValues.SetValues(currentBehaviorIncident); //Save the changes context.SaveChanges(); } //Redirect the user to the dashboard with the success message Response.Redirect(string.Format("/Pages/BehaviorIncidentDashboard.aspx?messageType={0}", successMessageType)); } else { using (PyramidContext context = new PyramidContext()) { //This is an add successMessageType = "BehaviorIncidentAdded"; //Set the create-specific fields currentBehaviorIncident.CreateDate = DateTime.Now; currentBehaviorIncident.Creator = User.Identity.Name; //Add the behavior incident to the database and save context.BehaviorIncident.Add(currentBehaviorIncident); context.SaveChanges(); } //Redirect the user to the dashboard with the success message Response.Redirect(string.Format("/Pages/BehaviorIncidentDashboard.aspx?messageType={0}", successMessageType)); } } else { msgSys.ShowMessageToUser("danger", "Error", "You are not authorized to make changes!", 120000); } }
/// <summary> /// This method fires when the user clicks the Save button in the /// submitASQSE user control /// </summary> /// <param name="sender">The submitASQSE control</param> /// <param name="e">The Click event</param> protected void submitASQSE_Click(object sender, EventArgs e) { if (currentProgramRole.AllowedToEdit.Value) { //To hold the success message type string successMessageType = null; //Fill the ASQSE fields from the form currentASQSE.FormDate = Convert.ToDateTime(deFormDate.Value); currentASQSE.HasDemographicInfoSheet = Convert.ToBoolean(ddDemographicSheet.Value); currentASQSE.HasPhysicianInfoLetter = Convert.ToBoolean(ddPhysicianLetter.Value); currentASQSE.ChildFK = Convert.ToInt32(ddChild.Value); currentASQSE.TotalScore = Convert.ToInt32(txtTotalScore.Value); currentASQSE.IntervalCodeFK = Convert.ToInt32(ddInterval.Value); currentASQSE.Version = Convert.ToInt32(ddVersion.Value); if (currentASQSEPK > 0) { //This is an edit using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "ASQSEEdited"; //Set the edit-only fields currentASQSE.Editor = User.Identity.Name; currentASQSE.EditDate = DateTime.Now; //Get the existing ASQSE record Models.ASQSE existingASQ = context.ASQSE.Find(currentASQSE.ASQSEPK); //Overwrite the existing ASQSE record with the values from the form context.Entry(existingASQ).CurrentValues.SetValues(currentASQSE); context.SaveChanges(); } //Redirect the user to the ASQSE dashboard Response.Redirect(string.Format("/Pages/ASQSEDashboard.aspx?messageType={0}", successMessageType)); } else { //This is an add using (PyramidContext context = new PyramidContext()) { //Set the success message successMessageType = "ASQSEAdded"; //Set the create-only fields currentASQSE.Creator = User.Identity.Name; currentASQSE.CreateDate = DateTime.Now; currentASQSE.ProgramFK = currentProgramRole.CurrentProgramFK.Value; //Add the ASQSE to the database context.ASQSE.Add(currentASQSE); context.SaveChanges(); } //Redirect the user to the ASQSE dashboard Response.Redirect(string.Format("/Pages/ASQSEDashboard.aspx?messageType={0}", successMessageType)); } } }