public Models.EvaluationModel GetLogbookEvaluation(String username) { Models.EvaluationModel model = new Models.EvaluationModel(); using (SqlConnection cn = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("SELECT * FROM [dbo].[Evaluation_Table] WHERE Type ='Logbook' AND Fk_username = '******' AND Evaluated_By ='" + ViewBag.Role + "'", cn); cn.Open(); SqlDataReader rd = cmd.ExecuteReader(); if (rd.Read()) { model.Id = Int32.Parse(Convert.ToString(rd.GetSqlValue(0))); model.Type = Convert.ToString(rd.GetSqlValue(1)); model.Fk_username = Convert.ToString(rd.GetSqlValue(2)); model.OptionA = Convert.ToInt32(Convert.ToString(rd.GetSqlValue(3))); model.OptionB = Convert.ToInt32(Convert.ToString(rd.GetSqlValue(4))); model.OptionC = Convert.ToInt32(Convert.ToString(rd.GetSqlValue(5))); if (model.Type == "Presentation") { model.OptionD = Convert.ToInt32(Convert.ToString(rd.GetSqlValue(6))); } model.Comment = Convert.ToString(rd.GetSqlValue(7)); model.EvaluatedBy = Convert.ToString(rd.GetSqlValue(8)); } } return(model); }
public String GetEvaluationMark(String username) { List <Models.EvaluationModel> list = new List <Models.EvaluationModel>(); Models.EvaluationModel model = null; Models.EvaluationModel result = new Models.EvaluationModel(); using (SqlConnection cn = new SqlConnection(connectionString)) { SqlCommand cmd = new SqlCommand("SELECT * FROM [dbo].[Evaluation_Table] WHERE Fk_username = '******'", cn); cn.Open(); SqlDataReader rd = cmd.ExecuteReader(); while (rd.Read()) { model = new Models.EvaluationModel(); model.Id = Int32.Parse(Convert.ToString(rd.GetSqlValue(0))); model.Type = Convert.ToString(rd.GetSqlValue(1)); model.Fk_username = Convert.ToString(rd.GetSqlValue(2)); model.OptionA = Convert.ToInt32(Convert.ToString(rd.GetSqlValue(3))); model.OptionB = Convert.ToInt32(Convert.ToString(rd.GetSqlValue(4))); model.OptionC = Convert.ToInt32(Convert.ToString(rd.GetSqlValue(5))); model.OptionD = Convert.ToInt32(Convert.ToString(rd.GetSqlValue(6))); model.Comment = Convert.ToString(rd.GetSqlValue(7)); model.EvaluatedBy = Convert.ToString(rd.GetSqlValue(8)); list.Add(model); } foreach (Models.EvaluationModel test in list) { if (test.EvaluatedBy == "Industrial Supervisor" && test.Type == "Internship") { result.ISupervisorInternshipMark = (Double)(test.OptionA + test.OptionB + test.OptionC) / 15 * 100 / 6; } else if (test.EvaluatedBy == "Industrial Supervisor" && test.Type == "Logbook") { result.ISupervisorLogbookMark = (Double)(test.OptionA + test.OptionB + test.OptionC) / 15 * 100 / 6; } else if (test.EvaluatedBy == "Industrial Supervisor" && test.Type == "Presentation") { result.ISupervisorPresentationMark = (Double)(test.OptionA + test.OptionB + test.OptionC + test.OptionD) / 20 * 100 / 6; } else if (test.EvaluatedBy == "Faculty Supervisor" && test.Type == "Internship") { result.FSupervisorInternshipMark = (Double)(test.OptionA + test.OptionB + test.OptionC) / 15 * 100 / 6; } else if (test.EvaluatedBy == "Faculty Supervisor" && test.Type == "Logbook") { result.FSupervisorLogbookMark = (Double)(test.OptionA + test.OptionB + test.OptionC) / 15 * 100 / 6; } else if (test.EvaluatedBy == "Faculty Supervisor" && test.Type == "Presentation") { result.FSupervisorPresentationMark = (Double)(test.OptionA + test.OptionB + test.OptionC + test.OptionD) / 20 * 100 / 6; } } cn.Close(); } Double resultDouble = result.FSupervisorInternshipMark + result.FSupervisorLogbookMark + result.FSupervisorPresentationMark + result.ISupervisorInternshipMark + result.ISupervisorLogbookMark + result.ISupervisorPresentationMark; return(resultDouble.ToString("0.00")); }
public ActionResult LogbookEvaluation(String username) { if (username == null) { return(RedirectToAction("EvaluationSvView")); } Models.EvaluationModel evaluation = new Models.EvaluationModel(); evaluation = GetLogbookEvaluation(username); evaluation.User = new Models.UserModel(); evaluation.User = Models.UserModel.GetUserDetails(username); return(View(evaluation)); }
public ActionResult EvaluatePresentation(Models.EvaluationModel model) { using (SqlConnection cn = new SqlConnection(connectionString)) { String _sql = @"INSERT INTO [dbo].[Evaluation_Table] VALUES ('Presentation', '" + model.User.Username + "', " + model.OptionA + " , " + model.OptionB + " , " + model.OptionC + ", 0, '" + model.Comment + "', '" + model.EvaluatedBy + "')"; var cmd = new SqlCommand(_sql, cn); cn.Open(); cmd.ExecuteNonQuery(); } return(RedirectToAction("EvaluationSvView")); }