public string insertWorkExperience(WorkExperienceDetails workExpDetails) { try { SqlCommand _userSqlCommand = new SqlCommand(); string _userCommandText = @"Insert INTO Work_Experience (StudentId, RecentCompanyYear, RecentCompanyName, TotalYrsExp, PreviousGA, PreGAFaculty,FacultyRef) values(@StudentId, @RecentCompanyYear, @RecentCompanyName, @TotalYrsExp, @PreviousGA, @PreGAFaculty, @FacultyRef) "; _userSqlCommand.Connection = _studentDatabaseConnection.OpenSQlDatabaseConnection(); _userSqlCommand.CommandText = _userCommandText; _userSqlCommand.Parameters.AddWithValue("@StudentId", workExpDetails.StudentId); _userSqlCommand.Parameters.AddWithValue("@RecentCompanyYear", workExpDetails.RecentCompanyYear); _userSqlCommand.Parameters.AddWithValue("@RecentCompanyName", workExpDetails.RecentCompanyName); _userSqlCommand.Parameters.AddWithValue("@TotalYrsExp", Convert.ToInt32(workExpDetails.TotalYrsExp)); _userSqlCommand.Parameters.AddWithValue("@PreviousGA", workExpDetails.PreviousGA); _userSqlCommand.Parameters.AddWithValue("@PreGAFaculty", workExpDetails.PreGAFaculty); _userSqlCommand.Parameters.AddWithValue("@FacultyRef", workExpDetails.FacultyRef); _userSqlCommand.ExecuteNonQuery(); return("Details Entered Successfully"); } catch (Exception Ex) { return(Ex.Message); } finally { _studentDatabaseConnection.CloseSqlDatabaseConnection(); } }
//Function to save work experience details of student private void workExpDetailsButton_Click(object sender, EventArgs e) { try { IWorkExperienceDetails _workExpDetails = new studentWorkExpDetails(); WorkExperienceDetails _studentWorkExpDetails = new WorkExperienceDetails(); if (!NoneRadioButton.Checked) { _studentWorkExpDetails.StudentId = _studentID; _studentWorkExpDetails.RecentCompanyYear = (string.IsNullOrEmpty(yearsTextbox.Text) == false) ? yearsTextbox.Text : "NA"; _studentWorkExpDetails.RecentCompanyName = (string.IsNullOrEmpty(companyTextbox.Text) == false) ? companyTextbox.Text : "NA"; _studentWorkExpDetails.TotalYrsExp = (string.IsNullOrEmpty(totalYearsExperienceTextbox.Text) == false) ? Convert.ToInt32(totalYearsExperienceTextbox.Text) : 0; _studentWorkExpDetails.PreviousGA = (string.IsNullOrEmpty(previousGATextbox.Text) == false) ? previousGATextbox.Text : "NA"; _studentWorkExpDetails.PreGAFaculty = (string.IsNullOrEmpty(prevGAFacultyTextbox.Text) == false) ? prevGAFacultyTextbox.Text : "NA"; _studentWorkExpDetails.FacultyRef = (string.IsNullOrEmpty(facultyReferenceTextbox.Text) == false) ? facultyReferenceTextbox.Text : "NA"; } else { _studentWorkExpDetails.StudentId = _studentID; _studentWorkExpDetails.RecentCompanyYear = "No Expereience"; _studentWorkExpDetails.RecentCompanyName = "No Expereience"; _studentWorkExpDetails.TotalYrsExp = 0; _studentWorkExpDetails.PreviousGA = "No Expereience"; _studentWorkExpDetails.PreGAFaculty = "No Expereience"; _studentWorkExpDetails.FacultyRef = "No Expereience"; } string _resultWorkExp = _workExpDetails.insertWorkExperience(_studentWorkExpDetails); MessageBox.Show(_resultWorkExp); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public string UpDateStudentWrkExpDetails(WorkExperienceDetails studentWrkExpDetail) { try { SqlCommand _userSqlCommand = new SqlCommand(); string _userCommandText = @"Update Work_Experience Set RecentCompanyYear = @RecentCompanyYear, RecentCompanyName = @RecentCompanyName, TotalYrsExp = @TotalYrsExp, PreviousGA = @PreviousGA, PreGAFaculty = @PreGAFaculty, FacultyRef = @FacultyRef where StudentId = @StudentId "; _userSqlCommand.Connection = _studentDatabaseConnection.OpenSQlDatabaseConnection(); _userSqlCommand.CommandText = _userCommandText; _userSqlCommand.Parameters.AddWithValue("@StudentId", studentWrkExpDetail.StudentId); _userSqlCommand.Parameters.AddWithValue("@RecentCompanyYear", studentWrkExpDetail.RecentCompanyYear); _userSqlCommand.Parameters.AddWithValue("@RecentCompanyName", studentWrkExpDetail.RecentCompanyName); _userSqlCommand.Parameters.AddWithValue("@TotalYrsExp", Convert.ToInt32(studentWrkExpDetail.TotalYrsExp)); _userSqlCommand.Parameters.AddWithValue("@PreviousGA", studentWrkExpDetail.PreviousGA); _userSqlCommand.Parameters.AddWithValue("@PreGAFaculty", studentWrkExpDetail.PreGAFaculty); _userSqlCommand.Parameters.AddWithValue("@FacultyRef", studentWrkExpDetail.FacultyRef); _userSqlCommand.ExecuteNonQuery(); return("Details Entered Successfully"); } catch (Exception Ex) { return(Ex.Message); } finally { _studentDatabaseConnection.CloseSqlDatabaseConnection(); } }
//get request to display work experience details private void getWorkExpButton_Click(object sender, EventArgs e) { try { IWorkExperienceDetails _workExpDetails = new studentWorkExpDetails(); _studentID = 700; WorkExperienceDetails _resultWorkExpDetails = _workExpDetails.GetStudentWrkExpDetailsBy(_studentID); companyTextbox.Text = _resultWorkExpDetails.RecentCompanyName; yearsTextbox.Text = _resultWorkExpDetails.RecentCompanyYear; totalYearsExperienceTextbox.Text = Convert.ToString(_resultWorkExpDetails.TotalYrsExp); previousGATextbox.Text = _resultWorkExpDetails.PreviousGA; prevGAFacultyTextbox.Text = _resultWorkExpDetails.PreGAFaculty; facultyReferenceTextbox.Text = _resultWorkExpDetails.FacultyRef; } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public WorkExperienceDetails GetStudentWrkExpDetailsBy(int Id) { try { SqlCommand _userSqlCommand = new SqlCommand(); string _userCommandText = @"select *from Work_Experience where StudentId = @StudentId "; _userSqlCommand.Connection = _studentDatabaseConnection.OpenSQlDatabaseConnection(); _userSqlCommand.CommandText = _userCommandText; _userSqlCommand.Parameters.AddWithValue("@StudentId", Id); SqlDataReader _resultStudentWrkExpDetails = _userSqlCommand.ExecuteReader(); WorkExperienceDetails _studentWrkExpDetails = new WorkExperienceDetails(); while (_resultStudentWrkExpDetails.Read()) { _studentWrkExpDetails.RecentCompanyYear = _resultStudentWrkExpDetails["RecentCompanyYear"].ToString(); _studentWrkExpDetails.RecentCompanyName = _resultStudentWrkExpDetails["RecentCompanyName"].ToString(); _studentWrkExpDetails.TotalYrsExp = (int)_resultStudentWrkExpDetails["TotalYrsExp"]; _studentWrkExpDetails.PreviousGA = _resultStudentWrkExpDetails["PreviousGA"].ToString(); _studentWrkExpDetails.PreGAFaculty = _resultStudentWrkExpDetails["PreGAFaculty"].ToString(); _studentWrkExpDetails.FacultyRef = _resultStudentWrkExpDetails["FacultyRef"].ToString(); } return(_studentWrkExpDetails); } catch (Exception Ex) { throw Ex; } finally { _studentDatabaseConnection.CloseSqlDatabaseConnection(); } }
//Function to update Work Experience Details private void updateWorkExpButton_Click(object sender, EventArgs e) { try { IWorkExperienceDetails _workExpDetails = new studentWorkExpDetails(); WorkExperienceDetails _studentWorkExpDetails = new WorkExperienceDetails(); if (!NoneRadioButton.Checked) { _studentWorkExpDetails.StudentId = 700;//_studentID; _studentWorkExpDetails.RecentCompanyYear = yearsTextbox.Text; _studentWorkExpDetails.RecentCompanyName = companyTextbox.Text; _studentWorkExpDetails.TotalYrsExp = Convert.ToInt32(totalYearsExperienceTextbox.Text); _studentWorkExpDetails.PreviousGA = previousGATextbox.Text; _studentWorkExpDetails.PreGAFaculty = prevGAFacultyTextbox.Text; _studentWorkExpDetails.FacultyRef = facultyReferenceTextbox.Text; } else { _studentWorkExpDetails.StudentId = _studentID; _studentWorkExpDetails.RecentCompanyYear = "No Expereience"; _studentWorkExpDetails.RecentCompanyName = "No Expereience"; _studentWorkExpDetails.TotalYrsExp = 0; _studentWorkExpDetails.PreviousGA = "No Expereience"; _studentWorkExpDetails.PreGAFaculty = "No Expereience"; _studentWorkExpDetails.FacultyRef = "No Expereience"; } string _resultWorkExp = _workExpDetails.UpDateStudentWrkExpDetails(_studentWorkExpDetails); MessageBox.Show(_resultWorkExp); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }