public void PreencheGrid() { FAMIS_BLL.Employee _Employee = new FAMIS_BLL.Employee(); grvEmployee.DataSource = _Employee.Select(""); grvEmployee.DataBind(); grvEmployee.AllowPaging = true; grvEmployee.PageSize = 5; }
protected void btnEditar_Click(object sender, EventArgs e) { ImageButton btnEdit = sender as ImageButton; GridViewRow grid = (GridViewRow)btnEdit.NamingContainer; FAMIS_BLL.Employee _employee = new FAMIS_BLL.Employee(); List<Model.Employee> ListEmployee = _employee.Select(" Where Employee_id=" + grvEmployee.DataKeys[grid.RowIndex].Values[0].ToString()); TxtEmployee_id.Text = ListEmployee.ElementAt(0).Employee_id.ToString(); TxtFirstName.Text = ListEmployee.ElementAt(0).First_name.ToString(); txtLast_name.Text = ListEmployee.ElementAt(0).Last_name.ToString(); DropDownPosition.SelectedValue = ListEmployee.ElementAt(0).Position_id.ToString(); DropDownAgencies.SelectedValue = ListEmployee.ElementAt(0).Agency_id.ToString(); TxtSalary.Text = ListEmployee.ElementAt(0).Salary.ToString(); txtDateHired.Text = ListEmployee.ElementAt(0).Date_hired.ToString(); TxtCode.Text = ListEmployee.ElementAt(0).Code.ToString(); HttpContext.Current.Session["EmployeePhoto"] = ListEmployee.ElementAt(0).Picture.ToString(); PicturePhoto.ImageUrl = Request.ApplicationPath + "/imagens/UsersPhoto/" + HttpContext.Current.Session["EmployeePhoto"].ToString() + ".jpg"; }
protected void btnExcluir_Click(object sender, EventArgs e) { try { ImageButton btnEdit = sender as ImageButton; GridViewRow grid = (GridViewRow)btnEdit.NamingContainer; FAMIS_BLL.Employee _employee = new FAMIS_BLL.Employee(); FAMIS_BLL.Employee _employeeDel = new FAMIS_BLL.Employee(); List<Model.Employee> ListEmployee = _employee.Select(" Where Employee_id=" + grvEmployee.DataKeys[grid.RowIndex].Values[0].ToString()); _employeeDel.Remove(ListEmployee.ElementAt(0)); PreencheGrid(); } catch (Exception ex) { throw new Exception("Error: " + ex.Message.ToString()); } }
protected void grvEmployee_PageIndexChanging(Object sender, GridViewPageEventArgs e) { FAMIS_BLL.Employee _employee = new FAMIS_BLL.Employee(); grvEmployee.DataSource = _employee.Select(""); //lista; grvEmployee.PageIndex = e.NewPageIndex; grvEmployee.DataBind(); }