using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class eval : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //ASP.NET 2.0 SqlDataSource ds = new SqlDataSource(); ds.ConnectionString = ConfigurationManager.ConnectionStrings["cnPPDB"].ToString(); ds.DataSourceMode = SqlDataSourceMode.DataSet; // Populate drop-downs Utilities.populateCombo(ds, overallRatingDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, repeatEventDropDown, "mspYesNoGetAll", "YesNoOptionValue", "YesNoOptionText"); Utilities.populateCombo(ds, seatingDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, locationDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, parkingDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, servingRefeshmentsDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, materialPresentedDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, audienceLearningDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, speakerKnowledgeDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, handoutMaterialDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, timeManagementDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, refreshmentsDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, marketingDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); Utilities.populateCombo(ds, volunteerServicesDropDown, "mspRateScaleGetAll", "RateScaleID", "RateScale"); // If ProjectID was passed in then retrieve eval details from DB if (Request.QueryString["ProjectID"] != null) { // Get the ProjectID from the QueryString int projectID = Convert.ToInt32(Request.QueryString["ProjectID"]); // Get project details for this project from DB dsProjectTableAdapters.tblProjectTableAdapter projectTableAdapter = new dsProjectTableAdapters.tblProjectTableAdapter(); dsProject.tblProjectDataTable dtProject = new dsProject.tblProjectDataTable(); dsProject.tblProjectRow projectRow; dtProject = projectTableAdapter.GetByID(projectID); // We have a single row of data projectRow = (dsProject.tblProjectRow)dtProject.Rows[0]; // Set controls coeRefNumValueLabel.Text = projectRow.COENumber; if (!projectRow.IsGLCodeNull()) { glCodeValueLabel.Text = projectRow.GLCode.ToString(); } else { glCodeValueLabel.Text = "None"; } proposalStatusValueLabel.Text = projectRow.PPStatus; projectTitleValueLabel.Text = projectRow.ProjectTitle; if (!projectRow.IsProjectDescriptionNull()) { descriptionTextBox.Text = projectRow.ProjectDescription; } // set overall eval controls if (!projectRow.IsProjectRatingNull()) { overallRatingDropDown.ClearSelection(); overallRatingDropDown.Items.FindByValue(projectRow.ProjectRating.ToString()).Selected = true; } if (!projectRow.IsProjectRepeatYNNull()) { repeatEventDropDown.ClearSelection(); repeatEventDropDown.Items.FindByValue(projectRow.ProjectRepeatYN.ToString()).Selected = true; } if (!projectRow.IsProjectEvalCommentsNull()) { overallCommentsTextBox.Text = projectRow.ProjectEvalComments.ToString(); } //Get date/venue/eval details from DB for this project setDateVenueEvalControls(projectID, null); // Enable/Disable controls based on role and status ReadWriteManager.SetEvalDetailsPermissions(projectRow.PPStatus, form1); } } // Validate intially to force *s to appear before the first round-trip //Page.Validate(); } protected void eventDateDropDown_SelectedIndexChanged(object sender, EventArgs e) { int projectID = Convert.ToInt32(Request.QueryString["ProjectID"]); int projectDateID = Convert.ToInt32(eventDateDropDown.SelectedValue); setDateVenueEvalControls(projectID, projectDateID); } // Rather than overloading, chose to use int? so method accepts null for ProjectDateID // This way method can be called from different places // Called on Page_Load, and when date drop-down is changed protected void setDateVenueEvalControls(int projectID, int? ProjectDateID) { //Get date/venue details from DB for this project dsProjectTableAdapters.mspProjectDateGetByIDTableAdapter dateVenueAdapter = new dsProjectTableAdapters.mspProjectDateGetByIDTableAdapter(); dsProject.mspProjectDateGetByIDDataTable dtDateVenue = new dsProject.mspProjectDateGetByIDDataTable(); dsProject.mspProjectDateGetByIDRow dateVenueRow; dtDateVenue = dateVenueAdapter.GetByID(projectID, ProjectDateID); if (dtDateVenue.Rows.Count > 0) { DataColumn newColumn = new DataColumn(); newColumn.ColumnName = "formattedDateDisplay"; newColumn.DataType = System.Type.GetType("System.String"); newColumn.Expression = "ProposedProjectDate + ', '+ formattedStartTime + ' - ' + formattedEndTime + ' at ' + AbsoluteVenueName"; dtDateVenue.Columns.Add(newColumn); dateVenueRow = (dsProject.mspProjectDateGetByIDRow)dtDateVenue.Rows[0]; if (dtDateVenue.Rows.Count == 1) { if (!eventDateDropDown.Visible) { eventDateDropDown.Visible = false; eventDateValueLabel.Visible = true; eventDateValueLabel.Text = dateVenueRow.ProposedProjectDate.ToString() + ", " + dateVenueRow.formattedStartTime.ToString() + " - " + dateVenueRow.formattedEndTime.ToString() + " at " + dateVenueRow.AbsoluteVenueName.ToString(); } } else { eventDateLabel.Text = "Event Dates:"; eventDateValueLabel.Visible = false; eventDateDropDown.Visible = true; eventDateDropDown.DataValueField = "ProjectDateID"; eventDateDropDown.DataTextField = "formattedDateDisplay"; eventDateDropDown.DataSource = dtDateVenue; eventDateDropDown.DataBind(); } // put ProjectDateID in hidden form element projectDateIDHidden.Value = dateVenueRow.ProjectDateID.ToString(); if (!dateVenueRow.IsJKIDNull()) { if (!dateVenueRow.IsJKNameNull()) { venueNameValueLabel.Text = dateVenueRow.JKName.ToString() + " JK"; } else { venueNameValueLabel.Text = "Not Available"; } cityLabel.Visible = false; venueCityValueLabel.Visible = false; } else { if (!dateVenueRow.IsVenueNameNull()) { venueNameValueLabel.Text = dateVenueRow.VenueName.ToString(); } else { venueNameValueLabel.Text = "Not Available"; } cityLabel.Visible = true; venueCityValueLabel.Visible = true; if (!dateVenueRow.IsCityNameNull()) { venueCityValueLabel.Text = dateVenueRow.CityName.ToString(); } else { venueCityValueLabel.Text = "Not Available"; } } if (!dateVenueRow.IsProvinceAbbrevNull()) { provinceValueLabel.Text = dateVenueRow.ProvinceAbbrev.ToString(); } else { provinceValueLabel.Text = "N/A"; } if (!dateVenueRow.IsSeatingRatingNull()) { seatingDropDown.ClearSelection(); seatingDropDown.Items.FindByValue(dateVenueRow.SeatingRating.ToString()).Selected = true; } locationDropDown.ClearSelection(); if (!dateVenueRow.IsLocationRatingNull()) { locationDropDown.Items.FindByValue(dateVenueRow.LocationRating.ToString()).Selected = true; } parkingDropDown.ClearSelection(); if (!dateVenueRow.IsParkingRatingNull()) { parkingDropDown.Items.FindByValue(dateVenueRow.ParkingRating.ToString()).Selected = true; } servingRefeshmentsDropDown.ClearSelection(); if (!dateVenueRow.IsServingRefreshmentsRatingNull()) { servingRefeshmentsDropDown.Items.FindByValue(dateVenueRow.ServingRefreshmentsRating.ToString()).Selected = true; } materialPresentedDropDown.ClearSelection(); if (!dateVenueRow.IsMaterialPresentedRatingNull()) { materialPresentedDropDown.Items.FindByValue(dateVenueRow.MaterialPresentedRating.ToString()).Selected = true; } audienceLearningDropDown.ClearSelection(); if (!dateVenueRow.IsAudienceLearningRatingNull()) { audienceLearningDropDown.Items.FindByValue(dateVenueRow.AudienceLearningRating.ToString()).Selected = true; } speakerKnowledgeDropDown.ClearSelection(); if (!dateVenueRow.IsSpeakerKnowledgeStyleRatingNull()) { speakerKnowledgeDropDown.Items.FindByValue(dateVenueRow.SpeakerKnowledgeStyleRating.ToString()).Selected = true; } handoutMaterialDropDown.ClearSelection(); if (!dateVenueRow.IsHandoutMaterialRatingNull()) { handoutMaterialDropDown.Items.FindByValue(dateVenueRow.HandoutMaterialRating.ToString()).Selected = true; } timeManagementDropDown.ClearSelection(); if (!dateVenueRow.IsTimeManagementRatingNull()) { timeManagementDropDown.Items.FindByValue(dateVenueRow.TimeManagementRating.ToString()).Selected = true; } refreshmentsDropDown.ClearSelection(); if (!dateVenueRow.IsRefreshmentsRatingNull()) { refreshmentsDropDown.Items.FindByValue(dateVenueRow.RefreshmentsRating.ToString()).Selected = true; } marketingDropDown.ClearSelection(); if (!dateVenueRow.IsMarketingRatingNull()) { marketingDropDown.Items.FindByValue(dateVenueRow.MarketingRating.ToString()).Selected = true; } volunteerServicesDropDown.ClearSelection(); if (!dateVenueRow.IsVolunteerServicesRatingNull()) { volunteerServicesDropDown.Items.FindByValue(dateVenueRow.VolunteerServicesRating.ToString()).Selected = true; } keepSameTextBox1.Text = string.Empty; keepSameTextBox2.Text = string.Empty; keepSameTextBox3.Text = string.Empty; if (!dateVenueRow.IsItemsKeepSameNull()) { // This field has 3 pipe delimited values. The field should be split and // the appropriate piece should go to each text box string[] itemsKeepSame = dateVenueRow.ItemsKeepSame.Split('|'); keepSameTextBox1.Text = itemsKeepSame[0]; keepSameTextBox2.Text = itemsKeepSame[1]; keepSameTextBox3.Text = itemsKeepSame[2]; } toChangeTextBox1.Text = string.Empty; toChangeTextBox2.Text = string.Empty; toChangeTextBox3.Text = string.Empty; if (!dateVenueRow.IsItemsToChangeNull()) { // This field has 3 pipe delimited values. The field should be split and // the appropriate piece should go to each text box string[] itemsToChange = dateVenueRow.ItemsToChange.Split('|'); toChangeTextBox1.Text = itemsToChange[0]; toChangeTextBox2.Text = itemsToChange[1]; toChangeTextBox3.Text = itemsToChange[2]; } if (!dateVenueRow.IsAdditionalCommentsNull()) { additionalDateVenueCommentsTextBox.Text = dateVenueRow.AdditionalComments; } } } protected void saveOverallEvalButton_Click(object sender, EventArgs e) { Page.Validate("overallEval"); if (Request.QueryString["ProjectID"] != null) { short projectRating; short projectRepeat; Int16.TryParse(overallRatingDropDown.SelectedValue, out projectRating); Int16.TryParse(repeatEventDropDown.SelectedValue, out projectRepeat); string projectEvalComments = overallCommentsTextBox.Text; string modifiedBy = Request.ServerVariables["LOGON_USER"]; int projectID = Convert.ToInt32(Request.QueryString["ProjectID"]); // Get table adapter for Project table dsProjectTableAdapters.tblProjectTableAdapter projectTableAdapter = new dsProjectTableAdapters.tblProjectTableAdapter(); // Call the method to update the database projectTableAdapter.UpdateOverallEvalByID(projectRating, projectRepeat, projectEvalComments, modifiedBy, projectID); } else { //ProjectID was not found in QueryString, so handle problem } } protected void saveDayEvalButton_Click(object sender, EventArgs e) { bool result; int projectDateID; result = Int32.TryParse(projectDateIDHidden.Value, out projectDateID); Page.Validate("eventDateEval"); if (result) { int seatingRating; int locationRating; int parkingRating; int servingRefeshmentsRating; int materialPresentedRating; int audienceLearningRating; int speakerKnowledgeRating; int handoutMaterialRating; int timeManagementRating; int refreshmentsRating; int marketingRating; int volunteerServicesRating; result = Int32.TryParse(seatingDropDown.SelectedValue, out seatingRating ); result = Int32.TryParse(locationDropDown.SelectedValue, out locationRating); result = Int32.TryParse(parkingDropDown.SelectedValue, out parkingRating); result = Int32.TryParse(servingRefeshmentsDropDown.SelectedValue, out servingRefeshmentsRating); result = Int32.TryParse(materialPresentedDropDown.SelectedValue, out materialPresentedRating); result = Int32.TryParse(audienceLearningDropDown.SelectedValue, out audienceLearningRating); result = Int32.TryParse(speakerKnowledgeDropDown.SelectedValue, out speakerKnowledgeRating); result = Int32.TryParse(handoutMaterialDropDown.SelectedValue, out handoutMaterialRating); result = Int32.TryParse(timeManagementDropDown.SelectedValue, out timeManagementRating); result = Int32.TryParse(refreshmentsDropDown.SelectedValue, out refreshmentsRating); result = Int32.TryParse(marketingDropDown.SelectedValue, out marketingRating); result = Int32.TryParse(volunteerServicesDropDown.SelectedValue, out volunteerServicesRating); string itemsKeepSame = keepSameTextBox1.Text + "|" + keepSameTextBox2.Text + "|" + keepSameTextBox3.Text; string itemsToChange = toChangeTextBox1.Text + "|" + toChangeTextBox2.Text + "|" + toChangeTextBox3.Text; string additionalComments = additionalDateVenueCommentsTextBox.Text; string modifiedBy = Request.ServerVariables["LOGON_USER"]; // Get table adapter for Project date & venue (adapter based on stored proc) dsProjectTableAdapters.mspProjectDateGetByIDTableAdapter projectDateAdapter = new dsProjectTableAdapters.mspProjectDateGetByIDTableAdapter(); // Call the method to update the database projectDateAdapter.UpdateEvalByID(projectDateID, seatingRating, parkingRating, locationRating, servingRefeshmentsRating, materialPresentedRating, audienceLearningRating, speakerKnowledgeRating, handoutMaterialRating, timeManagementRating, refreshmentsRating, marketingRating, volunteerServicesRating, itemsKeepSame, itemsToChange, additionalComments, modifiedBy); } else { //ProjectDateID was not found in QueryString, so handle problem } } }