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; using System.Data.SqlClient; using System.Xml; using System.Net; public partial class ProjectDetails : System.Web.UI.Page { //protected CredentialCache getCacheCreds() //{ // System.Net.NetworkCredential mycred = new System.Net.NetworkCredential("coereader", "coereader"); // System.Net.CredentialCache mycache = new System.Net.CredentialCache(); // //mycache.Add(new Uri("https://members.ijkc.com/cfbc/homepage/coe"), "NTLM", mycred); // mycache.Add(new Uri("http://seva.ijkc.com/coe"), "NTLM", mycred); // return mycache; //} protected void Page_Load(object sender, EventArgs e) { currTimeStampLabel.Text = "Today is " + Utilities.GetFormattedDateTime(); // TEMPORARY //coeRefNumTextBox.Text = "1617"; if (!Page.IsPostBack) { // Get Windows ID of user string logonUserName = Utilities.GetLoggedInUserID(User.Identity.Name); lblHeader.Text = "You are logged in as " + logonUserName; // Check if user is an authorized user of the system MembershipUser user = Membership.GetUser(logonUserName); if (user != null) { if (Roles.IsUserInRole(logonUserName, "AdminPlanning")) { #region Populate Combos //ASP.NET 2.0 SqlDataSource ds = new SqlDataSource(); ds.ConnectionString = ConfigurationManager.ConnectionStrings["cnPPDB"].ToString(); ds.DataSourceMode = SqlDataSourceMode.DataSet; // Populate drop-downs Utilities.populateCombo(ds, proposalStatusDropDown, "mspPPStatusGetAll", "PPStatusID", "PPStatus"); // Select the second item, which is "Pre-event Details", since "New" is not used proposalStatusDropDown.SelectedIndex = 2; Utilities.populateCombo(ds, categoryDropDown, "mspEventCategoryGetAll", "EventCategoryID", "EventCategory"); Utilities.populateCombo(ds, startHourDropDown, "mspHourGetAll", "HourID", "HourValue"); Utilities.populateCombo(ds, startMinuteDropDown, "mspMinuteGetAll", "MinuteID", "MinuteValue"); Utilities.populateCombo(ds, endHourDropDown, "mspHourGetAll", "HourID", "HourValue"); Utilities.populateCombo(ds, endMinuteDropDown, "mspMinuteGetAll", "MinuteID", "MinuteValue"); Utilities.populateCombo(ds, jkNameDropDown, "mspJKGetAll", "JKID", "JKName"); Utilities.populateCombo(ds, boardPortfolioDropDown, "mspBoardPortfolio", "BoardPortfolioID", "BoardPortfolioName"); Utilities.populateList(ds, keyPartnerListBox, "mspBoardPortfolio", "BoardPortfolioID", "BoardPortfolioName"); Utilities.populateCombo(ds, PrimaryTargetDropDown, "mspTargetSegmentGetAll", "TargetSegmentID", "TargetSegmentName"); Utilities.populateList(ds, SecondaryTargetListBox, "mspTargetSegmentGetAll", "TargetSegmentID", "TargetSegmentName"); startHourDropDown.Items.Remove("Select One"); startMinuteDropDown.Items.Remove("Select One"); endHourDropDown.Items.Remove("Select One"); endMinuteDropDown.Items.Remove("Select One"); #endregion #region Set up calendar control // Set up special dates eventDateCalendar.AddSpecialDate(-1, 7, 11, "Immamat Day"); eventDateCalendar.AddSpecialDate(-1, 3, 21, "Navroz"); eventDateCalendar.AddSpecialDate(-1, 12, 13, "Shah Karim's B'day"); //To add dates programatically, do so in a loop //eventDateCalendar.AddSpecialDate(Convert.ToDateTime(dateVenueRow.ProposedProjectDate.ToString()), projectRow.ProjectTitle); // Set up calendar behavior eventDateCalendar.DatePickerMode = true; //These are set by ReadWriteManager.cs //eventDateCalendar.AllowDeselect = true; //eventDateCalendar.OnClientDateChanged = "onDateChange"; //eventDateCalendar.TextBoxId = proposedDateTextBox.ID; eventDateCalendar.DateFormat = "MMM dd yyyy"; // Set Min date to date specified in Web.config variable "MinCalendarDate" eventDateCalendar.DateMin = Convert.ToDateTime(ConfigurationManager.AppSettings["MinCalendarDate"]); // Set Max date to date specified in Web.config variable "MaxCalendarDate" eventDateCalendar.DateMax = Convert.ToDateTime(ConfigurationManager.AppSettings["MaxCalendarDate"]); eventDateCalendar.TitleText = "Today is " + DateTime.Now.ToString("dddd MMMM dd, yyyy") + " "; eventDateCalendar.ShowYearSelector = false; #endregion #region Get COE Calendar Lists //com.ijkc.members.Lists coeLists = new com.ijkc.members.Lists(); //Lists coeLists = new Lists(); // Get the creds needed to connect to SharePoint Web Services //coeLists.Credentials = getCacheCreds(); //Call the GetListCollection web method to get an XML of all the lists //XmlNode coeListItems = coeLists.GetListCollection(); com.ijkc.seva.Lists sharepointLists = new com.ijkc.seva.Lists(); sharepointLists.UseDefaultCredentials = true; XmlNode coeListItems = sharepointLists.GetListCollection(); // Declare vars to hold COE list names and GUIDs string coeListName; string coeListGUID; string itemToSelect = ""; bool itemSelected = false; // Loop through the nodes to extract the list name and GUID for each COE list foreach (XmlNode coelistItem in coeListItems) { // Extract the COE list name and GUID coeListName = coelistItem.Attributes["Title"].Value; coeListGUID = coelistItem.Attributes["ID"].Value; // Create a list item for the ASP.NET listbox ListItem aspListItem = new ListItem(); // Set the ASP.NET list item's text (displayed to user) and value (hidden) aspListItem.Text = coeListName; aspListItem.Value = coeListGUID; // Add the list item to the listbox spCalendarDropDown.Items.Add(aspListItem); // If this is older COE, grab the text so we can select the item later if (itemSelected == false && coeListName.IndexOf(@"2009") != -1) { itemToSelect = coeListName; itemSelected = true; } } // Set the appropriate calendar in the dropdown if (itemToSelect.Length > 0) { spCalendarDropDown.Items.FindByText(itemToSelect.ToString()).Selected = true; } #endregion // Finish setting proposalStatusDropDown proposalStatusDropDown.Items.Remove("Select One"); } else { // Their account exists but not in role "AdminPlanning", so redirect to homepage Response.Redirect("Default.html", true); } } else { // Their account doesn't exists, so redirect to homepage Response.Redirect("Default.html", true); } } } protected void createProjectButton_Click(object sender, EventArgs e) { Page.Validate("eventDetails"); bool result; string successFailureMsg; // Get project details from form string coeRefNum = coeRefNumTextBox.Text; int ppStatusID; result = Int32.TryParse(proposalStatusDropDown.SelectedValue, out ppStatusID); string ppStatus = proposalStatusDropDown.SelectedItem.ToString(); string projectTitle = projectTitleTextBox.Text; string projectDescription = descriptionTextBox.Text; int eventCategoryID; result = Int32.TryParse(categoryDropDown.SelectedValue, out eventCategoryID); DateTime proposedProjectDate; result = DateTime.TryParse(proposedDateTextBox.Text, out proposedProjectDate); DateTime proposedStartTime; result = DateTime.TryParse(startHourDropDown.SelectedItem + ":" + startMinuteDropDown.SelectedItem, out proposedStartTime); DateTime proposedEndTime; result = DateTime.TryParse(endHourDropDown.SelectedItem + ":" + endMinuteDropDown.SelectedItem, out proposedEndTime); int jkID = -1; result = Int32.TryParse(jkNameDropDown.SelectedValue, out jkID); Int16 expectedParticipants; result = Int16.TryParse(expectedParticipantsTextBox.Text, out expectedParticipants); int boardPortfolioID; result = Int32.TryParse(boardPortfolioDropDown.SelectedValue, out boardPortfolioID); string boardPortfolioName = boardPortfolioDropDown.SelectedItem.Text; //key partners string keyPartners = ""; for (int i = 1; i <= keyPartnerListBox.Items.Count - 1; i++ ) { if (keyPartnerListBox.Items[i].Selected == true) { keyPartners += keyPartnerListBox.Items[i].Value + ";"; } } int primaryTargetSegmentID; // = Convert.ToInt32(PrimaryTargetDropDown.SelectedValue); result = Int32.TryParse(PrimaryTargetDropDown.SelectedValue, out primaryTargetSegmentID); //secondary target segments string secondaryTargetSegments = ""; for (int i = 1; i <= SecondaryTargetListBox.Items.Count - 1; i++) { if (SecondaryTargetListBox.Items[i].Selected == true) { secondaryTargetSegments += SecondaryTargetListBox.Items[i].Value + ";"; } } string projectNotes = projectNotesTextBox.Text; string createdBy = CreatedByTextBox.Text; string modifiedBy = ModifiedByTextBox.Text; //create vars needed for email notification string startDateForEmail = proposedDateTextBox.Text; string startTimeForEmail = startHourDropDown.SelectedItem + ":" + startMinuteDropDown.SelectedItem; string endTimeForEmail = endHourDropDown.SelectedItem + ":" + endMinuteDropDown.SelectedItem; bool sendEmailNotif = sendEmailNotifCheckBox.Checked; //call method that will handle the ceation of the new PP successFailureMsg = Project.CreateNewPP(projectTitle, coeRefNum, eventCategoryID, projectDescription, projectNotes, createdBy, modifiedBy, boardPortfolioID, boardPortfolioName, keyPartners, primaryTargetSegmentID, secondaryTargetSegments, expectedParticipants, proposedProjectDate, startDateForEmail, proposedStartTime, startTimeForEmail, proposedProjectDate, proposedEndTime, endTimeForEmail, jkID, ppStatusID, ppStatus, sendEmailNotif); // Display message for user saveResultLabel.Text = saveResultLabel2.Text = successFailureMsg; // top and bottom of page //clear the COE Ref field coeRefNumTextBox.Text = ""; // set the focus in the COE Ref field coeRefNumTextBox.Focus(); } protected void coeGetData_Click(object sender, EventArgs e) { string COEID = coeRefNumTextBox.Text; bool result; // Blank out the last message displayed. saveResultLabel.Text = ""; //warn user if the ID was blank if (COEID.Length == 0) { // we can't do anything // Display message for user saveResultLabel.Text = "Please enter a COE ID."; } else { // What does this do? Loads the web methods? //com.ijkc.members.Lists sharepointLists = new com.ijkc.members.Lists(); com.ijkc.seva.Lists sharepointLists = new com.ijkc.seva.Lists(); // Get the creds needed to connect to SharePoint Web Services //sharepointLists.Credentials = getCacheCreds(); sharepointLists.UseDefaultCredentials = true; string coeSelectedListValue = ""; coeSelectedListValue = spCalendarDropDown.SelectedValue.ToString(); // Create an XML doc in memory XmlDocument XMLdoc = new XmlDocument(); // Add a node the the XML doc for the CAML query XmlNode CAMLQuery = XMLdoc.CreateNode(XmlNodeType.Element, "Query", ""); // This CAML brings back only the row for the specified COEID CAMLQuery.InnerXml = "<Where><Eq><FieldRef Name='ID'/>" + "<Value Type='Counter'>" + COEID + "</Value></Eq></Where>"; // Does this specify the fields to return? XmlNode ViewFields = XMLdoc.CreateNode(XmlNodeType.Element, "ViewFields", ""); //ViewFields.InnerXml = "<FieldRef Name='ID'/><FieldRef Name='Title'/>"; XmlNode CAMLQueryOptions = XMLdoc.CreateNode(XmlNodeType.Element, "QueryOptions", ""); // Specify the number of rows that match our CAML criteria to return string rowsReturned = "5"; try { //XmlNode node = coeLists.GetListItems(list.Attributes["ID"].Value, null, Query, ViewFields, "5", QueryOptions); XmlNode nodeEventDetails = sharepointLists.GetListItems(coeSelectedListValue, null, CAMLQuery, ViewFields, rowsReturned, CAMLQueryOptions, null); XmlDocument xmlCOEEventDetails = new XmlDocument(); xmlCOEEventDetails.LoadXml(nodeEventDetails.OuterXml); XmlNamespaceManager nsmListItems = new XmlNamespaceManager(xmlCOEEventDetails.NameTable); nsmListItems.AddNamespace("foo", "http://schemas.microsoft.com/sharepoint/soap/"); #region set title, description, category string sTitle = ""; XmlNode ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Title", nsmListItems); if (ndTemp != null) { sTitle = ndTemp.InnerText; } string sDescr = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Description", nsmListItems); if (ndTemp != null) { sDescr = ndTemp.InnerText; } string sCategory = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Event_x0020_Category", nsmListItems); if (ndTemp != null) { sCategory = ndTemp.InnerText; // Get the clean name, since the string contains some prefixed chars sCategory = Utilities.GetStringPartAfterChar(sCategory, "= ").Trim(); } #endregion #region set start date/time controls string sStartDateTime = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_EventDate", nsmListItems); if (ndTemp != null) { sStartDateTime = ndTemp.InnerText; string[] sStartDateTimeArray = null; sStartDateTimeArray = sStartDateTime.Split(' '); TextBox1.Text = sStartDateTimeArray[0].ToString(); // Set the date of the event if (sStartDateTimeArray[0].Length > 0) { int eventMonthNumber = 0; string eventMonth = ""; string sConvertedDate = ""; DateTime convertedDate; result = System.Int32.TryParse(sStartDateTimeArray[0].Substring(5, 2), out eventMonthNumber); if (result == true) { eventMonth = Utilities.GetMonthText(eventMonthNumber, true); if (eventMonth != "-1") { string eventDateNumber = sStartDateTimeArray[0].Substring(8, 2).ToString(); string eventYear = sStartDateTimeArray[0].Substring(0, 4).ToString(); sConvertedDate = System.String.Concat(eventMonth, " ", eventDateNumber, " ", eventYear); result = System.DateTime.TryParse(sConvertedDate, out convertedDate); eventDateCalendar.SelectedDate = convertedDate; } } if(result == false || eventMonth == "-1") { proposedDateTextBox.Text = "Could not extract date"; } } // Set the start time if (sStartDateTimeArray[1].Length > 0) { startHourDropDown.ClearSelection(); startHourDropDown.Items.FindByText(sStartDateTimeArray[1].ToString().Substring(0, 2)).Selected = true; startMinuteDropDown.ClearSelection(); startMinuteDropDown.Items.FindByText(sStartDateTimeArray[1].ToString().Substring(3, 2)).Selected = true; } } #endregion #region set end time controls string sEndTime = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_EndDate", nsmListItems); if (ndTemp != null) { sEndTime = ndTemp.InnerText; string[] sEndTimeArray = null; sEndTimeArray = sEndTime.Split(' '); if (sEndTimeArray[1].Length > 0) { endHourDropDown.ClearSelection(); endHourDropDown.Items.FindByText(sEndTimeArray[1].ToString().Substring(0, 2)).Selected = true; endMinuteDropDown.ClearSelection(); endMinuteDropDown.Items.FindByText(sEndTimeArray[1].ToString().Substring(3, 2)).Selected = true; } } #endregion float sNumParticipants = 0; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows__x0023__x0020_of_x0020_People_x0", nsmListItems); if (ndTemp != null) { //sNumParticipants = float.Parse(ndTemp.InnerText); result = System.Single.TryParse(ndTemp.InnerText, out sNumParticipants); } string sEventLocation = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Location", nsmListItems); if (ndTemp != null) { sEventLocation = ndTemp.InnerText; } string sPrimaryTarget = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Primary_x0020_Target_x0020_Segme", nsmListItems); if (ndTemp != null) { sPrimaryTarget = ndTemp.InnerText; // Get the clean name, since the string contains some prefixed chars sPrimaryTarget = sPrimaryTarget.Trim(); } string sSecondaryTargets = ""; string[] sSecondaryTargetArray = null; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Segment_x0028_s_x0029_", nsmListItems); if (ndTemp != null) { sSecondaryTargets = ndTemp.InnerText; // Get the clean name, since the string contains some prefixed chars sSecondaryTargets = sSecondaryTargets.Trim(); // Get rid of the ; character sSecondaryTargets = Utilities.replaceString(sSecondaryTargets, ";", ""); sSecondaryTargets = Utilities.GetStringPartAfterChar(sSecondaryTargets, "#"); sSecondaryTargets = Utilities.GetStringPartBeforeChar(sSecondaryTargets, "#"); // Split the new sentence at each # character sSecondaryTargetArray = sSecondaryTargets.Split('#'); } string sBoardPortfolio = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Primary_x0020_Lead_x0020_Portfol", nsmListItems); if (ndTemp != null) { sBoardPortfolio = ndTemp.InnerText; // Get the clean name, since the string contains some prefixed chars sBoardPortfolio = sBoardPortfolio.Trim(); } string sKeyPartners = ""; string[] sKeyPartnersArray = null; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Board_x002f_Portfolio", nsmListItems); if (ndTemp != null) { sKeyPartners = ndTemp.InnerText; // Get the clean name, since the string contains some prefixed chars sKeyPartners = sKeyPartners.Trim(); // Get rid of the ; character sKeyPartners = Utilities.replaceString(sKeyPartners, ";", ""); // Get rid of the beggining # character sKeyPartners = Utilities.GetStringPartAfterChar(sKeyPartners, "#"); // Get rid of the ending # character sKeyPartners = Utilities.GetStringPartBeforeChar(sKeyPartners, "#"); // Split the new sentence at each # character sKeyPartnersArray = sKeyPartners.Split('#'); } string sNotes = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Comments", nsmListItems); if (ndTemp != null) { sNotes = ndTemp.InnerText; } string sCreatedBy = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Author", nsmListItems); if (ndTemp != null) { sCreatedBy = ndTemp.InnerText; // Get the clean name, since the string contains some prefixed chars sCreatedBy = Utilities.GetStringPartAfterChar(sCreatedBy, "#"); } string sModifiedBy = ""; ndTemp = xmlCOEEventDetails.SelectSingleNode("//*/*/*/@ows_Editor", nsmListItems); if (ndTemp != null) { sModifiedBy = ndTemp.InnerText; // Get the clean name, since the string contains some prefixed chars sModifiedBy = Utilities.GetStringPartAfterChar(sModifiedBy, "#"); } //Populate the controls projectTitleTextBox.Text = sTitle; descriptionTextBox.Text = sDescr; // This does not work because comparison is text sensitive // No way of setting case of list items //if (sCategory.Length > 0 && categoryDropDown.Items.FindByText(sCategory.ToString().ToUpper()) != null) //{ // categoryDropDown.ClearSelection(); // categoryDropDown.Items.FindByText(sCategory.ToString().ToUpper()).Selected = true; //} // Workaround for the above problem foreach (ListItem catListItem in categoryDropDown.Items) { // If there's a match, select the item in the list if (catListItem.Text.ToUpper() == sCategory.ToString().ToUpper()) { categoryDropDown.ClearSelection(); catListItem.Selected = true; break; // No need to check the rest of the items, so break out of the loop } } expectedParticipantsTextBox.Text = sNumParticipants.ToString(); coeEventLocationValueLabel.Text = sEventLocation.ToString(); PrimaryTargetDropDown.ClearSelection(); foreach (ListItem primaryTargetListItem in PrimaryTargetDropDown.Items) { // If there's a match, select the item in the list if (primaryTargetListItem.Text.ToUpper() == sPrimaryTarget.ToString().ToUpper()) { primaryTargetListItem.Selected = true; break; // No need to check the rest of the items, so break out of the loop } else if (primaryTargetListItem.Text.ToUpper() == "Pre-School (Birth - 5yrs)".ToUpper()) { primaryTargetListItem.Selected = true; break; // No need to check the rest of the items, so break out of the loop } } // if nothing was selected then select the first item if (PrimaryTargetDropDown.SelectedIndex == -1) { PrimaryTargetDropDown.SelectedIndex = 0; } SecondaryTargetListBox.SelectedIndex = 0; if (sSecondaryTargetArray != null) { int arrayLength = sSecondaryTargetArray.Length; if (arrayLength > 0) { SecondaryTargetListBox.ClearSelection(); for (int i = 0; i < arrayLength; i++) { if (sSecondaryTargetArray[i].ToString() != sPrimaryTarget) { if (sSecondaryTargetArray[i].ToString() == "Pre-School (Birth - 5yrs)") { //Set Preschool explicitly SecondaryTargetListBox.Items.FindByText("Pre-School (Birth - 5 yrs)").Selected = true; } else { SecondaryTargetListBox.Items.FindByText(sSecondaryTargetArray[i].ToString()).Selected = true; } } } } // if nothing was selected then select the first item if (SecondaryTargetListBox.SelectedIndex == -1) { SecondaryTargetListBox.SelectedIndex = 0; } } boardPortfolioDropDown.ClearSelection(); foreach (ListItem boardPortfolioListItem in boardPortfolioDropDown.Items) { // If there's a match, select the item in the list if (boardPortfolioListItem.Text.IndexOf(@sBoardPortfolio.ToString()) != -1) { boardPortfolioListItem.Selected = true; break; // No need to check the rest of the items, so break out of the loop } else if (boardPortfolioListItem.Text.IndexOf(@"HRD/IVC") != -1) { if (sBoardPortfolio.ToString().ToUpper() == "HRD/ IVC".ToUpper()) { boardPortfolioListItem.Selected = true; break; // No need to check the rest of the items, so break out of the loop } } } // if nothing was selected then select the first item if (boardPortfolioDropDown.SelectedIndex == -1) { boardPortfolioDropDown.SelectedIndex = 0; } keyPartnerListBox.SelectedIndex = 0; if (sKeyPartnersArray != null) { int arrayLength = sKeyPartnersArray.Length; if (arrayLength > 0) { keyPartnerListBox.ClearSelection(); for (int i = 0; i < arrayLength; i++) { if (sKeyPartnersArray[i].ToString() != sBoardPortfolio) { foreach (ListItem keyPartnerListItem in keyPartnerListBox.Items) { // If there's a match, select the item in the list string keyPartnerListItemText = keyPartnerListItem.Text; int lengthToMatch = sKeyPartnersArray[i].Length; int lengthOfListItem = keyPartnerListItemText.Length; if (lengthOfListItem > lengthToMatch) { string keyPartnerListItemTruncatedText = keyPartnerListItemText.Substring(0, lengthToMatch); if (keyPartnerListItemTruncatedText.ToUpper() == sKeyPartnersArray[i].ToString().ToUpper()) { keyPartnerListItem.Selected = true; break; // No need to check the rest of the items, so break out of the loop } // if the substring "HRD/IVC" is found in the current selected item else if (keyPartnerListItemTruncatedText.ToUpper().IndexOf(@"HRD/IVC") != -1) { if (sKeyPartnersArray[i].ToString().ToUpper() == "HRD/ IVC".ToUpper()) { keyPartnerListItem.Selected = true; break; // No need to check the rest of the items, so break out of the loop } } } } } } } // if nothing was selected then select the first item if (keyPartnerListBox.SelectedIndex == -1) { keyPartnerListBox.SelectedIndex = 0; } } projectNotesTextBox.Text = sNotes; CreatedByTextBox.Text = sCreatedBy; ModifiedByTextBox.Text = sModifiedBy; } catch (System.Web.Services.Protocols.SoapException ex) { string ErrMsg; ErrMsg = "Error:" + Environment.NewLine + ex.Message + Environment.NewLine + "Detail:" + Environment.NewLine + ex.Detail.InnerText + Environment.NewLine + "StackTrace:" + Environment.NewLine + ex.StackTrace; saveResultLabel.Text = ErrMsg; } catch (Exception ex) { string ErrMsg; ErrMsg = "Error: " + ex.Message; saveResultLabel.Text = ErrMsg; } } } protected void clearFormButton_Click(object sender, EventArgs e) { // clear all the fields coeRefNumTextBox.Text = ""; projectTitleTextBox.Text = ""; descriptionTextBox.Text = ""; categoryDropDown.SelectedIndex = 0; // NOTE: Both steps below required to clear the textbox // clear the date textbox proposedDateTextBox.Text = ""; // blank the selected date in the calendar DateTime proposedProjectDate; bool result = DateTime.TryParse("", out proposedProjectDate); eventDateCalendar.SelectedDate = proposedProjectDate; startHourDropDown.SelectedIndex = 0; startMinuteDropDown.SelectedIndex = 0; endHourDropDown.SelectedIndex = 0; endMinuteDropDown.SelectedIndex = 0; jkNameDropDown.SelectedIndex = 0; coeEventLocationValueLabel.Text = ""; expectedParticipantsTextBox.Text = ""; boardPortfolioDropDown.SelectedIndex = 0; keyPartnerListBox.SelectedIndex = 0; PrimaryTargetDropDown.SelectedIndex = 0; SecondaryTargetListBox.SelectedIndex = 0; projectNotesTextBox.Text = ""; CreatedByTextBox.Text = ""; ModifiedByTextBox.Text = ""; } }