public override List <Approver> GetApprover(int formNo) { List <Approver> listApprover = new List <Approver>(); ParticipantOrgInfo mdOrg = ParticipantDataAccess.GetParticipantOrg(ParticipantId); if (mdOrg == null) { return(listApprover); } string[] arrUserId = mdOrg.UserId.Split(';'); for (int i = 0; i < arrUserId.Length; i++) { User user = new User(arrUserId[i]); Approver approver = new Approver(); approver.ApproverId = user.UserId; approver.ApproverName = user.UserName; approver.ApproveRole = ""; approver.SequenceNo = 1; listApprover.Add(approver); } return(listApprover); }
public ParticipantControllerTest() { _teamaanagerDbEntities = new EliqTeamManagerDBEntities(); _teamDeatailDataAcces = new TeamDetailDataAccess(); _dataAccess = new ParticipantDataAccess(_teamDeatailDataAcces, _teamaanagerDbEntities); _controller = new ParticipantController(_dataAccess); }
/// <summary> /// Use to load Attendees information from Attendees id. /// Perticipant id get from query string. Return none. /// </summary> private void LoadParticipant() { try { ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); Participant currentParticipant = oParticipantDataAccess.GetParticipantByIDandCourseID(participantID, courseID); //check weather the provider is available if (currentParticipant != null) { //available so assign to UI txtLastName.Text = currentParticipant.LastName; txtFirstName.Text = currentParticipant.FirstName; txtASLA.Text = currentParticipant.ASLANumber; txtCLARB.Text = currentParticipant.CLARBNumber; txtFL.Text = currentParticipant.FloridaStateNumber; txtCSLA.Text = currentParticipant.CSLANumber; txtMiddleName.Text = currentParticipant.MiddleInitial; txtEmail.Text = currentParticipant.Email; } else { //show participant not found error message lblMsg.Text = LACESConstant.Messages.PARTICIPANT_NOT_FOUND_IN_PROVIDER; ///Disable buttons btnRemovePerticipant.Enabled = false; btnSaveFinish.Enabled = false; } } catch (Exception ex) { throw ex; } }
/// <summary> /// Page load event handler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { CourseDataAccess objCourseDAL = new CourseDataAccess(); string sSortColumn = string.Empty; string sSortOrder = string.Empty; //If found PARTICIPANT ID as query sting then display the participant info if (Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID] != null) { ///Check Sort Column Query String if (Request.QueryString[LACESConstant.QueryString.SORT_COLUMN] != null) { sSortColumn = Request.QueryString[LACESConstant.QueryString.SORT_COLUMN].ToString(); } else { sSortColumn = "DateEntered"; // by default sort by DateEntered column } ///Check Sort Order Query String if (Request.QueryString[LACESConstant.QueryString.SORT_ORDER] != null) { sSortOrder = Request.QueryString[LACESConstant.QueryString.SORT_ORDER].ToString(); } else { sSortOrder = "asc"; // by default sort in ascending order } //Create Header row //createHeaderRow(sSortColumn, sSortOrder); //Adjust left/right content place holder width IncreaseLeftContentWidth(); //System.Diagnostics.Debugger.Break(); ///Get Search result courseResult = objCourseDAL.GetParticipantCourses(Convert.ToInt32(Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID].ToString()), sSortColumn, sSortOrder); //Display participant information ParticipantDataAccess partDAC = new ParticipantDataAccess(); Participant objPart = partDAC.GetParticipantByID(Convert.ToInt32(Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID].ToString())); if (objPart != null) { lblPartLastName.Text = Server.HtmlEncode(objPart.LastName); lblPartFirstName.Text = Server.HtmlEncode(objPart.FirstName); lblPartASLA.Text = Server.HtmlEncode(objPart.ASLANumber); lblPartCLARB.Text = Server.HtmlEncode(objPart.CLARBNumber); lblPartFL.Text = Server.HtmlEncode(objPart.FloridaStateNumber); lblMiddleName.Text = Server.HtmlEncode(objPart.MiddleInitial); lblCSLA.Text = Server.HtmlEncode(objPart.CSLANumber); //if no course found then display 0 as number of courses lblPartCourses.Text = courseResult != null && courseResult.Count > 0 ? courseResult.Count.ToString() : "0"; } } }
/// <summary> /// Uplaod an Excel file /// </summary> private void UploadExcelFile() { if (Request.QueryString[LACESConstant.QueryString.COURSE_ID] != null) { try { //get the course id from query string long courseID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.COURSE_ID]); List <Participant> participantList = new List <Participant>(); //create the file loacton string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "xls\\" + System.DateTime.Now.Ticks + FileUpload1.FileName; FileStream oFileStream = File.Create(fileLocation); foreach (byte b in FileUpload1.FileBytes) { oFileStream.WriteByte(b); } oFileStream.Close(); Participant oParticipant = null; //now load it to UI DataTable oDataTable = ReadXLFile(fileLocation); foreach (DataRow dr in oDataTable.Rows) { oParticipant = new Participant(); oParticipant.LastName = dr["Last"].ToString(); oParticipant.FirstName = dr["First"].ToString(); oParticipant.ASLANumber = dr["ASLA"].ToString(); oParticipant.CLARBNumber = dr["CLARB"].ToString(); oParticipant.FloridaStateNumber = dr["FL"].ToString(); //add in to the participant list participantList.Add(oParticipant); } if (participantList.Count > 0) { //finally add the participant in to the database ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); oParticipantDataAccess.AddParticipantByCourse(courseID, participantList); } //finally remove the excel file if (File.Exists(fileLocation)) { File.Delete(fileLocation); } Response.Redirect(Request.Url.AbsoluteUri); } catch (Exception ex) { throw; } } }
/// <summary> /// Call every time when 'Save & Finish' Button Click form UI /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs</param> protected void btnSaveFinish_Click(object sender, EventArgs e) { //Save button click, so store the updated information into the database try { Course objCourse = getCourseInfo(); if (objCourse != null) { ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); Participant currentParticipant = new Participant(); //check weather the participant is exist currentParticipant = oParticipantDataAccess.GetParticipantByIDandCourseID(participantID, courseID); if (currentParticipant != null) { //participant exist so update currentParticipant.LastName = txtLastName.Text; currentParticipant.FirstName = txtFirstName.Text; currentParticipant.ASLANumber = txtASLA.Text; currentParticipant.CLARBNumber = txtCLARB.Text; currentParticipant.FloridaStateNumber = txtFL.Text; currentParticipant.ID = participantID; currentParticipant.CSLANumber = txtCSLA.Text; currentParticipant.MiddleInitial = txtMiddleName.Text; currentParticipant.Email = txtEmail.Text; currentParticipant = oParticipantDataAccess.Update(currentParticipant); //check update successfully if (currentParticipant != null) { if (referalURL != "") { //redirect the appropriate page Response.Redirect(referalURL); } } else { //error occur show error message lblMsg.Text = "Attendees already exists with same values.<br/><br/>"; } } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Call every time when user click on remove Attendees button. /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs</param> protected void btnRemovePerticipant_Click(object sender, EventArgs e) { //Remove Perticipant button click, so remove the Attendees and its related course information from database //at first get the Attendees id from query string if (Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID] != null) { try { //get the Attendees id from query string long participantID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID]); ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); //check weather the Attendees is exist Participant currentParticipant = oParticipantDataAccess.GetParticipantByID(participantID); if (currentParticipant == null) { //null means the Attendees is currently not exist //show Attendees not found error message lblMsg.Text = LACESConstant.Messages.PARTICIPANT_NOT_FOUND_IN_ADMIN; lblMsg.ForeColor = System.Drawing.Color.Red; } else { //get the course id from query string long courseID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.COURSE_ID]); //check delete successfully if (oParticipantDataAccess.Delete(courseID, participantID)) { if (referalURL != "") { //redirect the appropriate page Response.Redirect(referalURL); } } else { //error occur show error message lblMsg.Text = "Unable to delete attendees."; lblMsg.ForeColor = System.Drawing.Color.Red; } } } catch (Exception ex) { throw ex; } } }
public static string GetOrgParticipant(string activeId) { List <ParticipantInfo> list = ParticipantDataAccess.GetParticipantByActive(activeId); if (list.Count > 0) { ParticipantOrgInfo org = ParticipantDataAccess.GetParticipantOrg(list[0].ParticipantId); return(org.UserId); } else { return(string.Empty); } }
public Active(string activeId) { ActiveId = activeId; ActiveInfo active = ActiveDataAccess.GetActive(activeId); ActiveName = active.ActiveName; FormId = active.FormId; ActiveType = active.ActiveType; List <ParticipantInfo> listParameterInfo = ParticipantDataAccess.GetParticipantByActive(activeId); //participant if (listParameterInfo.Count > 0) { m_Participant = (Participant)Assembly.Load("SimpleFlow.BusinessRules").CreateInstance("SimpleFlow.BusinessRules.Participant" + listParameterInfo[0].ParticipantKind); m_Participant.ParticipantId = listParameterInfo[0].ParticipantId; } }
/// <summary> /// Use to load Attendees information from Attendees id. /// Perticipant id get from query string. Return none. /// </summary> private void LoadParticipant() { //load the course information if (populateCourseInfo() == false) { return; } //check the query string if (Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID] != null) { try { //get the Attendees id from query string long participantID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID]); ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); Participant currentParticipant = oParticipantDataAccess.GetParticipantByID(participantID); //check weather the provider is available if (currentParticipant != null) { //available so assign to UI txtLastName.Text = currentParticipant.LastName; txtFirstName.Text = currentParticipant.FirstName; txtASLA.Text = currentParticipant.ASLANumber; txtCLARB.Text = currentParticipant.CLARBNumber; txtFL.Text = currentParticipant.FloridaStateNumber; txtCSLA.Text = currentParticipant.CSLANumber; txtMiddleName.Text = currentParticipant.MiddleInitial; } else { //show Attendees not found error message lblMsg.Text = LACESConstant.Messages.PARTICIPANT_NOT_FOUND_IN_ADMIN; lblMsg.ForeColor = System.Drawing.Color.Red; } } catch (Exception ex) { throw ex; } } }
public static void SaveOrgParticipant(string activeId, string userId) { List <ParticipantInfo> list = ParticipantDataAccess.GetParticipantByActive(activeId); if (list.Count > 0) { ParticipantOrgInfo org = ParticipantDataAccess.GetParticipantOrg(list[0].ParticipantId); org.UserId = userId; ParticipantDataAccess.UpdateParticipantOrg(org); } else { ParticipantOrgInfo org = new ParticipantOrgInfo(); org.UserId = userId; org.ParticipantId = Guid.NewGuid().ToString("D"); ParticipantDataAccess.InsertParticipantOrg(org); } }
/// <summary> /// Populate the participants of the course /// </summary> /// <param name="courseID"></param> private void populateParticipantList(long courseID) { ParticipantDataAccess participantDAL = new ParticipantDataAccess(); IList <Participant> participantList = participantDAL.GetAllParticipantByCourse(courseID); // Get Participants of the course ////EditParticipants.aspx?ParticipantID=53&CourseID=54 //dvParticipantList.InnerHtml = "Participant(s): " + participantList.Count.ToString(); //if (participantList.Count > 0) //{ // dvParticipantList.InnerHtml = "<table width='100%' cellpadding='3' cellspacing='0'><tr><td width='50%' class='participantList' align='right'><b>Last Name, </b></td><td class='participantList' left='right'><b>First Name</b></td></tr>"; // foreach (Participant participant in participantList) // { // dvParticipantList.InnerHtml += "<tr><td width='50%' align='right' valign='top'><a onclick='return confirmonCloseLink(\"You have made changes to the course details. Would you like to save them before editing this individual participant?\",\"EditParticipants.aspx?ParticipantID=" + participant.ID.ToString() + "&CourseID=" + courseID.ToString() + "\");' href='EditParticipants.aspx?ParticipantID=" + participant.ID.ToString() + "&CourseID=" + courseID.ToString() + "'>" + Server.HtmlEncode(participant.LastName) + "</a>,</td><td valign='top'>" + Server.HtmlEncode(participant.FirstName) + " <small><a href='ParticipantCourses.aspx?ParticipantID=" + participant.ID.ToString() + "'>[courses]</a></small></td></tr>"; // } // dvParticipantList.InnerHtml += "</table>"; //} }
protected void uilnkDownloadAttendees_Click(object sender, EventArgs e) { long courseID; LinkButton btn = (LinkButton)(sender); string yourValue = btn.CommandArgument; if (long.TryParse(yourValue, out courseID)) { DataGrid dg = new DataGrid(); CourseDataAccess oCourseDataAccess = new CourseDataAccess(); ApprovedProvider provider = (ApprovedProvider)Session[LACESConstant.SessionKeys.LOGEDIN_APPROVED_PROVIDER]; // Get provider information from Session ParticipantDataAccess participantDAL = new ParticipantDataAccess(); IList <Participant> participantList = participantDAL.GetAllParticipantByCourseIDProviderID(courseID, provider.ID); // Get Participants of the course DataTable tab = ConvertToDataTable(participantList); ConvertToCSV(tab); } }
public override List <Approver> GetApprover(int formNo) { Object obj = ParticipantDataAccess.GetParticipantField(ParticipantId, formNo); List <Approver> listApprover = new List <Approver>(); if (obj != null) { User user = new User((string)obj); Approver approver = new Approver(); approver.ApproverId = user.UserId; approver.ApproverName = user.UserName; approver.ApproveRole = ""; approver.SequenceNo = 1; listApprover.Add(approver); } return(listApprover); }
protected void btnSave_Click(object sender, EventArgs e) { if (Request.QueryString["courseid"] != null) { long courseid = 0; long.TryParse(Request.QueryString["courseid"], out courseid); if (courseid > 0) { List <Participant> participantList = new List <Participant>(); string last_name = uiTxtLastName.Text; string first_name = uiTxtFirstName.Text; string middle_name = uiTxtMiddleName.Text; string clarb_number = uiTxtCLARBNumber.Text; string asla_number = uiTxtASLANumber.Text; string csla_number = uiTxtCSLANumber.Text; string florida_number = uiTxtFLLicenseNumber.Text; string email = uiTxtEmail.Text; Participant oParticipant = null; oParticipant = new Participant(); oParticipant.LastName = last_name; oParticipant.FirstName = first_name; oParticipant.MiddleInitial = middle_name; oParticipant.ASLANumber = asla_number; oParticipant.CLARBNumber = clarb_number; oParticipant.CSLANumber = csla_number; oParticipant.FloridaStateNumber = florida_number; oParticipant.Email = email; //add in to the participant list participantList.Add(oParticipant); ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); oParticipantDataAccess.AddParticipantByCourse(courseid, participantList); Response.Redirect(Request.Url.PathAndQuery + "&success=t"); } } }
/// <summary> /// Populate the participants of the course. Get a course id which participant information want to get /// from database. Return none. /// </summary> /// <param name="courseID">Course ID</param> private void populateParticipantList(long courseID) { try { CourseDataAccess oCourseDataAccess = new CourseDataAccess(); ApprovedProvider provider = (ApprovedProvider)Session[LACESConstant.SessionKeys.LOGEDIN_APPROVED_PROVIDER]; // Get provider information from Session ParticipantDataAccess participantDAL = new ParticipantDataAccess(); IList <Participant> participantList = participantDAL.GetAllParticipantByCourseIDProviderID(courseID, provider.ID); // Get Participants of the course rptParticipantList.DataSource = participantList; rptParticipantList.DataBind(); //prepare the header //dvParticipantList.InnerHtml = "<div class='title'>Edit Attendees for: " + Server.HtmlEncode(oCourseDataAccess.GetCoursesDetailsByID(courseID).Title) + "</div><div class=''><table border='0' style='text-align:center;' cellpadding='0' cellspacing='0'>"; //if (participantList.Count > 0) //{ // dvParticipantList.InnerHtml += "<tr><td style='text-align:left; vertical-align:middle;' class='participantList'><strong>Last Name</strong></td><td style='text-align:left; vertical-align:middle;' class='participantList'><strong>First Name</strong></td></tr>"; // //dynamically add rest of the rows // foreach (Participant participant in participantList) // { // dvParticipantList.InnerHtml += "<tr><td style='text-align:left; vertical-align:middle;' class='participantList'><a href='EditAttendees.aspx?ParticipantID=" + participant.ID.ToString() + "&CourseID=" + courseID.ToString() + "'>" + Server.HtmlEncode(participant.LastName) + "</a></td>"; // dvParticipantList.InnerHtml += "<td style='text-align:left; vertical-align:middle;' class='participantList'>" + Server.HtmlEncode(participant.FirstName) + "</td></tr>"; // } //} //else //{ // dvParticipantList.InnerHtml += "<tr><td style='color:red'>No attendees found.</td></tr>"; //} //dvParticipantList.InnerHtml += "</div></table>"; //dvParticipantList.InnerHtml += "<br/><div><a href='../provider/UploadAttendees.aspx?courseid=" + courseID + "'>Upload Attendees in Excel</a><div>"; } catch (Exception ex) { throw ex; } }
/// <summary> /// Call every time when user click on remove Attendees button. /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs</param> protected void btnRemovePerticipant_Click(object sender, EventArgs e) { //Remove Perticipant button click, so remove the Attendees and its related course information from database try { Course objCourse = getCourseInfo(); if (objCourse != null) { ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); //check weather the Attendees is exist Participant currentParticipant = oParticipantDataAccess.GetParticipantByIDandCourseID(participantID, courseID); if (currentParticipant != null) { //check delete successfully if (oParticipantDataAccess.Delete(objCourse.ID, participantID)) { if (referalURL != "") { //redirect the appropriate page Response.Redirect(referalURL); } } else { //error occur show error message lblMsg.Text = "Unable to delete attendees."; } } } } catch (Exception ex) { throw ex; } }
/// <summary> /// Populate the participants of the course. Get a course id which participant information want to get /// from database. Return none. /// </summary> /// <param name="courseID">Course ID</param> private void populateParticipantList(long courseID) { try { CourseDataAccess oCourseDataAccess = new CourseDataAccess(); ParticipantDataAccess participantDAL = new ParticipantDataAccess(); IList <Participant> participantList = participantDAL.GetAllParticipantByCourse(courseID); // Get Participants of the course //prepare the header dvParticipantList.InnerHtml = "<div class='title'>Edit Attendees for: " + Server.HtmlEncode(oCourseDataAccess.GetCoursesDetailsByID(courseID).Title) + "</div><div><table border='0' style='text-align:left;' cellpadding='0' cellspacing='0'>"; if (participantList.Count > 0) { dvParticipantList.InnerHtml += "<tr><td style='text-align:left; vertical-align:left;' class='participantList'><strong>Last Name</strong></td><td style='text-align:left; vertical-align:middle;' class='participantList'><strong>First Name</strong></td></tr>"; //dynamically add rest of the rows foreach (Participant participant in participantList) { dvParticipantList.InnerHtml += "<tr><td style='text-align:left; vertical-align:left;' class='participantList'><a href='EditAttendees.aspx?ParticipantID=" + participant.ID.ToString() + "&CourseID=" + courseID.ToString() + "'>" + Server.HtmlEncode(participant.LastName) + "</a></td>"; dvParticipantList.InnerHtml += "<td style='text-align:left; vertical-align:left;' class='participantList'>" + Server.HtmlEncode(participant.FirstName) + "</td></tr>"; } } else { dvParticipantList.InnerHtml += "<tr><td style='color:red'>No attendees found.</td></tr>"; } dvParticipantList.InnerHtml += "</div></table>"; dvParticipantList.InnerHtml += "<br/><div><a href='../admin/UploadAttendees.aspx?courseid=" + courseID + "'>Upload Attendees in Excel</a><div>"; } catch (Exception ex) { throw ex; } }
/// <summary> /// Call when Save & Finish Button Click form UI /// </summary> /// <param name="sender">sender object</param> /// <param name="e">EventArgs</param> protected void btnSaveFinish_Click(object sender, EventArgs e) { //Save button click, so store the updated information into the database //at first get the Attendees id from query string if (Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID] != null) { try { //get the Attendees id from query string long participantID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.PARTICIPANT_ID]); ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); Participant currentParticipant = new Participant(); //check weather the participant is exist currentParticipant = oParticipantDataAccess.GetParticipantByID(participantID); if (currentParticipant == null) { //null means the Attendees is currently not exist //show Attendees not found error message lblMsg.Text = LACESConstant.Messages.PARTICIPANT_NOT_FOUND_IN_ADMIN; lblMsg.ForeColor = System.Drawing.Color.Red; } else { //Attendees exist so update currentParticipant.LastName = txtLastName.Text; currentParticipant.FirstName = txtFirstName.Text; currentParticipant.ASLANumber = txtASLA.Text; currentParticipant.CLARBNumber = txtCLARB.Text; currentParticipant.FloridaStateNumber = txtFL.Text; currentParticipant.ID = participantID; currentParticipant.CSLANumber = txtCSLA.Text; currentParticipant.MiddleInitial = txtMiddleName.Text; currentParticipant = oParticipantDataAccess.Update(currentParticipant); //check update successfully if (currentParticipant != null) { if (referalURL != "") { //redirect the appropriate page Response.Redirect(referalURL); } } else { //error occur show error message lblMsg.Text = "Attendees already exists with same values.<br/><br/>"; lblMsg.ForeColor = System.Drawing.Color.Red; } } } catch (Exception ex) { throw ex; } } }
protected void gridview_RowCommand(object sender, GridViewCommandEventArgs e) { string strFirstName = "", strLastName = "", strASLAMemberNumber = "", strCLARBNumber = "", strFloridaStateNumber = "", strMiddleInitial = "", strCSLANumber = "", strEmail = ""; WebControl wc = e.CommandSource as WebControl; GridViewRow row = wc.NamingContainer as GridViewRow; object strid = (object)uiGVAllAttendees.DataKeys[row.RowIndex].Value; long participantID; if (long.TryParse(strid.ToString(), out participantID)) { if (e.CommandArgument.ToString().ToLower() == "save") { TextBox tbFirstName = (TextBox)row.FindControl("uiTxtFirstName"); strFirstName = tbFirstName != null ? tbFirstName.Text : ""; TextBox tbLastName = (TextBox)row.FindControl("uiTxtLastName"); strLastName = tbLastName != null ? tbLastName.Text : ""; TextBox tbAslaMemberNumber = (TextBox)row.FindControl("uiTxtASLAMemberNumber"); strASLAMemberNumber = tbAslaMemberNumber != null ? tbAslaMemberNumber.Text : ""; TextBox tbCLARBNumber = (TextBox)row.FindControl("uiTxtCLARBNumber"); strCLARBNumber = tbCLARBNumber != null ? tbCLARBNumber.Text : ""; TextBox tbFloridaNumber = (TextBox)row.FindControl("uiTxtFloridaStateNumber"); strFloridaStateNumber = tbFloridaNumber != null ? tbFloridaNumber.Text : ""; TextBox tbMiddleInitial = (TextBox)row.FindControl("uiTxtMiddleInitial"); strMiddleInitial = tbMiddleInitial != null ? tbMiddleInitial.Text : ""; TextBox tbCSLANumber = (TextBox)row.FindControl("uiTxtCSLANumber"); strCSLANumber = tbCLARBNumber != null ? tbCSLANumber.Text : ""; TextBox tbEmail = (TextBox)row.FindControl("uiTxtEmail"); Label lblResponse = (Label)row.FindControl("uiLblResponse"); strEmail = tbEmail != null ? tbEmail.Text : ""; try { ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); Participant currentParticipant = new Participant(); //check weather the participant is exist currentParticipant = oParticipantDataAccess.GetParticipantByID(participantID); if (currentParticipant != null) { //Attendees exist so update currentParticipant.LastName = strLastName; currentParticipant.FirstName = strFirstName; currentParticipant.ASLANumber = strASLAMemberNumber; currentParticipant.CLARBNumber = strCLARBNumber; currentParticipant.FloridaStateNumber = strFloridaStateNumber; currentParticipant.ID = participantID; currentParticipant.CSLANumber = strCSLANumber; currentParticipant.MiddleInitial = strMiddleInitial; currentParticipant.Email = strEmail; currentParticipant = oParticipantDataAccess.Update(currentParticipant); lblResponse.Text = "Updated"; } } catch (Exception ex) { lblResponse.Text = ("Error:" + ex.Message); } } else if (e.CommandArgument.ToString().ToLower() == "remove") { ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); Participant currentParticipant = new Participant(); //check weather the participant is exist currentParticipant = oParticipantDataAccess.GetParticipantByID(participantID); if (currentParticipant != null) { long lngCourseID; if (long.TryParse(Request.QueryString["CourseID"], out lngCourseID)) { bool isDeleted = oParticipantDataAccess.Delete(lngCourseID, participantID); if (isDeleted) { Response.Redirect("EditAllCourseAttendees.aspx?CourseID=" + lngCourseID.ToString() + "&fname=" + currentParticipant.FirstName + "&lname=" + currentParticipant.LastName); } } } } } }
/// <summary> /// Uplaod an Excel file /// </summary> private bool UploadExcelFile() { string staticErrorMessage = "There has been an error with your upload. Please ensure you use our template to upload attendees.<br/> "; lb_error_message.Style["color"] = "red"; bool blnShowGetNewExcel = false; //check the file extension, if not .xls file then show error if (!FileUpload1.FileName.EndsWith(".xls") && !FileUpload1.FileName.EndsWith(".xlsx")) { lb_error_message.InnerHtml = staticErrorMessage + "<br />location=1";// "Your provided file type is not supported."; return(false); } //prepare the file path fileLocation = AppDomain.CurrentDomain.BaseDirectory + "xls\\" + System.DateTime.Now.Ticks + FileUpload1.FileName; try { //get the course id from query string long courseID = 0; List <Participant> participantList = new List <Participant>(); //create the file loacton FileStream oFileStream = File.Create(fileLocation); foreach (byte b in FileUpload1.FileBytes) { oFileStream.WriteByte(b); } oFileStream.Close(); Participant oParticipant = null; //Debugger.Break(); //now load it to UI if (Request.QueryString["courseid"] != null) { try { courseID = Convert.ToInt32(Request.QueryString["courseid"]); } catch { courseID = 0; } //no course found if (courseID == 0) { lb_error_message.InnerHtml = staticErrorMessage + "<br />location=2";//"Course ID is invalid/not exists."; return(false); } //get the current login provider ApprovedProvider provider = (ApprovedProvider)Session[LACESConstant.SessionKeys.LOGEDIN_APPROVED_PROVIDER]; //check is the course available or not CourseDataAccess oCourseDataAccess = new CourseDataAccess(); if (oCourseDataAccess.GetCoursesDetailsByIDandProviderID(courseID, provider.ID) == null) { lb_error_message.InnerHtml = staticErrorMessage + "<br />location=3";// "Course ID is invalid/not exists."; return(false); } } else { lb_error_message.InnerHtml = staticErrorMessage + "<br />location=4";//"Course ID is invalid."; return(false); } DataTable oDataTable = LACESUtilities.ReadXLFile(fileLocation, "Attendees"); // Response.Write(fileLocation); // Response.End(); if (oDataTable == null) { lb_error_message.InnerHtml = staticErrorMessage + "<br />location=5";// "Attendees' information does not match with the template."; return(false); } foreach (DataRow dr in oDataTable.Rows) { oParticipant = new Participant(); string last_name = dr["Last"].ToString().Trim(); string first_name = dr["First"].ToString().Trim(); string middle_name = dr["Middle"].ToString().Trim(); string asla_number = dr["ASLA"].ToString().Trim(); string clarb_number = dr["CLARB"].ToString().Trim(); string csla_name = dr["CSLA"].ToString().Trim(); string florida_number = dr["FL"].ToString().Trim(); string email = ""; if (dr.Table.Columns.Contains("email")) { email = dr["email"].ToString().Trim(); } else { blnShowGetNewExcel = true; } //if (last_name == "" && first_name == "") //{ // lb_error_message.InnerHtml = staticErrorMessage + "<br />location=6";//"In your uploaded file, one or more first name/last name are //empty."; // return false; //} //if any field is empty then exit the process if (last_name != "" && first_name != "")// && asla_number != "" && clarb_number != "" && florida_number != "") { oParticipant.LastName = last_name; oParticipant.FirstName = first_name; oParticipant.MiddleInitial = middle_name; oParticipant.ASLANumber = asla_number; oParticipant.CLARBNumber = clarb_number; oParticipant.CSLANumber = csla_name; oParticipant.FloridaStateNumber = florida_number; oParticipant.Email = email; //add in to the participant list participantList.Add(oParticipant); } else if (csla_name == "" && middle_name == "" && last_name == "" && first_name == "" && asla_number == "" && clarb_number == "" && florida_number == "") { //if empty row found then discard the row } else { //some empty field found. so inform the error lb_error_message.InnerHtml = staticErrorMessage + "<br />location=7";// "Attendees' information does not match with the template."; return(false); } } if (participantList.Count > 0) { //finally add the participant in to the database ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); oParticipantDataAccess.AddParticipantByCourse(courseID, participantList); } //finally remove the excel file LACESUtilities.RemoveCreatedFileFromDisk(fileLocation); if (blnShowGetNewExcel) { lb_error_message.InnerHtml = "ALERT: Please download new Excel Template that now captures attendee email. This did not prevent your current attendee file from being successfully uploaded.<br/> "; lb_error_message.Style["color"] = "red"; } else { lb_error_message.InnerHtml = "Thank you. Your attendee file has been successfully uploaded.<br/> "; lb_error_message.Style["color"] = "green"; } //Response.Redirect("../Provider/ManageAttendees.aspx?courseid=" + courseID); } catch (Exception ex) { lb_error_message.InnerHtml = staticErrorMessage + "<br />location=1" + "<br />" + ex.Message;//"There has been an error with your upload. Please ensure you use our template to upload attendees."; if (File.Exists(fileLocation)) { File.Delete(fileLocation); } } return(true); }
/// <summary> /// Used to add participants for a specific course. course id is get form query string /// </summary> /// <returns>Return true if add successfull, otherwise return false</returns> private bool AddParticipants() { try { long courseID = 0; //get the course id from query string if (Request.QueryString[LACESConstant.QueryString.COURSE_ID] != null) { courseID = Convert.ToInt64(Request.QueryString[LACESConstant.QueryString.COURSE_ID]); } //get course detail by courseid and providerid Provider1 provider = (Provider1)Session[LACESConstant.SessionKeys.LOGEDIN_PROVIDER]; // Get provider information from Session CourseDataAccess courseDAL = new CourseDataAccess(); Course course = courseDAL.GetCoursesDetailsByIDandProviderID(courseID, provider.ID); // Get Courses Details from Course ID and Provider ID ///If the course is related with current provider if (course != null && course.ID > 0) { List <Participant> participantList = new List <Participant>(); Participant participant; string firstnameControl = "", lastnameControl = "", ASLANumberControl = "", CLARBNumControl = "", StateNumberControl = ""; string tempValue = "ctl00$ContentPlaceHolderLeftPane$row"; for (int row = 1; row <= 20; row++) { participant = new Participant(); //get a row's columns lastnameControl = tempValue + row + "1"; firstnameControl = tempValue + row + "2"; ASLANumberControl = tempValue + row + "3"; CLARBNumControl = tempValue + row + "4"; StateNumberControl = tempValue + row + "5"; //get the dynamic TextBox controls participant.LastName = ((TextBox)(this.FindControl(lastnameControl))).Text; participant.FirstName = ((TextBox)(this.FindControl(firstnameControl))).Text; participant.ASLANumber = ((TextBox)(this.FindControl(ASLANumberControl))).Text; participant.CLARBNumber = ((TextBox)(this.FindControl(CLARBNumControl))).Text; participant.FloridaStateNumber = ((TextBox)(this.FindControl(StateNumberControl))).Text; //check weather the required field is not empty if (participant.LastName != "" && participant.FirstName != "") { //add in to the participant list participantList.Add(participant); } } if (participantList.Count > 0) { //add the participant list into the database ParticipantDataAccess oParticipantDataAccess = new ParticipantDataAccess(); oParticipantDataAccess.AddParticipantByCourse(courseID, participantList); } return(true); } } catch (Exception ex) { return(false); } return(false); }