public static List <Models.CatEmpleado> ConsultarEmpleados(int EmpleadoID) { using (var connection = ConnectionManager.ConnectionFactory()) { var result = new List <Models.CatEmpleado>(); using (var command = connection.CreateCommand()) { command.CommandText = "[CatEmpleadoSelectDiferente]"; command.CommandType = CommandType.StoredProcedure; command.AddParameter(EmpleadoID, DbType.Int32, "@EmpleadoID"); connection.Open(); using (var reader = command.ExecuteReader()) { while (reader.Read()) { Models.CatEmpleado elemento = new Models.CatEmpleado(); elemento.EmpleadoID = int.Parse(reader["EmpleadoID"].ToString()); elemento.Nombre = reader["Nombre"].ToString(); elemento.RolEmpleadoID = int.Parse(reader["RolEmpleadoID"].ToString()); elemento.TipoEmpleadoID = int.Parse(reader["TipoEmpleadoID"].ToString()); result.Add(elemento); } } return(result); } } }
public string GuardarEmpleado(Models.CatEmpleado oEmpleado) { JavaScriptSerializer serializer = new JavaScriptSerializer(); try { string respuesta = Manager.CatEmpleado.GuardarEmpleado(oEmpleado); return(serializer.Serialize(new { d = Response <object> .CrearResponseVacio <object>(true, respuesta) })); } catch (Exception e) { return(serializer.Serialize(new { d = Response <object> .CrearResponseVacio <object>(false, e.Message) })); } }
public static string GuardarEmpleado(Models.CatEmpleado oEmpleado) { using (var connection = ConnectionManager.ConnectionFactory()) { var result = new List <Models.CatTipoEmpleado>(); using (var command = connection.CreateCommand()) { command.CommandText = "[CatEmpleadoSave]"; command.CommandType = CommandType.StoredProcedure; command.AddParameter(oEmpleado.EmpleadoID, DbType.Int32, "@EmpleadoID"); command.AddParameter(oEmpleado.Nombre, DbType.String, "@Nombre"); command.AddParameter(oEmpleado.RolEmpleadoID, DbType.Int32, "@RolEmpleadoID"); command.AddParameter(oEmpleado.TipoEmpleadoID, DbType.Int32, "@TipoEmpleadoID"); IDbDataParameter respuesta = command.AddParameter(false, DbType.String, "@Respuesta", true); connection.Open(); using (var reader = command.ExecuteReader()) { return(respuesta.Value.ToString()); } } } }