private void BindData() { EmployeeBLL EmployeeBL = new EmployeeBLL(connectionString); List <EmployeeViewModel> employees = EmployeeBL.GetEmployeeInventory(); string[] date_notime = new string[3]; List <string> employees_in_modal = new List <string>(); foreach (EmployeeViewModel element in employees) { date_notime = element.BirthDate.Split(' '); element.BirthDate = date_notime[0]; date_notime = element.StartDate.Split(' '); element.StartDate = date_notime[0]; if (!String.IsNullOrEmpty(element.EndDate)) { date_notime = element.EndDate.Split(' '); element.EndDate = date_notime[0]; } else { employees_in_modal.Add(element.Name); } } TerminateEmployeeList.DataSource = employees_in_modal; TerminateEmployeeList.DataBind(); EmployeeList.DataSource = employees; EmployeeList.DataBind(); }
protected void bind(string sortExpression) { sortExpression = sortExpression.Replace("Ascending", "ASC"); using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); using (SqlDataAdapter dAd = new SqlDataAdapter("AireSpringEmployees_GetAll", con)) { DataTable dTable = new DataTable(); dAd.Fill(dTable); dTable.DefaultView.Sort = sortExpression; EmployeeList.DataSource = dTable; EmployeeList.DataBind(); } Session.Clear(); con.Close(); } }
protected void SearchClick(object sender, EventArgs e) { if (EmployeeLastNameSearch.Text == "" && PhoneNumberSearch.Text == "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Search fields cannot be blank!')", true); return; } else if (EmployeeLastNameSearch.Text != "" && PhoneNumberSearch.Text != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('You cannot use both fields!')", true); return; } using (SqlConnection con = new SqlConnection(connectionString)) { con.Open(); var cmd = con.CreateCommand(); string cmdText; if (EmployeeLastNameSearch.Text != "") { cmdText = "AireSpringEmployees_GetByLastName"; cmd.Parameters.AddWithValue("@EmployeeLastName", EmployeeLastNameSearch.Text); } else { cmdText = "AireSpringEmployees_GetByPhone"; cmd.Parameters.AddWithValue("@EmployeePhone", PhoneNumberSearch.Text); } cmd.CommandText = cmdText; cmd.CommandType = System.Data.CommandType.StoredProcedure; using (SqlDataReader reader = cmd.ExecuteReader()) { DataTable dTable = new DataTable(); dTable.Load(reader); EmployeeList.DataSource = dTable; Session["dtable"] = dTable; EmployeeList.EditIndex = -1; EmployeeList.DataBind(); } } }
protected void searchBind(string sortExpression) { sortExpression = sortExpression.Replace("Ascending", "ASC"); DataTable dTable = (DataTable)Session["dTable"]; dTable.DefaultView.Sort = sortExpression; EmployeeList.DataSource = dTable; EmployeeList.DataBind(); }
protected void GetEmp() { query = "select Fname + ' ' + Lname AS FullName, Email from Employee where DepartementNo=" + depNum; da = new SqlDataAdapter(query, con); da.Fill(ds); EmployeeList.DataSource = ds; EmployeeList.DataTextField = "FullName"; EmployeeList.DataValueField = "Email"; EmployeeList.DataBind(); EmployeeList.Items.Insert(0, new ListItem("Select an Employee to Assign", "NA")); }
protected void Page_Load(object sender, EventArgs e) { EmployeeList.Attributes["onchange"] = "CurrentEmployee_OnChange(this);"; Guid currentEmployeeId = CurrentUserSettings.GetCurrentUser(); if (currentEmployeeId == Guid.Empty) { IList <Employee> list = EmployeeRepository.GetAll(); if (list != null && list.Count > 0) { currentEmployeeId = list[0].Id; CurrentUserSettings.SetUserInCookies(currentEmployeeId); } } EmployeeList.DataSource = GetData(); EmployeeList.DataBind(); EmployeeList.SelectedValue = currentEmployeeId.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["EmployeeID"] != null) { LabelMessage.Text = Session["EmployeeID"].ToString(); } //else //{ // Session["EmployeeID"] = "2931"; // Session["LastSix"] = "22160"; //} int employeeID = Convert.ToInt32(Session["EmployeeID"]); using (SSIRentEntities context = new SSIRentEntities()) { EmployeeList.DataSource = context.Employees .Where(emp => emp.TerminationDate == null && emp.EmployeeID != employeeID) .OrderBy(emp => emp.EmployeeNumber) .ToList(); EmployeeList.DataBind(); } }
private void BindData() { EmployeeBLL EmployeeBL = new EmployeeBLL(connectionString); List <EmployeeViewModel> employees = EmployeeBL.GetCurrentEmployeeInventory(); string[] date_notime = new string[3]; List <string> employees_in_modal = new List <string>(); /* * for (int i = 0; i < employees.Count; i++) * { * if (!String.IsNullOrEmpty(employees[i].EndDate)) * employees.RemoveAt(i); * } */ foreach (EmployeeViewModel element in employees) { date_notime = element.BirthDate.Split(' '); element.BirthDate = date_notime[0]; date_notime = element.StartDate.Split(' '); element.StartDate = date_notime[0]; if (!String.IsNullOrEmpty(element.EndDate)) { date_notime = element.EndDate.Split(' '); element.EndDate = date_notime[0]; } employees_in_modal.Add(element.Name); } TerminateEmployeeList.DataSource = employees_in_modal; TerminateEmployeeList.DataBind(); EmployeeList.DataSource = employees; EmployeeList.DataBind(); }