public void ABCFAMILIARES(char Op, Emp.FAMILIARES FAMILIARES) { const string querySql = "Emp.prFAMILIARES"; int IntReturn; try { using (SqlConnection connection = _objPersistencia.GetSqlConnection()) { connection.Open(); using (SqlCommand sqlCmnd = _objPersistencia.GetSqlCommand(connection, querySql, CommandType.StoredProcedure)) { sqlCmnd.Parameters.AddWithValue("@Op", Op); sqlCmnd.Parameters.AddWithValue("@IdFamiliar", FAMILIARES.IdFamiliar); sqlCmnd.Parameters.AddWithValue("@IdPersona", FAMILIARES.IdPersona); sqlCmnd.Parameters.AddWithValue("@IdEmpleado", FAMILIARES.IdEmpleado); // Ejecucion del sqlCommand using (SqlDataReader reader = sqlCmnd.ExecuteReader()) { if (!reader.Read()) { throw new Exception("La ejecución del Store Procedure no arrojó ningun dato"); } // Verificamos el resultado de la ejecucion de sp 0 = correcto y 1 existe algun error IntReturn = (int)reader["Result"]; if (IntReturn == 1) { throw new Exception(reader["MensajeError"].ToString()); } reader.Close(); } connection.Close(); } } } catch (Exception ex) { throw new Exception($"{ex.Message} \n\nSP: {querySql}"); } }
public void ABCFAMILIARES(char Op, Emp.FAMILIARES FAMILIARES) { _objAdEmpleados.ABCFAMILIARES(Op, FAMILIARES); }