protected void Page_Load(object sender, EventArgs e) { try { emp = Session["Employee"] as List <Employee_t>; if (emp == null) { Response.Redirect("~/Login.aspx", false); } empId = emp[0].Emp_Id; role = Session["Role"] as Role_t; appraisal = Session["appraisal"] as Appraisal_t; Rating = new List <int>(); for (int i = 1; i <= 5; i++) { Rating.Add(i); } RatingItem = new List <string>(); RatingItem.Add("Extraordinary"); RatingItem.Add("Exemplary +"); RatingItem.Add("Exemplary"); RatingItem.Add("Enabler +"); RatingItem.Add("Enabler"); appraisal = Session["appraisal"] as Appraisal_t; if (Session["Type"] != null) { type = Convert.ToInt32(Session["Type"].ToString()); } if (!Page.IsPostBack) { //jquery drop ReviewerRating.DataSource = RatingItem; ReviewerRating.DataBind(); using (PerformanceAppEntities db = new PerformanceAppEntities()) { string[] CriteriaIds = role.CriteriaIds.Split(';'); for (int i = 0; i < CriteriaIds.Length; i++) { Guid Id = Guid.Parse(CriteriaIds[i]); Parameter_t Localparameter = db.Parameter_t.Where(m => m.CriteriaId == Id).Single(); Parameters.Add(Localparameter); } ProjectGrid.DataSource = Parameters; ProjectGrid.DataBind(); if (appraisal != null) { if (appraisal.EmpProjects != null) { ReviewerRating.Text = appraisal.ProRevRating; ReviewerComment.Text = appraisal.ProRevComment; OtherTextBox.Text = appraisal.ProAppOtherCmnt; ProjectIds = appraisal.EmpProjects.Split(';'); empProject = new List <EmpProject_t>(); for (int t = 0; t < ProjectIds.Length - 1; t++) { Guid ID = Guid.Parse(ProjectIds[t]); EmpProject_t empPro = db.EmpProject_t.Where(m => m.EmpProjId == ID).Single(); empProject.Add(empPro); } if (empProject != null) { int total = 0; foreach (var item in empProject.OrderBy(order => order.Type)) { GridViewRow row = ProjectGrid.Rows[total]; if (item.Type == total) { DropDownList combo1 = (DropDownList)row.FindControl("SelfRating"); combo1.SelectedValue = item.Self_Rating.ToString(); TextBox text_Self = row.FindControl("SelfComment") as TextBox; text_Self.Text = item.SelfComments; DropDownList combo2 = (DropDownList)row.FindControl("AppraiserRating"); combo2.SelectedValue = item.App_Rating.ToString(); TextBox text_App = row.FindControl("AppraiserComment") as TextBox; text_App.Text = item.AppComments; } total++; } } } } } if (type == 0) { name.Text = emp[0].Firstname + " " + emp[0].Lastname; Reviwer.Visible = false; OtherComments.Visible = false; OtherTextBox.Visible = false; } else { name.Text = Session["Firstname"].ToString() + " " + Session["Lastname"].ToString(); } } } catch (Exception ex) { using (PerformanceAppEntities db = new PerformanceAppEntities()) { Log_t log = new Log_t(); log.Error_Message = ex.Message; log.Page = "PerformanceAppraisal3"; log.Method = "Page_Load"; log.Datetime = DateTime.Now; db.Log_t.Add(log); db.SaveChanges(); Response.Redirect("~/Login.aspx", false); } } }
public void Save() { try { string EmpProjectId = ""; for (int i = 0; i < ProjectGrid.Rows.Count; i++) { using (PerformanceAppEntities db = new PerformanceAppEntities()) { GridViewRow item = ProjectGrid.Rows[i]; int empId = emp[0].Emp_Id; EmpProject_t pro = new EmpProject_t(); var query = db.EmpProject_t.Where(m => m.EmpId == empId && m.Type == i); if (query.Count() != 0) { pro = query.Single(); } pro.EmpId = emp[0].Emp_Id; DropDownList combo_Self = item.FindControl("SelfRating") as DropDownList; pro.Self_Rating = combo_Self.SelectedValue; TextBox text_Self = item.FindControl("SelfComment") as TextBox; pro.SelfComments = text_Self.Text; DropDownList combo_App = item.FindControl("AppraiserRating") as DropDownList; pro.App_Rating = combo_App.SelectedValue; TextBox text_App = item.FindControl("AppraiserComment") as TextBox; pro.AppComments = text_App.Text; if (query.Count() == 0) { pro.EmpProjId = Guid.NewGuid(); } EmpProjectId += pro.EmpProjId.ToString() + ";"; pro.Type = i; if (query.Count() == 0) { db.EmpProject_t.Add(pro); } db.SaveChanges(); } } Session["EmpProjectId"] = EmpProjectId; { using (PerformanceAppEntities db1 = new PerformanceAppEntities()) { Appraisal_t appraisals = new Appraisal_t(); if (appraisal != null) { int empId = emp[0].Emp_Id; appraisals = db1.Appraisal_t.Where(m => m.EmpId == empId).Single(); } else { appraisals.AppId = Guid.NewGuid(); } appraisals.EmpId = emp[0].Emp_Id; appraisals.EmpProjects = Session["EmpProjectId"] as String; //appraisals.EmpSkills = Empskills; //appraisals.SelfOverall = SelfAssessment0.SelectedValue; //appraisals.AssessorOverAll = AssessorRating0.SelectedValue; //appraisals.FinalOverAll = FinalizedRating.SelectedValue; //appraisals.RecPromotion = RecommendedforPromotion0.Text; //appraisals.NotPromoting = notpromoting0.Text; if (appraisals.DoAssessment == null) { appraisals.DoAssessment = DateTime.Parse("1753-01-01 00:00:00"); } if (appraisals.DoAssessmentDisc == null) { appraisals.DoAssessmentDisc = DateTime.Parse("1753-01-01 00:00:00"); } if (appraisals.DoAssessorCompletion == null) { appraisals.DoAssessorCompletion = DateTime.Parse("1753-01-01 00:00:00"); } if (appraisals.DoFinalization == null) { appraisals.DoFinalization = DateTime.Parse("1753-01-01 00:00:00"); } appraisals.Understanding = Session["Understanding"] as String; appraisals.Responsibility = Session["Responsibility"] as String; appraisals.From = Convert.ToDateTime(Session["From"] as String); appraisals.To = Convert.ToDateTime(Session["To"] as String); appraisals.SkillRevRating = ReviewerRating.SelectedValue; appraisals.SkillRevComment = ReviewerComment.Text; appraisals.ProAppOtherCmnt = OtherTextBox.Text; if (appraisal == null) { db1.Appraisal_t.Add(appraisals); } db1.SaveChanges(); Session["appraisal"] = appraisals; } } } catch (Exception ex) { using (PerformanceAppEntities db = new PerformanceAppEntities()) { Log_t log = new Log_t(); log.Error_Message = ex.Message; log.Page = "PerformanceAppraisal3"; log.Method = "Save"; log.Datetime = DateTime.Now; db.Log_t.Add(log); db.SaveChanges(); Response.Redirect("~/Login.aspx", false); } } }