//When you select another evaluation, populate the boxes with the information from the selected evaluation. private void evalListBox_SelectedIndexChanged(object sender, EventArgs e) { selectedEval = (string)evalListBox.SelectedItem; desiredEval = Tools.findEval(selectedEval, emp); idLabel.Text = desiredEval.evalID; empNameLabel.Text = emp.company; dateEvaledLabel.Text = desiredEval.currentEvalDate; workQualScoreLabel.Text = desiredEval.workQualScore; workQualBox.Text = desiredEval.workQualComments.Replace('|', ','); workHabScoreLabel.Text = desiredEval.workHabScore; workHabBox.Text = desiredEval.workHabComments.Replace('|', ','); jobKnowScoreLabel.Text = desiredEval.jobKnowScore; jobKnowBox.Text = desiredEval.jobKnowComments.Replace('|', ','); behaviorScoreLabel.Text = desiredEval.behaviorScore; behaviorBox.Text = desiredEval.behaviorComments.Replace('|', ','); overallProgScoreLabel.Text = desiredEval.overallProgScore; overallProgBox.Text = desiredEval.overallProgressComments.Replace('|', ','); avgScoreLabel.Text = desiredEval.avgScore; recommendLabel.Text = desiredEval.recommend; nextEvalLabel.Text = desiredEval.nextEvalDate; }
private void nextEvalNext_Click(object sender, EventArgs e) { bool isDone = true; foreach (Employee emp in MainForm.Employees) { foreach (Evaluation eval in emp.employeeEvaluations) { if (eval.evalID.Equals(evalID)) { MessageBox.Show("An evaluation with this identifier already exists. Please enter a new one."); isDone = false; } } } if (isDone == true) { //Calculate average score avgScore = (workQualScore + workHabScore + jobKnowScore + behaviorScore) / 4; //Get Current Date currentEvalDate = DateTime.Today.ToShortDateString(); //Recommend? if (wouldRecommend == true) { recommend = "Yes"; } else if (wouldRecommend == false) { recommend = "No"; } //Format current date string fileCompatibleCurrentDate = currentEvalDate.Replace('/', '_'); //Saving process FileStream evalCSV = new FileStream(mainEvalFilePath, FileMode.Append, FileAccess.Write); //Create necessary directories, assign path and field variables string[] evalFields = { currentEvalDate, evalID, selectedEmployeeID, selectedEmployeeName, selectedEmployerID, selectedEmployerName, nextEvalDate, workQualScore.ToString(), workQualComments, workHabScore.ToString(), workHabComments, jobKnowScore.ToString(), jobKnowComments, behaviorScore.ToString(), behaviorComments, avgScore.ToString(), overallProgScore.ToString(), overallProgressComments, recommend }; string formattedEvalFields = Tools.formatToCSV(evalFields); Evaluation newEval = new Evaluation(currentEvalDate, evalID, selectedEmployeeID, selectedEmployeeName, selectedEmployerID, selectedEmployerName, nextEvalDate, workQualScore.ToString(), workQualComments, workHabScore.ToString(), workHabComments, jobKnowScore.ToString(), jobKnowComments, behaviorScore.ToString(), behaviorComments, avgScore.ToString(), overallProgScore.ToString(), overallProgressComments, recommend); Employee employee_evaluated = Tools.findEmployee(selectedEmployeeID + " " + selectedEmployeeName); employee_evaluated.employeeEvaluations.Add(newEval); //Write the field placement to its own report and add the same data in CSV format to the data file StreamWriter fileWriter = new StreamWriter(evalCSV); fileWriter.WriteLine(formattedEvalFields, Encoding.UTF8); fileWriter.Close(); //Clear data from elements and rebind them with updated fields MainFormEvalTable.Rows.Clear(); Tools.readAndBindTableData(mainEvalFilePath, MainFormEvalTable, dateColumn); string recentsBarText = currentEvalDate + " " + selectedEmployeeName; recentsBar.Items.Add(recentsBarText); MessageBox.Show("Saved"); MainFormClass.deleteCurrentTab(); } }