protected void txtDepartamento_OnTextChanged(object sender, EventArgs e) { if (txtBuscar.ToString().Length > 0) { ModelEpleadoEmpresa mdEmpleado = new ModelEpleadoEmpresa(); mdEmpleado.Nombredepartamento = txtBuscar.Value.ToString(); try { DataTable dataTable = empleadoSRV.ObtenerEmpleados(mdEmpleado).Tables[0]; if (dataTable.Rows.Count != 0) { gvEmpleados.DataSource = dataTable; gvEmpleados.DataBind(); } else { DataBinderEmpleados(); } } catch (Exception) { Response.Redirect("../GUI/Empleados.aspx"); } } }
protected void BuscarEmpleado_OnClick(object sender, EventArgs e) { if (txtBuscar.Value.Length > 0) { ModelEpleadoEmpresa empleadoEmpresaBO = new ModelEpleadoEmpresa() { Nombreempleado = txtBuscar.Value.ToString() }; try { DataTable empleadoEmpresaDT = empleadosSRV.ObtenerEmpleados(empleadoEmpresaBO).Tables[0]; if (empleadoEmpresaDT.Rows[0].ToString().Length > 0) { txtEmpleadoEmpresaID.Value = empleadoEmpresaDT.Rows[0]["empleadoempresaID"].ToString(); txtNombreEmpleado.Text = empleadoEmpresaDT.Rows[0]["nombreempleado"].ToString(); txtApellidoPaterno.Text = empleadoEmpresaDT.Rows[0]["apellidopaterno"].ToString(); txtApellidoMaterno.Text = empleadoEmpresaDT.Rows[0]["apellidomaterno"].ToString(); txtDepartamento.Text = empleadoEmpresaDT.Rows[0]["nombredepartamento"].ToString(); txtPuesto.Text = empleadoEmpresaDT.Rows[0]["nombrepuesto"].ToString(); txtSalario.Text = double.Parse(empleadoEmpresaDT.Rows[0]["sueldo"].ToString()).ToString(); } txtBuscar.Value = ""; } catch (Exception ex) { ex.Message.ToString(); } } }
public DataTable ListaEmpleados() { DataTable dataTable; ModelEpleadoEmpresa mdEmpleado = new ModelEpleadoEmpresa(); dataTable = empleadoSRV.ObtenerEmpleados(mdEmpleado).Tables[0]; return(dataTable); }
public DataSet GetEmpleados(object obj) { string cadenaWhere = ""; bool edo = false; DataSet empleadosDS = new DataSet(); ModelEpleadoEmpresa data = (ModelEpleadoEmpresa)obj; adapter = new SqlDataAdapter(); using (SqlConnection connection = new SqlConnection(cadena)) { connection.Open(); command = connection.CreateCommand(); transaction = connection.BeginTransaction("SelectEmpleados"); command.Connection = connection; command.Transaction = transaction; try { if (data.Nombreempleado != null) { cadenaWhere = cadenaWhere + " nombreempleado like '" + data.Nombreempleado + "%' or"; edo = true; } if (data.Apellidomaterno != null) { cadenaWhere = cadenaWhere + " apellidomaterno=@ApellidoMaterno and"; command.Parameters.Add("@ApellidoMaterno", SqlDbType.VarChar); command.Parameters["@ApellidoMaterno"].Value = data.Apellidomaterno; edo = true; } if (data.Apellidopaterno != null) { cadenaWhere = cadenaWhere + " apellidopaterno=@ApellidoPaterno and"; command.Parameters.Add("@ApellidoPaterno", SqlDbType.VarChar); command.Parameters["@ApellidoPaterno"].Value = data.Apellidopaterno; edo = true; } if (data.Nombredepartamento != null) { cadenaWhere = cadenaWhere + " nombredepartamento like '" + data.Nombredepartamento + "%' or"; edo = true; } if (edo == true) { cadenaWhere = " WHERE " + cadenaWhere.Remove(cadenaWhere.Length - 3, 3); } command.CommandText = " SELECT * FROM vwEmpleadoEmpresa " + cadenaWhere + " and NOT EXISTS (SELECT * FROM vwNominas WHERE vwNominas.nombreempleado = vwEmpleadoEmpresa.nombreempleado)"; transaction.Commit(); adapter.SelectCommand = command; adapter.Fill(empleadosDS); connection.Close(); } catch (System.Exception ex) { try { ex.Message.ToString(); connection.Close(); transaction.Rollback(); } catch (System.Exception) { } } return(empleadosDS); } }