protected void Page_Load(object sender, EventArgs e) { try { emp = Session["Employee"] as List <Employee_t>; Role_t role = new Role_t(); if (emp != null) { if (Session["Type"] != null) { type = Convert.ToInt32(Session["Type"].ToString()); } if (emp[0].PwdReset == 1) { Response.Redirect("~/ResetPassword.aspx", false); } if (!Page.IsPostBack) { if (type == 1 || type == 2) { int empId = Convert.ToInt32(Request.QueryString["EmpId"].ToString()); using (PerformanceAppEntities db = new PerformanceAppEntities()) { Session["Firstname"] = emp[0].Firstname; Session["Lastname"] = emp[0].Lastname; //Getting the Reviewer or the appraiser object backup.. Session["Employee_Bckup"] = Session["Employee"]; emp = db.Employee_t.Where(m => m.Emp_Id == empId).ToList(); Session["Employee"] = emp; } } using (PerformanceAppEntities db = new PerformanceAppEntities()) { if (Session["Type"] != null) { if (type == 1) { FromTextBox.Enabled = false; ToTextBox.Enabled = false; Responsibility.Enabled = false; Understanding.Enabled = false; } else if (type == 2) { FromTextBox.Enabled = false; ToTextBox.Enabled = false; Responsibility.Enabled = false; Understanding.Enabled = false; } else if (type == 0) { } } empId = emp[0].Emp_Id; var query = db.Appraisal_t.Where(m => m.EmpId == empId).ToList(); if (query.Count() != 0) { appraisal = query.Single(); } Guid roleId = emp[0].RoleId ?? Guid.Empty; role = db.Role_t.Where(m => m.RoleId == roleId).Single(); Session["Role"] = role; Role.Text = role.Name; if (appraisal != null) { Session["appraisal"] = appraisal; } } if (appraisal != null) { FromTextBox.Text = appraisal.From.Value.ToString("dd-MM-yyyy"); ToTextBox.Text = appraisal.To.Value.ToString("dd-MM-yyyy"); Responsibility.Text = appraisal.Responsibility; Understanding.Text = appraisal.Understanding; } NameTextBox.Text = emp[0].Firstname + "" + emp[0].Lastname; if (type == 0) { name.Text = emp[0].Firstname + " " + emp[0].Lastname; } else { name.Text = Session["Firstname"].ToString() + " " + Session["Lastname"].ToString(); } DateofJoiningTextBox.Text = emp[0].Dateofjoining.Value.ToString("dd-MM-yyyy"); using (PerformanceAppEntities db1 = new PerformanceAppEntities()) { if (emp[0].Appraiser != null) { int appr = emp[0].Appraiser ?? 0; Employee_t app = db1.Employee_t.Where(m => m.Emp_Id == appr).Single(); AppraiserTextBox.Text = app.Firstname + "" + app.Lastname; } else { AppraiserTextBox.Text = ""; } if (emp[0].Reviewer != null) { int revr = emp[0].Reviewer ?? 0; Employee_t rev = db1.Employee_t.Where(m => m.Emp_Id == revr).Single(); ReviewerTextBox.Text = rev.Firstname + "" + rev.Lastname; } else { ReviewerTextBox.Text = ""; } } if (appraisal == null) { FromTextBox.Text = DateTime.Now.ToString("dd-MM-yyyy"); ToTextBox.Text = DateTime.Now.AddDays(30).ToString("dd-MM-yyyy"); } } } else { Response.Redirect("~/Login.aspx", false); } } catch (Exception ex) { using (PerformanceAppEntities db = new PerformanceAppEntities()) { Log_t log = new Log_t(); log.Error_Message = ex.Message; log.Page = "PerformanceAppraisal"; log.Method = "Page_Load"; log.Datetime = DateTime.Now; db.Log_t.Add(log); db.SaveChanges(); Response.Redirect("~/Login.aspx", false); } } }
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); } } }