/// <summary> /// Page_Load /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { try { _userID = Convert.ToInt32(Session["UserID"]); _companyID = Convert.ToInt32(Session["CompanyID"]); _employeeID = Convert.ToInt32(Session["EmployeeID"]); if (!IsPostBack) { // GetUserPhoto(); commented on 25/06/2014 if (_userID == 0 && _companyID == 0) { Response.Redirect("~/Login.aspx", false); } else { DataTable dataTable = new DataTable(); //dataTable.Tables.Add("Table"); dataTable.Columns.Add("ID", typeof(int)); dataTable.Columns.Add("ParentID", typeof(int)); dataTable.Columns.Add("Text", typeof(string)); dataTable.Columns.Add("Url", typeof(string)); DataTable tree = new DataTable(); //tree = _menuDL.GetMenuParentItems(_userID, _companyID); tree = _menuDL.GetMenuItems(_userID, _companyID); foreach (DataRow row in tree.Rows) { DataRow newrow = dataTable.NewRow(); newrow["ID"] = row["id"]; newrow["Url"] = row["Url"].ToString().Replace("..", "~"); newrow["Text"] = row["Title"]; if (row["Parent"] != null && row["Title"].ToString() != "Select Company") // For Select company menu removing { if (row["Parent"].ToString() == "1" || row["Parent"].ToString() == "") { newrow["ParentID"] = 0; } else { newrow["ParentID"] = row["Parent"]; } } dataTable.Rows.Add(newrow); } AddItems(ECMenu.Items, 0, dataTable); } if (_employeeID != 0) { EmployeeDL employeeDL = new EmployeeDL(); lblProfileCount.Text = Convert.ToString(employeeDL.GetEmployeeProfileCount(_employeeID)); imgEmployeeProfileCount.AlternateText = String.Format("{0} Percent Complete", lblProfileCount.Text); imgEmployeeProfileCount.Width = Unit.Percentage(Convert.ToInt32(lblProfileCount.Text)); trProfileCount.Visible = true; } else { trProfileCount.Visible = false; } sPageName = GetPagePath(); //btnOrderImage.Visible = false; } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("Menu.ascx", "", "Page_Load", ex.Message.ToString(), new ACEConnection()); } }
/// <summary> /// gvEmployeeDetails_RowDataBound /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvEmployeeDetails_RowDataBound(object sender, GridViewRowEventArgs e) { try { if (e.Row.RowType == DataControlRowType.DataRow) { // Set the Serial Number Label lblSerial = (Label)e.Row.FindControl("lblSerial"); lblSerial.Text = ((gvEmployeeDetails.PageIndex * gvEmployeeDetails.PageSize) + e.Row.RowIndex + 1).ToString(); // Attach Confirmation to the Delete Image Button //ImageButton lnkDelete = (ImageButton)e.Row.FindControl("ibtnDeleteEmployee"); //lnkDelete.Attributes.Add("OnClick", "return confirm('Are you sure you want to delete?');"); ImageButton btnEditEmployee = (ImageButton)e.Row.FindControl("ibtnEditEmployee"); btnEditEmployee.Attributes.Add("OnClick", "repagination();"); // Display the Dates in dd/MM/yyyy format DateTime dTime; if (e.Row.Cells[4].Text != " ") { dTime = Convert.ToDateTime(e.Row.Cells[4].Text.ToString()); e.Row.Cells[4].Text = dTime.ToString(_dateFormat); } if (e.Row.Cells[5].Text != "") { string phoneStr = e.Row.Cells[5].Text; if (phoneStr.Length > 10) { string str1 = phoneStr.Remove(0, phoneStr.Length - 10); string str2 = str1.Remove(0, 5); string str3 = str1.Remove(5, 5); string str4 = str3 + " " + str2; e.Row.Cells[5].Text = str4; } if (phoneStr.Length == 10) { string str5 = e.Row.Cells[5].Text; string str6 = str5.Remove(0, 5); string str7 = str5.Remove(5, 5); string str8 = str7 + " " + str6; e.Row.Cells[5].Text = str8; } } // Hide Columns e.Row.Cells[3].Visible = false; Image imgProfileCount = (Image)e.Row.FindControl("imgEmployeeProfileCount"); EmployeeDL employeeDL = new EmployeeDL(); imgProfileCount.Width = Unit.Percentage(Convert.ToInt32(Convert.ToString(employeeDL.GetEmployeeProfileCount(Convert.ToInt32(e.Row.Cells[3].Text))))); imgProfileCount.AlternateText = imgProfileCount.Width.ToString(); imgProfileCount.Visible = false; Label lblProfileCount = (Label)e.Row.FindControl("lblEmployeeProfileCount"); lblProfileCount.Text = imgProfileCount.Width.ToString(); } else if (e.Row.RowType == DataControlRowType.Header) { // Hide Column Headers e.Row.Cells[3].Visible = false; } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("ManageEmployee.aspx", "", "gvEmployeeDetails_RowDataBound", ex.Message.ToString(), new ACEConnection()); } }